rtc: mark if rtc-cmos drivers were successfully registered

rtc-cmos has two drivers, one PNP and one platform.  When PNP has not
succeeded probing, platform is registered.  However, it tries to
unregister both drivers unconditionally, instead of only unregistering
those that were successfully registered.  This causes runtime warnings to
be emitted from the driver core code.

Fix this with a boolean variable for each driver indicating whether
registering was successful.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Cc: David Brownell <david-b@pacbell.net>
Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
Cc: Alessandro Zummo <alessandro.zummo@towertech.it>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: David Brownell <david-b@pacbell.net>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Greg KH <greg@kroah.com>
Cc: Ozan Caglayan <ozan@pardus.org.tr>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Thadeu Lima de Souza Cascardo 2009-07-29 15:02:13 -07:00 committed by Linus Torvalds
parent 57c5c28dbc
commit 659098141d
1 changed files with 18 additions and 5 deletions

View File

@ -1174,22 +1174,33 @@ static struct platform_driver cmos_platform_driver = {
} }
}; };
#ifdef CONFIG_PNP
static bool pnp_driver_registered;
#endif
static bool platform_driver_registered;
static int __init cmos_init(void) static int __init cmos_init(void)
{ {
int retval = 0; int retval = 0;
#ifdef CONFIG_PNP #ifdef CONFIG_PNP
pnp_register_driver(&cmos_pnp_driver); retval = pnp_register_driver(&cmos_pnp_driver);
if (retval == 0)
pnp_driver_registered = true;
#endif #endif
if (!cmos_rtc.dev) if (!cmos_rtc.dev) {
retval = platform_driver_probe(&cmos_platform_driver, retval = platform_driver_probe(&cmos_platform_driver,
cmos_platform_probe); cmos_platform_probe);
if (retval == 0)
platform_driver_registered = true;
}
if (retval == 0) if (retval == 0)
return 0; return 0;
#ifdef CONFIG_PNP #ifdef CONFIG_PNP
if (pnp_driver_registered)
pnp_unregister_driver(&cmos_pnp_driver); pnp_unregister_driver(&cmos_pnp_driver);
#endif #endif
return retval; return retval;
@ -1199,8 +1210,10 @@ module_init(cmos_init);
static void __exit cmos_exit(void) static void __exit cmos_exit(void)
{ {
#ifdef CONFIG_PNP #ifdef CONFIG_PNP
if (pnp_driver_registered)
pnp_unregister_driver(&cmos_pnp_driver); pnp_unregister_driver(&cmos_pnp_driver);
#endif #endif
if (platform_driver_registered)
platform_driver_unregister(&cmos_platform_driver); platform_driver_unregister(&cmos_platform_driver);
} }
module_exit(cmos_exit); module_exit(cmos_exit);