aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-stk17ta8.c
diff options
context:
space:
mode:
authorAnton Vorontsov <avorontsov@ru.mvista.com>2009-01-06 17:42:11 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-06 18:59:23 -0500
commit2fac6674ddf3164da42a76d62f8912073d629a30 (patch)
treeffc7b69bbbe065ebe1e75be601c866467252f550 /drivers/rtc/rtc-stk17ta8.c
parentd4afc76c0b59a37113e184004f8a9989cfc1ddd3 (diff)
rtc: bunch of drivers: fix 'no irq' case handing
This patch fixes a bunch of irq checking misuses. Most drivers were getting irq via platform_get_irq(), which returns -ENXIO or r->start. rtc-cmos.c is special. It is using PNP and platform bindings. Hopefully nobody is using PNP IRQ 0 for RTC. So the changes should be safe. rtc-sh.c is using platform_get_irq, but was storing a result into an unsigned type, then was checking for < 0. This is fixed now. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Cc: Alessandro Zummo <a.zummo@towertech.it> Acked-by: David Brownell <dbrownell@users.sourceforge.net> Acked-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-stk17ta8.c')
-rw-r--r--drivers/rtc/rtc-stk17ta8.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-stk17ta8.c b/drivers/rtc/rtc-stk17ta8.c
index f4cd46e15af9..dc0b6224ad9b 100644
--- a/drivers/rtc/rtc-stk17ta8.c
+++ b/drivers/rtc/rtc-stk17ta8.c
@@ -170,7 +170,7 @@ static int stk17ta8_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)
170 struct platform_device *pdev = to_platform_device(dev); 170 struct platform_device *pdev = to_platform_device(dev);
171 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 171 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
172 172
173 if (pdata->irq < 0) 173 if (pdata->irq <= 0)
174 return -EINVAL; 174 return -EINVAL;
175 pdata->alrm_mday = alrm->time.tm_mday; 175 pdata->alrm_mday = alrm->time.tm_mday;
176 pdata->alrm_hour = alrm->time.tm_hour; 176 pdata->alrm_hour = alrm->time.tm_hour;
@@ -187,7 +187,7 @@ static int stk17ta8_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
187 struct platform_device *pdev = to_platform_device(dev); 187 struct platform_device *pdev = to_platform_device(dev);
188 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 188 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
189 189
190 if (pdata->irq < 0) 190 if (pdata->irq <= 0)
191 return -EINVAL; 191 return -EINVAL;
192 alrm->time.tm_mday = pdata->alrm_mday < 0 ? 0 : pdata->alrm_mday; 192 alrm->time.tm_mday = pdata->alrm_mday < 0 ? 0 : pdata->alrm_mday;
193 alrm->time.tm_hour = pdata->alrm_hour < 0 ? 0 : pdata->alrm_hour; 193 alrm->time.tm_hour = pdata->alrm_hour < 0 ? 0 : pdata->alrm_hour;
@@ -221,7 +221,7 @@ static int stk17ta8_rtc_ioctl(struct device *dev, unsigned int cmd,
221 struct platform_device *pdev = to_platform_device(dev); 221 struct platform_device *pdev = to_platform_device(dev);
222 struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 222 struct rtc_plat_data *pdata = platform_get_drvdata(pdev);
223 223
224 if (pdata->irq < 0) 224 if (pdata->irq <= 0)
225 return -ENOIOCTLCMD; /* fall back into rtc-dev's emulation */ 225 return -ENOIOCTLCMD; /* fall back into rtc-dev's emulation */
226 switch (cmd) { 226 switch (cmd) {
227 case RTC_AIE_OFF: 227 case RTC_AIE_OFF:
@@ -303,7 +303,6 @@ static int __init stk17ta8_rtc_probe(struct platform_device *pdev)
303 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); 303 pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
304 if (!pdata) 304 if (!pdata)
305 return -ENOMEM; 305 return -ENOMEM;
306 pdata->irq = -1;
307 if (!request_mem_region(res->start, RTC_REG_SIZE, pdev->name)) { 306 if (!request_mem_region(res->start, RTC_REG_SIZE, pdev->name)) {
308 ret = -EBUSY; 307 ret = -EBUSY;
309 goto out; 308 goto out;
@@ -329,13 +328,13 @@ static int __init stk17ta8_rtc_probe(struct platform_device *pdev)
329 if (readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_PF) 328 if (readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_PF)
330 dev_warn(&pdev->dev, "voltage-low detected.\n"); 329 dev_warn(&pdev->dev, "voltage-low detected.\n");
331 330
332 if (pdata->irq >= 0) { 331 if (pdata->irq > 0) {
333 writeb(0, ioaddr + RTC_INTERRUPTS); 332 writeb(0, ioaddr + RTC_INTERRUPTS);
334 if (request_irq(pdata->irq, stk17ta8_rtc_interrupt, 333 if (request_irq(pdata->irq, stk17ta8_rtc_interrupt,
335 IRQF_DISABLED | IRQF_SHARED, 334 IRQF_DISABLED | IRQF_SHARED,
336 pdev->name, pdev) < 0) { 335 pdev->name, pdev) < 0) {
337 dev_warn(&pdev->dev, "interrupt not available.\n"); 336 dev_warn(&pdev->dev, "interrupt not available.\n");
338 pdata->irq = -1; 337 pdata->irq = 0;
339 } 338 }
340 } 339 }
341 340
@@ -355,7 +354,7 @@ static int __init stk17ta8_rtc_probe(struct platform_device *pdev)
355 out: 354 out:
356 if (pdata->rtc) 355 if (pdata->rtc)
357 rtc_device_unregister(pdata->rtc); 356 rtc_device_unregister(pdata->rtc);
358 if (pdata->irq >= 0) 357 if (pdata->irq > 0)
359 free_irq(pdata->irq, pdev); 358 free_irq(pdata->irq, pdev);
360 if (ioaddr) 359 if (ioaddr)
361 iounmap(ioaddr); 360 iounmap(ioaddr);
@@ -371,7 +370,7 @@ static int __devexit stk17ta8_rtc_remove(struct platform_device *pdev)
371 370
372 sysfs_remove_bin_file(&pdev->dev.kobj, &stk17ta8_nvram_attr); 371 sysfs_remove_bin_file(&pdev->dev.kobj, &stk17ta8_nvram_attr);
373 rtc_device_unregister(pdata->rtc); 372 rtc_device_unregister(pdata->rtc);
374 if (pdata->irq >= 0) { 373 if (pdata->irq > 0) {
375 writeb(0, pdata->ioaddr + RTC_INTERRUPTS); 374 writeb(0, pdata->ioaddr + RTC_INTERRUPTS);
376 free_irq(pdata->irq, pdev); 375 free_irq(pdata->irq, pdev);
377 } 376 }