Skip to content

Commit 600485e

Browse files
haukelinvjw
authored andcommitted
ssb: unregister gpios before unloading ssb
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>
1 parent c50ae94 commit 600485e

3 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎drivers/ssb/driver_gpio.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,15 @@ int ssb_gpio_init(struct ssb_bus *bus)
174174

175175
return -1;
176176
}
177+
178+
int ssb_gpio_unregister(struct ssb_bus *bus)
179+
{
180+
if (ssb_chipco_available(&bus->chipco) ||
181+
ssb_extif_available(&bus->extif)) {
182+
return gpiochip_remove(&bus->gpio);
183+
} else {
184+
SSB_WARN_ON(1);
185+
}
186+
187+
return -1;
188+
}

‎drivers/ssb/main.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,15 @@ static void ssb_devices_unregister(struct ssb_bus *bus)
443443

444444
void ssb_bus_unregister(struct ssb_bus *bus)
445445
{
446+
int err;
447+
448+
err = ssb_gpio_unregister(bus);
449+
if (err == -EBUSY)
450+
ssb_dprintk(KERN_ERR PFX "Some GPIOs are still in use.\n");
451+
else if (err)
452+
ssb_dprintk(KERN_ERR PFX
453+
"Can not unregister GPIO driver: %i\n", err);
454+
446455
ssb_buses_lock();
447456
ssb_devices_unregister(bus);
448457
list_del(&bus->list);

‎drivers/ssb/ssb_private.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,16 @@ static inline void ssb_extif_init(struct ssb_extif *extif)
252252

253253
#ifdef CONFIG_SSB_DRIVER_GPIO
254254
extern int ssb_gpio_init(struct ssb_bus *bus);
255+
extern int ssb_gpio_unregister(struct ssb_bus *bus);
255256
#else /* CONFIG_SSB_DRIVER_GPIO */
256257
static inline int ssb_gpio_init(struct ssb_bus *bus)
257258
{
258259
return -ENOTSUPP;
259260
}
261+
static inline int ssb_gpio_unregister(struct ssb_bus *bus)
262+
{
263+
return 0;
264+
}
260265
#endif /* CONFIG_SSB_DRIVER_GPIO */
261266

262267
#endif /* LINUX_SSB_PRIVATE_H_ */

0 commit comments

Comments
 (0)