diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2009-01-06 17:42:11 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-01-06 18:59:23 -0500 |
commit | 2fac6674ddf3164da42a76d62f8912073d629a30 (patch) | |
tree | ffc7b69bbbe065ebe1e75be601c866467252f550 /drivers/rtc/rtc-ds1553.c | |
parent | d4afc76c0b59a37113e184004f8a9989cfc1ddd3 (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-ds1553.c')
-rw-r--r-- | drivers/rtc/rtc-ds1553.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c index b9475cd20210..38d472b63406 100644 --- a/drivers/rtc/rtc-ds1553.c +++ b/drivers/rtc/rtc-ds1553.c | |||
@@ -162,7 +162,7 @@ static int ds1553_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
162 | struct platform_device *pdev = to_platform_device(dev); | 162 | struct platform_device *pdev = to_platform_device(dev); |
163 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | 163 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); |
164 | 164 | ||
165 | if (pdata->irq < 0) | 165 | if (pdata->irq <= 0) |
166 | return -EINVAL; | 166 | return -EINVAL; |
167 | pdata->alrm_mday = alrm->time.tm_mday; | 167 | pdata->alrm_mday = alrm->time.tm_mday; |
168 | pdata->alrm_hour = alrm->time.tm_hour; | 168 | pdata->alrm_hour = alrm->time.tm_hour; |
@@ -179,7 +179,7 @@ static int ds1553_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
179 | struct platform_device *pdev = to_platform_device(dev); | 179 | struct platform_device *pdev = to_platform_device(dev); |
180 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | 180 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); |
181 | 181 | ||
182 | if (pdata->irq < 0) | 182 | if (pdata->irq <= 0) |
183 | return -EINVAL; | 183 | return -EINVAL; |
184 | alrm->time.tm_mday = pdata->alrm_mday < 0 ? 0 : pdata->alrm_mday; | 184 | alrm->time.tm_mday = pdata->alrm_mday < 0 ? 0 : pdata->alrm_mday; |
185 | alrm->time.tm_hour = pdata->alrm_hour < 0 ? 0 : pdata->alrm_hour; | 185 | alrm->time.tm_hour = pdata->alrm_hour < 0 ? 0 : pdata->alrm_hour; |
@@ -213,7 +213,7 @@ static int ds1553_rtc_ioctl(struct device *dev, unsigned int cmd, | |||
213 | struct platform_device *pdev = to_platform_device(dev); | 213 | struct platform_device *pdev = to_platform_device(dev); |
214 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | 214 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); |
215 | 215 | ||
216 | if (pdata->irq < 0) | 216 | if (pdata->irq <= 0) |
217 | return -ENOIOCTLCMD; /* fall back into rtc-dev's emulation */ | 217 | return -ENOIOCTLCMD; /* fall back into rtc-dev's emulation */ |
218 | switch (cmd) { | 218 | switch (cmd) { |
219 | case RTC_AIE_OFF: | 219 | case RTC_AIE_OFF: |
@@ -301,7 +301,6 @@ static int __devinit ds1553_rtc_probe(struct platform_device *pdev) | |||
301 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); | 301 | pdata = kzalloc(sizeof(*pdata), GFP_KERNEL); |
302 | if (!pdata) | 302 | if (!pdata) |
303 | return -ENOMEM; | 303 | return -ENOMEM; |
304 | pdata->irq = -1; | ||
305 | if (!request_mem_region(res->start, RTC_REG_SIZE, pdev->name)) { | 304 | if (!request_mem_region(res->start, RTC_REG_SIZE, pdev->name)) { |
306 | ret = -EBUSY; | 305 | ret = -EBUSY; |
307 | goto out; | 306 | goto out; |
@@ -327,13 +326,13 @@ static int __devinit ds1553_rtc_probe(struct platform_device *pdev) | |||
327 | if (readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_BLF) | 326 | if (readb(ioaddr + RTC_FLAGS) & RTC_FLAGS_BLF) |
328 | dev_warn(&pdev->dev, "voltage-low detected.\n"); | 327 | dev_warn(&pdev->dev, "voltage-low detected.\n"); |
329 | 328 | ||
330 | if (pdata->irq >= 0) { | 329 | if (pdata->irq > 0) { |
331 | writeb(0, ioaddr + RTC_INTERRUPTS); | 330 | writeb(0, ioaddr + RTC_INTERRUPTS); |
332 | if (request_irq(pdata->irq, ds1553_rtc_interrupt, | 331 | if (request_irq(pdata->irq, ds1553_rtc_interrupt, |
333 | IRQF_DISABLED | IRQF_SHARED, | 332 | IRQF_DISABLED | IRQF_SHARED, |
334 | pdev->name, pdev) < 0) { | 333 | pdev->name, pdev) < 0) { |
335 | dev_warn(&pdev->dev, "interrupt not available.\n"); | 334 | dev_warn(&pdev->dev, "interrupt not available.\n"); |
336 | pdata->irq = -1; | 335 | pdata->irq = 0; |
337 | } | 336 | } |
338 | } | 337 | } |
339 | 338 | ||
@@ -353,7 +352,7 @@ static int __devinit ds1553_rtc_probe(struct platform_device *pdev) | |||
353 | out: | 352 | out: |
354 | if (pdata->rtc) | 353 | if (pdata->rtc) |
355 | rtc_device_unregister(pdata->rtc); | 354 | rtc_device_unregister(pdata->rtc); |
356 | if (pdata->irq >= 0) | 355 | if (pdata->irq > 0) |
357 | free_irq(pdata->irq, pdev); | 356 | free_irq(pdata->irq, pdev); |
358 | if (ioaddr) | 357 | if (ioaddr) |
359 | iounmap(ioaddr); | 358 | iounmap(ioaddr); |
@@ -369,7 +368,7 @@ static int __devexit ds1553_rtc_remove(struct platform_device *pdev) | |||
369 | 368 | ||
370 | sysfs_remove_bin_file(&pdev->dev.kobj, &ds1553_nvram_attr); | 369 | sysfs_remove_bin_file(&pdev->dev.kobj, &ds1553_nvram_attr); |
371 | rtc_device_unregister(pdata->rtc); | 370 | rtc_device_unregister(pdata->rtc); |
372 | if (pdata->irq >= 0) { | 371 | if (pdata->irq > 0) { |
373 | writeb(0, pdata->ioaddr + RTC_INTERRUPTS); | 372 | writeb(0, pdata->ioaddr + RTC_INTERRUPTS); |
374 | free_irq(pdata->irq, pdev); | 373 | free_irq(pdata->irq, pdev); |
375 | } | 374 | } |