Commit b2bdc3e7 authored by Richard Purdie's avatar Richard Purdie

leds: Fix leds-gpio driver multiple module_init/exit usage

You can't have multiple module_init()/module_exit calls so resort to messy
ifdefs potentially pending some code refactoring.
Signed-off-by: default avatarRichard Purdie <rpurdie@linux.intel.com>
parent ac2dd0f1
...@@ -178,19 +178,6 @@ static struct platform_driver gpio_led_driver = { ...@@ -178,19 +178,6 @@ static struct platform_driver gpio_led_driver = {
}, },
}; };
static int __init gpio_led_init(void)
{
return platform_driver_register(&gpio_led_driver);
}
static void __exit gpio_led_exit(void)
{
platform_driver_unregister(&gpio_led_driver);
}
module_init(gpio_led_init);
module_exit(gpio_led_exit);
MODULE_ALIAS("platform:leds-gpio"); MODULE_ALIAS("platform:leds-gpio");
#endif /* CONFIG_LEDS_GPIO_PLATFORM */ #endif /* CONFIG_LEDS_GPIO_PLATFORM */
...@@ -283,19 +270,40 @@ static struct of_platform_driver of_gpio_leds_driver = { ...@@ -283,19 +270,40 @@ static struct of_platform_driver of_gpio_leds_driver = {
.probe = of_gpio_leds_probe, .probe = of_gpio_leds_probe,
.remove = __devexit_p(of_gpio_leds_remove), .remove = __devexit_p(of_gpio_leds_remove),
}; };
#endif
static int __init of_gpio_leds_init(void) static int __init gpio_led_init(void)
{ {
return of_register_platform_driver(&of_gpio_leds_driver); int ret;
#ifdef CONFIG_LEDS_GPIO_PLATFORM
ret = platform_driver_register(&gpio_led_driver);
if (ret)
return ret;
#endif
#ifdef CONFIG_LEDS_GPIO_OF
ret = of_register_platform_driver(&of_gpio_leds_driver);
#endif
#ifdef CONFIG_LEDS_GPIO_PLATFORM
if (ret)
platform_driver_unregister(&gpio_led_driver);
#endif
return ret;
} }
module_init(of_gpio_leds_init);
static void __exit of_gpio_leds_exit(void) static void __exit gpio_led_exit(void)
{ {
#ifdef CONFIG_LEDS_GPIO_PLATFORM
platform_driver_unregister(&gpio_led_driver);
#endif
#ifdef CONFIG_LEDS_GPIO_OF
of_unregister_platform_driver(&of_gpio_leds_driver); of_unregister_platform_driver(&of_gpio_leds_driver);
}
module_exit(of_gpio_leds_exit);
#endif #endif
}
module_init(gpio_led_init);
module_exit(gpio_led_exit);
MODULE_AUTHOR("Raphael Assenat <raph@8d.com>, Trent Piepho <tpiepho@freescale.com>"); MODULE_AUTHOR("Raphael Assenat <raph@8d.com>, Trent Piepho <tpiepho@freescale.com>");
MODULE_DESCRIPTION("GPIO LED driver"); MODULE_DESCRIPTION("GPIO LED driver");
......
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