From: Sander Vanheule <sander@svanheule.net>
To: Rustam Adilov <adilov@disroot.org>,
Wim Van Sebroeck <wim@linux-watchdog.org>,
Guenter Roeck <linux@roeck-us.net>,
linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/1] watchdog: realtek-otto: Change to use regmap API
Date: Tue, 19 May 2026 21:00:37 +0200 [thread overview]
Message-ID: <6ff773c9cf93167fbfcf5d9a40106121f9ac8238.camel@svanheule.net> (raw)
In-Reply-To: <20260519182329.24472-2-adilov@disroot.org>
Hi Rustam,
On Tue, 2026-05-19 at 23:23 +0500, Rustam Adilov wrote:
[...]
> @@ -74,24 +75,17 @@ struct otto_wdt_ctrl {
> static int otto_wdt_start(struct watchdog_device *wdev)
> {
> struct otto_wdt_ctrl *ctrl = watchdog_get_drvdata(wdev);
> - u32 v;
> -
> - v = ioread32(ctrl->base + OTTO_WDT_REG_CTRL);
> - v |= OTTO_WDT_CTRL_ENABLE;
> - iowrite32(v, ctrl->base + OTTO_WDT_REG_CTRL);
>
> + regmap_set_bits(ctrl->regmap, OTTO_WDT_REG_CTRL,
> OTTO_WDT_CTRL_ENABLE);
> return 0;
iowrite32() doesn't return anything, but regmap_set_bits() does.
You can turn this into
return regmap_set_bits(...);
> }
>
> static int otto_wdt_stop(struct watchdog_device *wdev)
> {
> struct otto_wdt_ctrl *ctrl = watchdog_get_drvdata(wdev);
> - u32 v;
> -
> - v = ioread32(ctrl->base + OTTO_WDT_REG_CTRL);
> - v &= ~OTTO_WDT_CTRL_ENABLE;
> - iowrite32(v, ctrl->base + OTTO_WDT_REG_CTRL);
>
> + regmap_clear_bits(ctrl->regmap, OTTO_WDT_REG_CTRL,
> + OTTO_WDT_CTRL_ENABLE);
> return 0;
Same as above.
This is probably short enough to keep is on one line? (< 100 characters)
> }
>
> @@ -99,8 +93,7 @@ static int otto_wdt_ping(struct watchdog_device *wdev)
> {
> struct otto_wdt_ctrl *ctrl = watchdog_get_drvdata(wdev);
>
> - iowrite32(OTTO_WDT_CNTR_PING, ctrl->base + OTTO_WDT_REG_CNTR);
> -
> + regmap_write(ctrl->regmap, OTTO_WDT_REG_CNTR, OTTO_WDT_CNTR_PING);
> return 0;
Same as above.
> }
>
> @@ -126,7 +119,7 @@ static int otto_wdt_determine_timeouts(struct
> watchdog_device *wdev, unsigned in
> unsigned int total_ticks;
> unsigned int prescale;
> unsigned int tick_ms;
> - u32 v;
> + u32 mask, val;
>
> do {
> prescale = prescale_next;
> @@ -142,14 +135,11 @@ static int otto_wdt_determine_timeouts(struct
> watchdog_device *wdev, unsigned in
> } while (phase1_ticks > OTTO_WDT_PHASE_TICKS_MAX
> || phase2_ticks > OTTO_WDT_PHASE_TICKS_MAX);
>
> - v = ioread32(ctrl->base + OTTO_WDT_REG_CTRL);
> -
> - v &= ~(OTTO_WDT_CTRL_PRESCALE | OTTO_WDT_CTRL_PHASE1 |
> OTTO_WDT_CTRL_PHASE2);
> - v |= FIELD_PREP(OTTO_WDT_CTRL_PHASE1, phase1_ticks - 1);
> - v |= FIELD_PREP(OTTO_WDT_CTRL_PHASE2, phase2_ticks - 1);
> - v |= FIELD_PREP(OTTO_WDT_CTRL_PRESCALE, prescale);
> -
> - iowrite32(v, ctrl->base + OTTO_WDT_REG_CTRL);
> + mask = OTTO_WDT_CTRL_PRESCALE | OTTO_WDT_CTRL_PHASE1 |
> OTTO_WDT_CTRL_PHASE2;
> + val = FIELD_PREP(OTTO_WDT_CTRL_PHASE1, phase1_ticks - 1);
> + val |= FIELD_PREP(OTTO_WDT_CTRL_PHASE2, phase2_ticks - 1);
> + val |= FIELD_PREP(OTTO_WDT_CTRL_PRESCALE, prescale);
> + regmap_update_bits(ctrl->regmap, OTTO_WDT_REG_CTRL, mask, val);
To be consistent, you would also need to propagate the result of
regmap_update_bits() if it's an error. Same for the other regmap_*() calls.
Best,
Sander
next prev parent reply other threads:[~2026-05-19 19:00 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-19 18:23 [PATCH v2 0/1] watchdog: realtek-otto: Make use of " Rustam Adilov
2026-05-19 18:23 ` [PATCH v2 1/1] watchdog: realtek-otto: Change to use " Rustam Adilov
2026-05-19 19:00 ` Sander Vanheule [this message]
2026-05-19 19:25 ` Guenter Roeck
2026-05-26 20:23 ` Rustam Adilov
2026-06-20 11:23 ` [PATCH v2 0/1] watchdog: realtek-otto: Make use of " Rustam Adilov
2026-06-23 18:44 ` Guenter Roeck
2026-06-23 20:44 ` Sander Vanheule
2026-07-01 18:48 ` Rustam Adilov
2026-07-04 14:00 ` Sander Vanheule
2026-07-04 15:13 ` Rustam Adilov
2026-07-04 16:05 ` Sander Vanheule
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=6ff773c9cf93167fbfcf5d9a40106121f9ac8238.camel@svanheule.net \
--to=sander@svanheule.net \
--cc=adilov@disroot.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-watchdog@vger.kernel.org \
--cc=linux@roeck-us.net \
--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®