aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-twl.c
diff options
context:
space:
mode:
authorVenu Byravarasu <vbyravarasu@nvidia.com>2012-03-23 18:02:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-23 19:58:39 -0400
commitce9f650636d310e4c8febc821b0038e9918a12db (patch)
tree3165a949b121068c6c62b42bb9c77f20cb53f5e4 /drivers/rtc/rtc-twl.c
parentb4f0b880c8d7eb225b79dec663780b4dcdea7fbc (diff)
drivers/rtc/rtc-twl.c: optimize IRQ bit access
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>
Diffstat (limited to 'drivers/rtc/rtc-twl.c')
-rw-r--r--drivers/rtc/rtc-twl.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index d43b4f6eb4e4..18dff5255670 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -176,6 +176,10 @@ static int set_rtc_irq_bit(unsigned char bit)
176 unsigned char val; 176 unsigned char val;
177 int ret; 177 int ret;
178 178
179 /* if the bit is set, return from here */
180 if (rtc_irq_bits & bit)
181 return 0;
182
179 val = rtc_irq_bits | bit; 183 val = rtc_irq_bits | bit;
180 val &= ~BIT_RTC_INTERRUPTS_REG_EVERY_M; 184 val &= ~BIT_RTC_INTERRUPTS_REG_EVERY_M;
181 ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG); 185 ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG);
@@ -193,6 +197,10 @@ static int mask_rtc_irq_bit(unsigned char bit)
193 unsigned char val; 197 unsigned char val;
194 int ret; 198 int ret;
195 199
200 /* if the bit is clear, return from here */
201 if (!(rtc_irq_bits & bit))
202 return 0;
203
196 val = rtc_irq_bits & ~bit; 204 val = rtc_irq_bits & ~bit;
197 ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG); 205 ret = twl_rtc_write_u8(val, REG_RTC_INTERRUPTS_REG);
198 if (ret == 0) 206 if (ret == 0)