Commit cac089f9 authored by Tony Lindgren's avatar Tony Lindgren Committed by Linus Walleij

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: default avatarTony Lindgren <tony@atomide.com>
Reviewed-by: default avatarGrygorii Strashko <grygorii.strashko@linaro.org>
Acked-by: default avatarSantosh Shilimkar <ssantosh@kernel.org>
Reviewed-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 606f13e9
...@@ -316,7 +316,7 @@ config GPIO_OCTEON ...@@ -316,7 +316,7 @@ config GPIO_OCTEON
family of SOCs. family of SOCs.
config GPIO_OMAP config GPIO_OMAP
bool "TI OMAP GPIO support" if COMPILE_TEST && !ARCH_OMAP2PLUS tristate "TI OMAP GPIO support" if ARCH_OMAP2PLUS || COMPILE_TEST
default y if ARCH_OMAP default y if ARCH_OMAP
depends on ARM depends on ARM
select GENERIC_IRQ_CHIP select GENERIC_IRQ_CHIP
......
...@@ -1263,6 +1263,17 @@ static int omap_gpio_probe(struct platform_device *pdev) ...@@ -1263,6 +1263,17 @@ static int omap_gpio_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int omap_gpio_remove(struct platform_device *pdev)
{
struct gpio_bank *bank = platform_get_drvdata(pdev);
list_del(&bank->node);
gpiochip_remove(&bank->chip);
pm_runtime_disable(bank->dev);
return 0;
}
#ifdef CONFIG_ARCH_OMAP2PLUS #ifdef CONFIG_ARCH_OMAP2PLUS
#if defined(CONFIG_PM) #if defined(CONFIG_PM)
...@@ -1448,6 +1459,7 @@ static int omap_gpio_runtime_resume(struct device *dev) ...@@ -1448,6 +1459,7 @@ static int omap_gpio_runtime_resume(struct device *dev)
} }
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
#if IS_BUILTIN(CONFIG_GPIO_OMAP)
void omap2_gpio_prepare_for_idle(int pwr_mode) void omap2_gpio_prepare_for_idle(int pwr_mode)
{ {
struct gpio_bank *bank; struct gpio_bank *bank;
...@@ -1473,6 +1485,7 @@ void omap2_gpio_resume_after_idle(void) ...@@ -1473,6 +1485,7 @@ void omap2_gpio_resume_after_idle(void)
pm_runtime_get_sync(bank->dev); pm_runtime_get_sync(bank->dev);
} }
} }
#endif
#if defined(CONFIG_PM) #if defined(CONFIG_PM)
static void omap_gpio_init_context(struct gpio_bank *p) static void omap_gpio_init_context(struct gpio_bank *p)
...@@ -1628,6 +1641,7 @@ MODULE_DEVICE_TABLE(of, omap_gpio_match); ...@@ -1628,6 +1641,7 @@ MODULE_DEVICE_TABLE(of, omap_gpio_match);
static struct platform_driver omap_gpio_driver = { static struct platform_driver omap_gpio_driver = {
.probe = omap_gpio_probe, .probe = omap_gpio_probe,
.remove = omap_gpio_remove,
.driver = { .driver = {
.name = "omap_gpio", .name = "omap_gpio",
.pm = &gpio_pm_ops, .pm = &gpio_pm_ops,
...@@ -1645,3 +1659,13 @@ static int __init omap_gpio_drv_reg(void) ...@@ -1645,3 +1659,13 @@ static int __init omap_gpio_drv_reg(void)
return platform_driver_register(&omap_gpio_driver); return platform_driver_register(&omap_gpio_driver);
} }
postcore_initcall(omap_gpio_drv_reg); postcore_initcall(omap_gpio_drv_reg);
static void __exit omap_gpio_exit(void)
{
platform_driver_unregister(&omap_gpio_driver);
}
module_exit(omap_gpio_exit);
MODULE_DESCRIPTION("omap gpio driver");
MODULE_ALIAS("platform:gpio-omap");
MODULE_LICENSE("GPL v2");
...@@ -208,9 +208,17 @@ struct omap_gpio_platform_data { ...@@ -208,9 +208,17 @@ struct omap_gpio_platform_data {
int (*get_context_loss_count)(struct device *dev); int (*get_context_loss_count)(struct device *dev);
}; };
#if IS_BUILTIN(CONFIG_GPIO_OMAP)
extern void omap2_gpio_prepare_for_idle(int off_mode); extern void omap2_gpio_prepare_for_idle(int off_mode);
extern void omap2_gpio_resume_after_idle(void); extern void omap2_gpio_resume_after_idle(void);
extern void omap_set_gpio_debounce(int gpio, int enable); #else
extern void omap_set_gpio_debounce_time(int gpio, int enable); static inline void omap2_gpio_prepare_for_idle(int off_mode)
{
}
static inline void omap2_gpio_resume_after_idle(void)
{
}
#endif
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment