Re: [PATCH 2/2] rtc: rtc-wm8350: Add support for WM8350 RTC

From: Andrew Morton
Date: Mon Oct 27 2008 - 01:15:29 EST


On Mon, 20 Oct 2008 20:35:18 +0100 Mark Brown <broonie@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

> +static int wm8350_rtc_stop_alarm(struct wm8350 *wm8350)
> +{
> + int retries = WM8350_SET_ALM_RETRIES;
> + u16 rtc_ctrl;
> + int ret;
> +
> + /* Set RTC_SET to stop the clock */
> + ret = wm8350_set_bits(wm8350, WM8350_RTC_TIME_CONTROL,
> + WM8350_RTC_ALMSET);
> + if (ret < 0)
> + return ret;
> +
> + /* Wait until confirmation of stopping */
> + do {
> + rtc_ctrl = wm8350_reg_read(wm8350, WM8350_RTC_TIME_CONTROL);
> + schedule_timeout_interruptible(msecs_to_jiffies(1));

If the calling process has signal_pending() (eg: someone typed ^C) then
schedule_timeout_interruptible() will return immediately.

> + } while (retries-- && !(rtc_ctrl & WM8350_RTC_ALMSTS));
> +
> + if (!(rtc_ctrl & WM8350_RTC_ALMSTS))
> + return -ETIMEDOUT;

And the driver will incorrectly return -ETIMEDOUT.

> + return 0;
> +}
> +
> +static int wm8350_rtc_start_alarm(struct wm8350 *wm8350)
> +{
> + int ret;
> + int retries = WM8350_SET_ALM_RETRIES;
> + u16 rtc_ctrl;
> +
> + ret = wm8350_clear_bits(wm8350, WM8350_RTC_TIME_CONTROL,
> + WM8350_RTC_ALMSET);
> + if (ret < 0)
> + return ret;
> +
> + /* Wait until confirmation */
> + do {
> + rtc_ctrl = wm8350_reg_read(wm8350, WM8350_RTC_TIME_CONTROL);
> + schedule_timeout_interruptible(msecs_to_jiffies(1));
> + } while (retries-- && rtc_ctrl & WM8350_RTC_ALMSTS);
> +
> + if (rtc_ctrl & WM8350_RTC_ALMSTS)
> + return -ETIMEDOUT;

ditto.

> + return 0;
> +}

I'll switch those to schedule_timeout_uninterruptible(), OK?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/