Skip to content

Commit

Permalink
ssb: unregister gpios before unloading ssb
Browse files Browse the repository at this point in the history
This patch unregisters the gpio chip before ssb gets unloaded.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Hauke Mehrtens authored and John W. Linville committed Feb 4, 2013
1 parent c50ae94 commit 600485e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/ssb/driver_gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,15 @@ int ssb_gpio_init(struct ssb_bus *bus)

return -1;
}

int ssb_gpio_unregister(struct ssb_bus *bus)
{
if (ssb_chipco_available(&bus->chipco) ||
ssb_extif_available(&bus->extif)) {
return gpiochip_remove(&bus->gpio);
} else {
SSB_WARN_ON(1);
}

return -1;
}
9 changes: 9 additions & 0 deletions drivers/ssb/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,15 @@ static void ssb_devices_unregister(struct ssb_bus *bus)

void ssb_bus_unregister(struct ssb_bus *bus)
{
int err;

err = ssb_gpio_unregister(bus);
if (err == -EBUSY)
ssb_dprintk(KERN_ERR PFX "Some GPIOs are still in use.\n");
else if (err)
ssb_dprintk(KERN_ERR PFX
"Can not unregister GPIO driver: %i\n", err);

ssb_buses_lock();
ssb_devices_unregister(bus);
list_del(&bus->list);
Expand Down
5 changes: 5 additions & 0 deletions drivers/ssb/ssb_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,16 @@ static inline void ssb_extif_init(struct ssb_extif *extif)

#ifdef CONFIG_SSB_DRIVER_GPIO
extern int ssb_gpio_init(struct ssb_bus *bus);
extern int ssb_gpio_unregister(struct ssb_bus *bus);
#else /* CONFIG_SSB_DRIVER_GPIO */
static inline int ssb_gpio_init(struct ssb_bus *bus)
{
return -ENOTSUPP;
}
static inline int ssb_gpio_unregister(struct ssb_bus *bus)
{
return 0;
}
#endif /* CONFIG_SSB_DRIVER_GPIO */

#endif /* LINUX_SSB_PRIVATE_H_ */

0 comments on commit 600485e

Please sign in to comment.