Commit 600485edaef65d89f5c44ce62baa7cac961cd50d

Authored by Hauke Mehrtens
Committed by John W. Linville
1 parent c50ae9470e

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>

Showing 3 changed files with 26 additions and 0 deletions Side-by-side Diff

drivers/ssb/driver_gpio.c
... ... @@ -174,4 +174,16 @@
174 174  
175 175 return -1;
176 176 }
  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 +}
... ... @@ -443,6 +443,15 @@
443 443  
444 444 void ssb_bus_unregister(struct ssb_bus *bus)
445 445 {
  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 +
446 455 ssb_buses_lock();
447 456 ssb_devices_unregister(bus);
448 457 list_del(&bus->list);
drivers/ssb/ssb_private.h
... ... @@ -252,10 +252,15 @@
252 252  
253 253 #ifdef CONFIG_SSB_DRIVER_GPIO
254 254 extern int ssb_gpio_init(struct ssb_bus *bus);
  255 +extern int ssb_gpio_unregister(struct ssb_bus *bus);
255 256 #else /* CONFIG_SSB_DRIVER_GPIO */
256 257 static inline int ssb_gpio_init(struct ssb_bus *bus)
257 258 {
258 259 return -ENOTSUPP;
  260 +}
  261 +static inline int ssb_gpio_unregister(struct ssb_bus *bus)
  262 +{
  263 + return 0;
259 264 }
260 265 #endif /* CONFIG_SSB_DRIVER_GPIO */
261 266