lkml.org 
[lkml]   [2012]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] rtc: twl: optimize IRQ bit access
On Thu, 19 Jan 2012 17:22:22 +0530
Venu Byravarasu <vbyravarasu@nvidia.com> wrote:

> From: Venu Byravarasu <vbyravarasu@nvidia.com>
>
> As TWL RTC driver is having 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.
>
> ...
>
> --- 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)
> 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)

Are these functions called frequently enough to make this optimisation
significant?

I can see no locking protecting rtc_irq_bits from concurrent updaters.
Is this code as racy as it appears?




\
 
 \ /
  Last update: 2012-01-28 01:41    [W:1.156 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site