Commit 5d2a50371ddf127afa782ad3147469be8e9bd69f

Authored by Jonathan Cameron
Committed by Linus Torvalds
1 parent 2fac6674dd

rtc: move power of 2 periodic frequency check down into drivers

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>

Showing 5 changed files with 12 additions and 3 deletions Side-by-side Diff

drivers/rtc/interface.c
... ... @@ -504,9 +504,6 @@
504 504 if (rtc->ops->irq_set_freq == NULL)
505 505 return -ENXIO;
506 506  
507   - if (!is_power_of_2(freq))
508   - return -EINVAL;
509   -
510 507 spin_lock_irqsave(&rtc->irq_task_lock, flags);
511 508 if (rtc->irq_task != NULL && task == NULL)
512 509 err = -EBUSY;
drivers/rtc/rtc-cmos.c
... ... @@ -35,6 +35,7 @@
35 35 #include <linux/spinlock.h>
36 36 #include <linux/platform_device.h>
37 37 #include <linux/mod_devicetable.h>
  38 +#include <linux/log2.h>
38 39  
39 40 /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */
40 41 #include <asm-generic/rtc.h>
... ... @@ -384,6 +385,8 @@
384 385 if (!is_valid_irq(cmos->irq))
385 386 return -ENXIO;
386 387  
  388 + if (!is_power_of_2(freq))
  389 + return -EINVAL;
387 390 /* 0 = no irqs; 1 = 2^15 Hz ... 15 = 2^0 Hz */
388 391 f = ffs(freq);
389 392 if (f-- > 16)
drivers/rtc/rtc-s3c.c
... ... @@ -94,6 +94,9 @@
94 94 {
95 95 unsigned int tmp;
96 96  
  97 + if (!is_power_of_2(freq))
  98 + return -EINVAL;
  99 +
97 100 spin_lock_irq(&s3c_rtc_pie_lock);
98 101  
99 102 tmp = readb(s3c_rtc_base + S3C2410_TICNT) & S3C2410_TICNT_ENABLE;
drivers/rtc/rtc-sh.c
... ... @@ -24,6 +24,7 @@
24 24 #include <linux/interrupt.h>
25 25 #include <linux/spinlock.h>
26 26 #include <linux/io.h>
  27 +#include <linux/log2.h>
27 28 #include <asm/rtc.h>
28 29  
29 30 #define DRV_NAME "sh-rtc"
... ... @@ -551,6 +552,8 @@
551 552  
552 553 static int sh_rtc_irq_set_freq(struct device *dev, int freq)
553 554 {
  555 + if (!is_power_of_2(freq))
  556 + return -EINVAL;
554 557 return sh_rtc_ioctl(dev, RTC_IRQP_SET, freq);
555 558 }
556 559  
drivers/rtc/rtc-vr41xx.c
... ... @@ -27,6 +27,7 @@
27 27 #include <linux/rtc.h>
28 28 #include <linux/spinlock.h>
29 29 #include <linux/types.h>
  30 +#include <linux/log2.h>
30 31  
31 32 #include <asm/div64.h>
32 33 #include <asm/io.h>
... ... @@ -210,6 +211,8 @@
210 211 {
211 212 unsigned long count;
212 213  
  214 + if (!is_power_of_2(freq))
  215 + return -EINVAL;
213 216 count = RTC_FREQUENCY;
214 217 do_div(count, freq);
215 218