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.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index 5d760bb6c2cd..6d0c35397b49 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -246,11 +246,9 @@ static int cmos_irq_set_freq(struct device *dev, int freq)
246 246
247 /* 0 = no irqs; 1 = 2^15 Hz ... 15 = 2^0 Hz */ 247 /* 0 = no irqs; 1 = 2^15 Hz ... 15 = 2^0 Hz */
248 f = ffs(freq); 248 f = ffs(freq);
249 if (f != 0) { 249 if (f-- > 16)
250 if (f-- > 16 || freq != (1 << f)) 250 return -EINVAL;
251 return -EINVAL; 251 f = 16 - f;
252 f = 16 - f;
253 }
254 252
255 spin_lock_irqsave(&rtc_lock, flags); 253 spin_lock_irqsave(&rtc_lock, flags);
256 CMOS_WRITE(RTC_REF_CLCK_32KHZ | f, RTC_FREQ_SELECT); 254 CMOS_WRITE(RTC_REF_CLCK_32KHZ | f, RTC_FREQ_SELECT);