rtc: move power of 2 periodic frequency check down into drivers
authorJonathan Cameron <jic23@cam.ac.uk>
Tue, 6 Jan 2009 22:42:12 +0000 (14:42 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 6 Jan 2009 23:59:24 +0000 (15:59 -0800)
Move the power of 2 check on frequencies down into individual rtc drivers

This is to allow for non power of 2 real time clock periodic interrupts
such as those on the pxa27x to be found in the new pxa27x-rtc driver

Signed-off-by: Jonathan Cameron <jic23@cam.ac.uk>
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/rtc/interface.c
drivers/rtc/rtc-cmos.c
drivers/rtc/rtc-s3c.c
drivers/rtc/rtc-sh.c
drivers/rtc/rtc-vr41xx.c

index 43276f29d63610db4984cf24bdc006b7cbc2f57b..50482d1321e8130e96d0bac111e14b1b107bcba9 100644 (file)
@@ -504,9 +504,6 @@ int rtc_irq_set_freq(struct rtc_device *rtc, struct rtc_task *task, int freq)
        if (rtc->ops->irq_set_freq == NULL)
                return -ENXIO;
 
-       if (!is_power_of_2(freq))
-               return -EINVAL;
-
        spin_lock_irqsave(&rtc->irq_task_lock, flags);
        if (rtc->irq_task != NULL && task == NULL)
                err = -EBUSY;
index cf98a5d8358e156dc078945d043b44abac4c8d0b..b6d35f50e40488141debded78ca4d5992f78288a 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/spinlock.h>
 #include <linux/platform_device.h>
 #include <linux/mod_devicetable.h>
+#include <linux/log2.h>
 
 /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */
 #include <asm-generic/rtc.h>
@@ -384,6 +385,8 @@ static int cmos_irq_set_freq(struct device *dev, int freq)
        if (!is_valid_irq(cmos->irq))
                return -ENXIO;
 
+       if (!is_power_of_2(freq))
+               return -EINVAL;
        /* 0 = no irqs; 1 = 2^15 Hz ... 15 = 2^0 Hz */
        f = ffs(freq);
        if (f-- > 16)
index 7a568beba3f00b95f483664b03d888fc76059877..e0d7b9991505564c412e4771f8061154c5adc449 100644 (file)
@@ -94,6 +94,9 @@ static int s3c_rtc_setfreq(struct device *dev, int freq)
 {
        unsigned int tmp;
 
+       if (!is_power_of_2(freq))
+               return -EINVAL;
+
        spin_lock_irq(&s3c_rtc_pie_lock);
 
        tmp = readb(s3c_rtc_base + S3C2410_TICNT) & S3C2410_TICNT_ENABLE;
index 5ed66acf8ca5113da9a743f54d53b88644a7ab97..1c3fc6b428e9a705c8b711053401e859f52bca6d 100644 (file)
@@ -24,6 +24,7 @@
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
 #include <linux/io.h>
+#include <linux/log2.h>
 #include <asm/rtc.h>
 
 #define DRV_NAME       "sh-rtc"
@@ -551,6 +552,8 @@ static int sh_rtc_irq_set_state(struct device *dev, int enabled)
 
 static int sh_rtc_irq_set_freq(struct device *dev, int freq)
 {
+       if (!is_power_of_2(freq))
+               return -EINVAL;
        return sh_rtc_ioctl(dev, RTC_IRQP_SET, freq);
 }
 
index 57b7aac092a39bccba15bc2578ad83773f520c5e..f11297aff854a3bf680d84c382581083e853df5d 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/rtc.h>
 #include <linux/spinlock.h>
 #include <linux/types.h>
+#include <linux/log2.h>
 
 #include <asm/div64.h>
 #include <asm/io.h>
@@ -210,6 +211,8 @@ static int vr41xx_rtc_irq_set_freq(struct device *dev, int freq)
 {
        unsigned long count;
 
+       if (!is_power_of_2(freq))
+               return -EINVAL;
        count = RTC_FREQUENCY;
        do_div(count, freq);