Skip to content

Commit cac089f

Browse files
tmlindlinusw
authored andcommitted
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 <[email protected]> Cc: Kevin Hilman <[email protected]> Cc: Nishanth Menon <[email protected]> Signed-off-by: Tony Lindgren <[email protected]> Reviewed-by: Grygorii Strashko <[email protected]> Acked-by: Santosh Shilimkar <[email protected]> Reviewed-by: Felipe Balbi <[email protected]> Signed-off-by: Linus Walleij <[email protected]>
1 parent 606f13e commit cac089f

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

drivers/gpio/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ config GPIO_OCTEON
316316
family of SOCs.
317317

318318
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
320320
default y if ARCH_OMAP
321321
depends on ARM
322322
select GENERIC_IRQ_CHIP

drivers/gpio/gpio-omap.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,17 @@ static int omap_gpio_probe(struct platform_device *pdev)
12631263
return 0;
12641264
}
12651265

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+
12661277
#ifdef CONFIG_ARCH_OMAP2PLUS
12671278

12681279
#if defined(CONFIG_PM)
@@ -1448,6 +1459,7 @@ static int omap_gpio_runtime_resume(struct device *dev)
14481459
}
14491460
#endif /* CONFIG_PM */
14501461

1462+
#if IS_BUILTIN(CONFIG_GPIO_OMAP)
14511463
void omap2_gpio_prepare_for_idle(int pwr_mode)
14521464
{
14531465
struct gpio_bank *bank;
@@ -1473,6 +1485,7 @@ void omap2_gpio_resume_after_idle(void)
14731485
pm_runtime_get_sync(bank->dev);
14741486
}
14751487
}
1488+
#endif
14761489

14771490
#if defined(CONFIG_PM)
14781491
static void omap_gpio_init_context(struct gpio_bank *p)
@@ -1628,6 +1641,7 @@ MODULE_DEVICE_TABLE(of, omap_gpio_match);
16281641

16291642
static struct platform_driver omap_gpio_driver = {
16301643
.probe = omap_gpio_probe,
1644+
.remove = omap_gpio_remove,
16311645
.driver = {
16321646
.name = "omap_gpio",
16331647
.pm = &gpio_pm_ops,
@@ -1645,3 +1659,13 @@ static int __init omap_gpio_drv_reg(void)
16451659
return platform_driver_register(&omap_gpio_driver);
16461660
}
16471661
postcore_initcall(omap_gpio_drv_reg);
1662+
1663+
static void __exit omap_gpio_exit(void)
1664+
{
1665+
platform_driver_unregister(&omap_gpio_driver);
1666+
}
1667+
module_exit(omap_gpio_exit);
1668+
1669+
MODULE_DESCRIPTION("omap gpio driver");
1670+
MODULE_ALIAS("platform:gpio-omap");
1671+
MODULE_LICENSE("GPL v2");

include/linux/platform_data/gpio-omap.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,17 @@ struct omap_gpio_platform_data {
208208
int (*get_context_loss_count)(struct device *dev);
209209
};
210210

211+
#if IS_BUILTIN(CONFIG_GPIO_OMAP)
211212
extern void omap2_gpio_prepare_for_idle(int off_mode);
212213
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
215223

216224
#endif

0 commit comments

Comments
 (0)