mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tzung-Bi Shih <tzungbi@kernel.org>
To: Paul Louvel <paul.louvel@bootlin.com>
Cc: Wim Van Sebroeck <wim@linux-watchdog.org>,
	Guenter Roeck <linux@roeck-us.net>,
	linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Subject: Re: [PATCH v5 5/5] watchdog: w83627hf_wdt: Add minute mode counting
Date: Thu, 22 Oct 2026 15:09:49 +0000	[thread overview]
Message-ID: <atonPYaCken3EItA@google.com> (raw)
In-Reply-To: <20261020-w83627hf_wdt-improvements-v5-5-90b226684fc7@bootlin.com>

On Tue, Oct 20, 2026 at 10:11:58AM +0200, Paul Louvel wrote:
> @@ -258,21 +263,10 @@ static int w83627hf_init(struct watchdog_device *wdog, enum chips chip)
>  		break;
>  	}
>  
> -	t = superio_inb(data->sio->addr, data->reg->timeout);
> -	if (t != 0) {
> -		if (early_disable) {
> -			pr_warn("Stopping previously enabled watchdog until userland kicks in\n");
> -			superio_outb(data->sio->addr, data->reg->timeout, 0);
> -		} else {
> -			pr_info("Watchdog already running. Resetting timeout to %d sec\n",
> -				wdog->timeout);
> -			superio_outb(data->sio->addr, data->reg->timeout, wdog->timeout);
> -			set_bit(WDOG_HW_RUNNING, &wdog->status);
> -		}
> -	}
> +	data->early_timer_val = superio_inb(data->sio->addr, data->reg->timeout);

I failed to figure out why this block needs to move to probe().  It looks
equivalent to me while introducing a redundant `early_timer_val`.

>  	t = superio_inb(data->sio->addr, data->reg->control) &
> -	    ~(WDT_CTRL_MINUTE_MODE | WDT_CTRL_RISING_EDGE_KBD_RESET);
> +	    ~WDT_CTRL_RISING_EDGE_KBD_RESET;

Why this change?  Wouldn't wdt_set_time() overwrite WDT_CTRL_MINUTE_MODE
anyway?

> @@ -297,6 +292,15 @@ static int wdt_set_time(struct watchdog_device *wdog, unsigned int timeout)
>  		return ret;
>  
>  	superio_select(data->sio->addr, W83627HF_LD_WDT);
> +
> +	ctrl = superio_inb(data->sio->addr, data->reg->control);
> +
> +	if (data->minute_mode)
> +		ctrl |= WDT_CTRL_MINUTE_MODE;
> +	else
> +		ctrl &= ~WDT_CTRL_MINUTE_MODE;
> +
> +	superio_outb(data->sio->addr, data->reg->control, ctrl);

It doesn't need to set `data->reg->control` if `!timeout`.

> @@ -305,7 +309,9 @@ static int wdt_set_time(struct watchdog_device *wdog, unsigned int timeout)
>  
>  static int wdt_start(struct watchdog_device *wdog)
>  {
> -	return wdt_set_time(wdog, wdog->timeout);
> +	struct w83627hf_data *data = watchdog_get_drvdata(wdog);
> +
> +	return wdt_set_time(wdog, data->timer_val);
>  }
>  
>  static int wdt_stop(struct watchdog_device *wdog)
> @@ -315,6 +321,17 @@ static int wdt_stop(struct watchdog_device *wdog)
>  
>  static int wdt_set_timeout(struct watchdog_device *wdog, unsigned int timeout)
>  {
> +	struct w83627hf_data *data = watchdog_get_drvdata(wdog);
> +
> +	if (timeout > 255) {
> +		data->minute_mode = true;
> +		data->timer_val = DIV_ROUND_UP(timeout, 60);
> +		timeout = data->timer_val * 60;
> +	} else {
> +		data->minute_mode = false;
> +		data->timer_val = timeout;
> +	}
> +
>  	wdog->timeout = timeout;

Can't it just use `wdog->timeout` instead of introducing a new
`data->timer_val`?

> @@ -332,6 +349,8 @@ static unsigned int wdt_get_time(struct watchdog_device *wdog)
>  
>  	superio_select(data->sio->addr, W83627HF_LD_WDT);
>  	timeleft = superio_inb(data->sio->addr, data->reg->timeout);
> +	if (data->minute_mode)
> +		timeleft *= 60;
>  	superio_exit(data->sio->addr, data->sio->cfg_leave);

The scaling can move out of the superio_* block.

      parent reply	other threads:[~2026-10-22 15:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-20  8:11 [PATCH v5 0/5] watchdog: w83627hf_wdt: Convert driver to the driver model and add minute support Paul Louvel
2026-10-20  8:11 ` [PATCH v5 1/5] watchdog: w83627hf_wdt: Replace magic numbers with descriptive macros Paul Louvel
2026-10-20  8:11 ` [PATCH v5 2/5] watchdog: w83627hf_wdt: Convert to platform driver model Paul Louvel
2026-10-20 13:29   ` Tzung-Bi Shih
2026-10-20  8:11 ` [PATCH v5 3/5] watchdog: w83627hf_wdt: Move register offsets into driver data Paul Louvel
2026-10-20 13:44   ` Tzung-Bi Shih
2026-10-20  8:11 ` [PATCH v5 4/5] watchdog: w83627hf_wdt: Store Super I/O configurations in platform data Paul Louvel
2026-10-20  8:11 ` [PATCH v5 5/5] watchdog: w83627hf_wdt: Add minute mode counting Paul Louvel
2026-10-20 14:08   ` Tzung-Bi Shih
2026-10-20 15:42     ` Guenter Roeck
2026-10-20 16:28     ` Paul Louvel
2026-10-22 15:09   ` Tzung-Bi Shih [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=atonPYaCken3EItA@google.com \
    --to=tzungbi@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=paul.louvel@bootlin.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=wim@linux-watchdog.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®