• Nishanth Menon's avatar
    rtc: ds1307: Enable the mcp794xx alarm after programming time · e3edd671
    Nishanth Menon authored
    Alarm interrupt enable register is at offset 0x7, while the time
    registers for the alarm follow that. When we program Alarm interrupt
    enable prior to programming the time, it is possible that previous
    time value could be close or match at the time of alarm enable
    resulting in interrupt trigger which is unexpected (and does not match
    the time we expect it to trigger).
    
    To prevent this scenario from occuring, program the ALM0_EN bit only
    after the alarm time is appropriately programmed.
    
    Ofcourse, I2C programming is non-atomic, so there are loopholes where
    the interrupt wont trigger if the time requested is in the past at
    the time of programming the ALM0_EN bit. However, we will not have
    unexpected interrupts while the time is programmed after the interrupt
    are enabled.
    Signed-off-by: default avatarNishanth Menon <nm@ti.com>
    Reviewed-by: default avatarGrygorii Strashko <grygorii.strashko@linaro.org>
    Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
    e3edd671
rtc-ds1307.c 33.4 KB