The patch titled Subject: drivers/rtc/rtc-isl12057.c: add proper handling of oscillator failure bit has been added to the -mm tree. Its filename is rtc-rtc-isl12057-add-proper-handling-of-oscillator-failure-bit.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/rtc-rtc-isl12057-add-proper-handling-of-oscillator-failure-bit.patch echo and later at echo http://ozlabs.org/~akpm/mmotm/broken-out/rtc-rtc-isl12057-add-proper-handling-of-oscillator-failure-bit.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Arnaud Ebalard <arno@xxxxxxxxxxxx> Subject: drivers/rtc/rtc-isl12057.c: add proper handling of oscillator failure bit As suggested by Uwe, instead of clearing oscillator failure bit unconditionally at driver load, this patch adds proper handling of the flag. The driver now returns -ENODATA when reading time from the device and oscillator failure bit is set. The flag is now cleared only when the a new time value is pushed to the device. Signed-off-by: Arnaud Ebalard <arno@xxxxxxxxxxxx> Reported-by: Uwe Kleine-König <uwe@xxxxxxxxxxxxxxxxx> Cc: Mark Rutland <mark.rutland@xxxxxxx> Cc: Alessandro Zummo <a.zummo@xxxxxxxxxxxx> Cc: Peter Huewe <peter.huewe@xxxxxxxxxxxx> Cc: Linus Walleij <linus.walleij@xxxxxxxxxx> Cc: Thierry Reding <treding@xxxxxxxxxx> Cc: Mark Brown <broonie@xxxxxxxxxx> Cc: Grant Likely <grant.likely@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- drivers/rtc/rtc-isl12057.c | 47 ++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 14 deletions(-) diff -puN drivers/rtc/rtc-isl12057.c~rtc-rtc-isl12057-add-proper-handling-of-oscillator-failure-bit drivers/rtc/rtc-isl12057.c --- a/drivers/rtc/rtc-isl12057.c~rtc-rtc-isl12057-add-proper-handling-of-oscillator-failure-bit +++ a/drivers/rtc/rtc-isl12057.c @@ -164,17 +164,32 @@ static int isl12057_rtc_read_time(struct { struct isl12057_rtc_data *data = dev_get_drvdata(dev); u8 regs[ISL12057_RTC_SEC_LEN]; + unsigned int sr; int ret; mutex_lock(&data->lock); + ret = regmap_read(data->regmap, ISL12057_REG_SR, &sr); + if (ret) { + dev_err(dev, "%s: unable to read oscillator status flag\n", + __func__); + goto out; + } else { + if (sr & ISL12057_REG_SR_OSF) { + ret = -ENODATA; + goto out; + } + } + ret = regmap_bulk_read(data->regmap, ISL12057_REG_RTC_SC, regs, ISL12057_RTC_SEC_LEN); + if (ret) + dev_err(dev, "%s: unable to read RTC time\n", __func__); + +out: mutex_unlock(&data->lock); - if (ret) { - dev_err(dev, "%s: RTC read failed\n", __func__); + if (ret) return ret; - } isl12057_rtc_regs_to_tm(tm, regs); @@ -194,10 +209,22 @@ static int isl12057_rtc_set_time(struct mutex_lock(&data->lock); ret = regmap_bulk_write(data->regmap, ISL12057_REG_RTC_SC, regs, ISL12057_RTC_SEC_LEN); - mutex_unlock(&data->lock); + if (ret) { + dev_err(dev, "%s: writing RTC time failed\n", __func__); + goto out; + } - if (ret) - dev_err(dev, "%s: RTC write failed\n", __func__); + /* + * Now that RTC time has been updated, let's clear oscillator + * failure flag, if needed. + */ + ret = regmap_update_bits(data->regmap, ISL12057_REG_SR, + ISL12057_REG_SR_OSF, 0); + if (ret < 0) + dev_err(dev, "Unable to clear oscillator failure bit\n"); + +out: + mutex_unlock(&data->lock); return ret; } @@ -219,14 +246,6 @@ static int isl12057_check_rtc_status(str return ret; } - /* Clear oscillator failure bit if needed */ - ret = regmap_update_bits(regmap, ISL12057_REG_SR, - ISL12057_REG_SR_OSF, 0); - if (ret < 0) { - dev_err(dev, "Unable to clear oscillator failure bit\n"); - return ret; - } - /* Clear alarm bit if needed */ ret = regmap_update_bits(regmap, ISL12057_REG_SR, ISL12057_REG_SR_A1F, 0); _ Patches currently in -mm which might be from arno@xxxxxxxxxxxx are rtc-rtc-isl12057-fix-masking-of-register-values.patch rtc-rtc-isl12057-add-support-for-century-bit.patch rtc-rtc-isl12057-add-proper-handling-of-oscillator-failure-bit.patch rtc-rtc-isl12057-fix-isil-vs-isl-naming-for-intersil.patch rtc-rtc-isl12057-report-error-code-upon-failure-in-dev_err-calls.patch rtc-rtc-isl12057-add-alarm-support-to-intersil-isl12057-rtc-driver.patch linux-next.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html