diff options
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rtc-cmos.c | 23 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1374.c | 4 |
2 files changed, 20 insertions, 7 deletions
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index 23e10b6263d6..f7a4701bf863 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c | |||
@@ -1174,23 +1174,34 @@ static struct platform_driver cmos_platform_driver = { | |||
1174 | } | 1174 | } |
1175 | }; | 1175 | }; |
1176 | 1176 | ||
1177 | #ifdef CONFIG_PNP | ||
1178 | static bool pnp_driver_registered; | ||
1179 | #endif | ||
1180 | static bool platform_driver_registered; | ||
1181 | |||
1177 | static int __init cmos_init(void) | 1182 | static int __init cmos_init(void) |
1178 | { | 1183 | { |
1179 | int retval = 0; | 1184 | int retval = 0; |
1180 | 1185 | ||
1181 | #ifdef CONFIG_PNP | 1186 | #ifdef CONFIG_PNP |
1182 | pnp_register_driver(&cmos_pnp_driver); | 1187 | retval = pnp_register_driver(&cmos_pnp_driver); |
1188 | if (retval == 0) | ||
1189 | pnp_driver_registered = true; | ||
1183 | #endif | 1190 | #endif |
1184 | 1191 | ||
1185 | if (!cmos_rtc.dev) | 1192 | if (!cmos_rtc.dev) { |
1186 | retval = platform_driver_probe(&cmos_platform_driver, | 1193 | retval = platform_driver_probe(&cmos_platform_driver, |
1187 | cmos_platform_probe); | 1194 | cmos_platform_probe); |
1195 | if (retval == 0) | ||
1196 | platform_driver_registered = true; | ||
1197 | } | ||
1188 | 1198 | ||
1189 | if (retval == 0) | 1199 | if (retval == 0) |
1190 | return 0; | 1200 | return 0; |
1191 | 1201 | ||
1192 | #ifdef CONFIG_PNP | 1202 | #ifdef CONFIG_PNP |
1193 | pnp_unregister_driver(&cmos_pnp_driver); | 1203 | if (pnp_driver_registered) |
1204 | pnp_unregister_driver(&cmos_pnp_driver); | ||
1194 | #endif | 1205 | #endif |
1195 | return retval; | 1206 | return retval; |
1196 | } | 1207 | } |
@@ -1199,9 +1210,11 @@ module_init(cmos_init); | |||
1199 | static void __exit cmos_exit(void) | 1210 | static void __exit cmos_exit(void) |
1200 | { | 1211 | { |
1201 | #ifdef CONFIG_PNP | 1212 | #ifdef CONFIG_PNP |
1202 | pnp_unregister_driver(&cmos_pnp_driver); | 1213 | if (pnp_driver_registered) |
1214 | pnp_unregister_driver(&cmos_pnp_driver); | ||
1203 | #endif | 1215 | #endif |
1204 | platform_driver_unregister(&cmos_platform_driver); | 1216 | if (platform_driver_registered) |
1217 | platform_driver_unregister(&cmos_platform_driver); | ||
1205 | } | 1218 | } |
1206 | module_exit(cmos_exit); | 1219 | module_exit(cmos_exit); |
1207 | 1220 | ||
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c index 32b27739ec2a..713f7bf5afb3 100644 --- a/drivers/rtc/rtc-ds1374.c +++ b/drivers/rtc/rtc-ds1374.c | |||
@@ -283,7 +283,7 @@ static void ds1374_work(struct work_struct *work) | |||
283 | 283 | ||
284 | stat = i2c_smbus_read_byte_data(client, DS1374_REG_SR); | 284 | stat = i2c_smbus_read_byte_data(client, DS1374_REG_SR); |
285 | if (stat < 0) | 285 | if (stat < 0) |
286 | return; | 286 | goto unlock; |
287 | 287 | ||
288 | if (stat & DS1374_REG_SR_AF) { | 288 | if (stat & DS1374_REG_SR_AF) { |
289 | stat &= ~DS1374_REG_SR_AF; | 289 | stat &= ~DS1374_REG_SR_AF; |
@@ -302,7 +302,7 @@ static void ds1374_work(struct work_struct *work) | |||
302 | out: | 302 | out: |
303 | if (!ds1374->exiting) | 303 | if (!ds1374->exiting) |
304 | enable_irq(client->irq); | 304 | enable_irq(client->irq); |
305 | 305 | unlock: | |
306 | mutex_unlock(&ds1374->mutex); | 306 | mutex_unlock(&ds1374->mutex); |
307 | } | 307 | } |
308 | 308 | ||