From: Jagadeesh Bhaskar Pakaravoor <j-pakaravoor@xxxxxx> rtc_irq_set_freq() function takes only powers of 2 as a valid argument. This stipulates that an ioctl call on /dev/rtc0 can accept values of 1,2,4 and 8 only. But the function twl4030_rtc_irq_set_freq() takes only values 0-3. RTC_INTERRUPTS_REG of TWL4030 also requires value in the range 0-3 for the interrupt period. Hence it is required to map the argument from the powers of 2, to the corresponding numbers 0-3, via a call to ilog2. Signed-off-by: Jagadeesh Bhaskar Pakaravoor <j-pakaravoor@xxxxxx> --- Fixing a bug in the last patch: argument to set_rtc_irq_bit() function should have been "value" instead of "freq". Index: my-local-git-dir/drivers/rtc/rtc-twl4030.c =================================================================== --- my-local-git-dir.orig/drivers/rtc/rtc-twl4030.c 2008-08-22 17:37:33.000000000 +0530 +++ my-local-git-dir/drivers/rtc/rtc-twl4030.c 2008-08-22 19:25:41.616786397 +0530 @@ -38,6 +38,7 @@ #include <linux/i2c/twl4030-rtc.h> #include <linux/io.h> #include <linux/irq.h> +#include <linux/log2.h> #include <asm/mach/time.h> #include <asm/system.h> @@ -363,14 +364,26 @@ out: static int twl4030_rtc_irq_set_freq(struct device *dev, int freq) { struct rtc_device *rtc = dev_get_drvdata(dev); + u8 value; - if (freq < 0 || freq > 3) + /* RTC_INTERRUPTS_REG takes the value of 0 for interrupts every + * second, 1 for every minute, 2 every hour and 3 every day. + * But freq is in 2^N format, which needs to be converted back. + */ + value = ilog2(freq); + if (value < 0 || value > 3) return -EINVAL; - rtc->irq_freq = freq; + rtc->irq_freq = value; + + /* Clear the current periodicity of irq*/ + mask_rtc_irq_bit(0x3); - /* set rtc irq freq to user defined value */ - set_rtc_irq_bit(freq); + /* If the new value is non-zero, set the new periodicity */ + if (value) { + /* set rtc irq freq to user defined value */ + set_rtc_irq_bit(value); + } return 0; } -- With Regards, Jagadeesh Bhaskar P ---------------------------- Some men see things as they are and say why - I dream things that never were and say why not. - George Bernard Shaw ------------------- -- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html