drivers/rtc/rtc-twl.c: optimize IRQ bit access
authorVenu Byravarasu <vbyravarasu@nvidia.com>
Fri, 23 Mar 2012 22:02:32 +0000 (15:02 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 23 Mar 2012 23:58:39 +0000 (16:58 -0700)
As the TWL RTC driver has a cached copy of enabled RTC interrupt bits in
variable rtc_irq_bits, that can be checked before really setting or
masking any of the interrupt bits.

Signed-off-by: Venu Byravarasu <vbyravarasu@nvidia.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/rtc/rtc-twl.c

index d43b4f6eb4e420c79327566e3444351cf86c8185..18dff5255670ee77d0ab93881aa94e21d1203161 100644 (file)
@@ -176,6 +176,10 @@ static int set_rtc_irq_bit(unsigned char bit)
        unsigned char val;
        int ret;
 
+       /* if the bit is set, return from here */
+       if (rtc_irq_bits & bit)
+               return 0;
+
        val = rtc_irq_bits | bit;
        val &= ~BIT_RTC_INTERRUPTS_REG_EVERY_M;
        ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG);
@@ -193,6 +197,10 @@ static int mask_rtc_irq_bit(unsigned char bit)
        unsigned char val;
        int ret;
 
+       /* if the bit is clear, return from here */
+       if (!(rtc_irq_bits & bit))
+               return 0;
+
        val = rtc_irq_bits & ~bit;
        ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG);
        if (ret == 0)