Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: omap: Allow building as a loadable module

We currently get all kinds of errors building the omap gpio driver
as a module starting with:

undefined reference to `omap2_gpio_resume_after_idle'
undefined reference to `omap2_gpio_prepare_for_idle'
...

Let's fix the issue by adding inline functions to the header.
Note that we can now also remove the two unused functions for
omap_set_gpio_debounce and omap_set_gpio_debounce_time.

Then doing rmmod on the module produces further warnings
because of missing exit related functions. Let's add those.

And finally, we can make the Kconfig entry just a tristate
option that's selected for omaps.

Cc: Javier Martinez Canillas <javier@dowhile0.org>
Cc: Kevin Hilman <khilman@deeprootsystems.com>
Cc: Nishanth Menon <nm@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Reviewed-by: Grygorii Strashko <grygorii.strashko@linaro.org>
Acked-by: Santosh Shilimkar <ssantosh@kernel.org>
Reviewed-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Tony Lindgren and committed by
Linus Walleij
cac089f9 606f13e9

+35 -3
+1 -1
drivers/gpio/Kconfig
··· 316 316 family of SOCs. 317 317 318 318 config GPIO_OMAP 319 - bool "TI OMAP GPIO support" if COMPILE_TEST && !ARCH_OMAP2PLUS 319 + tristate "TI OMAP GPIO support" if ARCH_OMAP2PLUS || COMPILE_TEST 320 320 default y if ARCH_OMAP 321 321 depends on ARM 322 322 select GENERIC_IRQ_CHIP
+24
drivers/gpio/gpio-omap.c
··· 1263 1263 return 0; 1264 1264 } 1265 1265 1266 + static int omap_gpio_remove(struct platform_device *pdev) 1267 + { 1268 + struct gpio_bank *bank = platform_get_drvdata(pdev); 1269 + 1270 + list_del(&bank->node); 1271 + gpiochip_remove(&bank->chip); 1272 + pm_runtime_disable(bank->dev); 1273 + 1274 + return 0; 1275 + } 1276 + 1266 1277 #ifdef CONFIG_ARCH_OMAP2PLUS 1267 1278 1268 1279 #if defined(CONFIG_PM) ··· 1459 1448 } 1460 1449 #endif /* CONFIG_PM */ 1461 1450 1451 + #if IS_BUILTIN(CONFIG_GPIO_OMAP) 1462 1452 void omap2_gpio_prepare_for_idle(int pwr_mode) 1463 1453 { 1464 1454 struct gpio_bank *bank; ··· 1485 1473 pm_runtime_get_sync(bank->dev); 1486 1474 } 1487 1475 } 1476 + #endif 1488 1477 1489 1478 #if defined(CONFIG_PM) 1490 1479 static void omap_gpio_init_context(struct gpio_bank *p) ··· 1641 1628 1642 1629 static struct platform_driver omap_gpio_driver = { 1643 1630 .probe = omap_gpio_probe, 1631 + .remove = omap_gpio_remove, 1644 1632 .driver = { 1645 1633 .name = "omap_gpio", 1646 1634 .pm = &gpio_pm_ops, ··· 1659 1645 return platform_driver_register(&omap_gpio_driver); 1660 1646 } 1661 1647 postcore_initcall(omap_gpio_drv_reg); 1648 + 1649 + static void __exit omap_gpio_exit(void) 1650 + { 1651 + platform_driver_unregister(&omap_gpio_driver); 1652 + } 1653 + module_exit(omap_gpio_exit); 1654 + 1655 + MODULE_DESCRIPTION("omap gpio driver"); 1656 + MODULE_ALIAS("platform:gpio-omap"); 1657 + MODULE_LICENSE("GPL v2");
+10 -2
include/linux/platform_data/gpio-omap.h
··· 208 208 int (*get_context_loss_count)(struct device *dev); 209 209 }; 210 210 211 + #if IS_BUILTIN(CONFIG_GPIO_OMAP) 211 212 extern void omap2_gpio_prepare_for_idle(int off_mode); 212 213 extern void omap2_gpio_resume_after_idle(void); 213 - extern void omap_set_gpio_debounce(int gpio, int enable); 214 - extern void omap_set_gpio_debounce_time(int gpio, int enable); 214 + #else 215 + static inline void omap2_gpio_prepare_for_idle(int off_mode) 216 + { 217 + } 218 + 219 + static inline void omap2_gpio_resume_after_idle(void) 220 + { 221 + } 222 + #endif 215 223 216 224 #endif