aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-cmos.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-cmos.c')
-rw-r--r--drivers/rtc/rtc-cmos.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index 6cf8e282338f..b6d35f50e404 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -35,6 +35,7 @@
35#include <linux/spinlock.h> 35#include <linux/spinlock.h>
36#include <linux/platform_device.h> 36#include <linux/platform_device.h>
37#include <linux/mod_devicetable.h> 37#include <linux/mod_devicetable.h>
38#include <linux/log2.h>
38 39
39/* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ 40/* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */
40#include <asm-generic/rtc.h> 41#include <asm-generic/rtc.h>
@@ -58,7 +59,7 @@ struct cmos_rtc {
58}; 59};
59 60
60/* both platform and pnp busses use negative numbers for invalid irqs */ 61/* both platform and pnp busses use negative numbers for invalid irqs */
61#define is_valid_irq(n) ((n) >= 0) 62#define is_valid_irq(n) ((n) > 0)
62 63
63static const char driver_name[] = "rtc_cmos"; 64static const char driver_name[] = "rtc_cmos";
64 65
@@ -384,6 +385,8 @@ static int cmos_irq_set_freq(struct device *dev, int freq)
384 if (!is_valid_irq(cmos->irq)) 385 if (!is_valid_irq(cmos->irq))
385 return -ENXIO; 386 return -ENXIO;
386 387
388 if (!is_power_of_2(freq))
389 return -EINVAL;
387 /* 0 = no irqs; 1 = 2^15 Hz ... 15 = 2^0 Hz */ 390 /* 0 = no irqs; 1 = 2^15 Hz ... 15 = 2^0 Hz */
388 f = ffs(freq); 391 f = ffs(freq);
389 if (f-- > 16) 392 if (f-- > 16)
@@ -729,7 +732,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
729 732
730 cmos_rtc.dev = dev; 733 cmos_rtc.dev = dev;
731 dev_set_drvdata(dev, &cmos_rtc); 734 dev_set_drvdata(dev, &cmos_rtc);
732 rename_region(ports, cmos_rtc.rtc->dev.bus_id); 735 rename_region(ports, dev_name(&cmos_rtc.rtc->dev));
733 736
734 spin_lock_irq(&rtc_lock); 737 spin_lock_irq(&rtc_lock);
735 738
@@ -777,7 +780,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
777 rtc_cmos_int_handler = cmos_interrupt; 780 rtc_cmos_int_handler = cmos_interrupt;
778 781
779 retval = request_irq(rtc_irq, rtc_cmos_int_handler, 782 retval = request_irq(rtc_irq, rtc_cmos_int_handler,
780 IRQF_DISABLED, cmos_rtc.rtc->dev.bus_id, 783 IRQF_DISABLED, dev_name(&cmos_rtc.rtc->dev),
781 cmos_rtc.rtc); 784 cmos_rtc.rtc);
782 if (retval < 0) { 785 if (retval < 0) {
783 dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq); 786 dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
@@ -795,7 +798,7 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
795 } 798 }
796 799
797 pr_info("%s: alarms up to one %s%s, %zd bytes nvram%s\n", 800 pr_info("%s: alarms up to one %s%s, %zd bytes nvram%s\n",
798 cmos_rtc.rtc->dev.bus_id, 801 dev_name(&cmos_rtc.rtc->dev),
799 is_valid_irq(rtc_irq) 802 is_valid_irq(rtc_irq)
800 ? (cmos_rtc.mon_alrm 803 ? (cmos_rtc.mon_alrm
801 ? "year" 804 ? "year"
@@ -885,7 +888,7 @@ static int cmos_suspend(struct device *dev, pm_message_t mesg)
885 } 888 }
886 889
887 pr_debug("%s: suspend%s, ctrl %02x\n", 890 pr_debug("%s: suspend%s, ctrl %02x\n",
888 cmos_rtc.rtc->dev.bus_id, 891 dev_name(&cmos_rtc.rtc->dev),
889 (tmp & RTC_AIE) ? ", alarm may wake" : "", 892 (tmp & RTC_AIE) ? ", alarm may wake" : "",
890 tmp); 893 tmp);
891 894
@@ -941,7 +944,7 @@ static int cmos_resume(struct device *dev)
941 } 944 }
942 945
943 pr_debug("%s: resume, ctrl %02x\n", 946 pr_debug("%s: resume, ctrl %02x\n",
944 cmos_rtc.rtc->dev.bus_id, 947 dev_name(&cmos_rtc.rtc->dev),
945 tmp); 948 tmp);
946 949
947 return 0; 950 return 0;