diff mbox series

[v2,1/3] watchdog: pm8916_wdt: Avoid read of write-only PET register

Message ID 20220629084816.125515-2-stephan.gerhold@kernkonzept.com
State New
Headers show
Series [v2,1/3] watchdog: pm8916_wdt: Avoid read of write-only PET register | expand

Commit Message

Stephan Gerhold June 29, 2022, 8:48 a.m. UTC
PMIC_WD_RESET_PET is a write-only register that is used to ping
the watchdog. It does not make sense to use read-modify-write
for it: a register read will never return anything but zero.
(And actually even if it did we would still want to write again
to ensure the watchdog is pinged.)

Reduce the overhead for the watchdog ping slightly by using
regmap_write() directly instead.

Signed-off-by: Stephan Gerhold <stephan.gerhold@kernkonzept.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
---
Changes in v2: Add Guenter's Reviewed-by
---
 drivers/watchdog/pm8916_wdt.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Loic Poulain June 29, 2022, 2:02 p.m. UTC | #1
On Wed, 29 Jun 2022 at 10:48, Stephan Gerhold
<stephan.gerhold@kernkonzept.com> wrote:
>
> PMIC_WD_RESET_PET is a write-only register that is used to ping
> the watchdog. It does not make sense to use read-modify-write
> for it: a register read will never return anything but zero.
> (And actually even if it did we would still want to write again
> to ensure the watchdog is pinged.)
>
> Reduce the overhead for the watchdog ping slightly by using
> regmap_write() directly instead.
>
> Signed-off-by: Stephan Gerhold <stephan.gerhold@kernkonzept.com>
> Reviewed-by: Guenter Roeck <linux@roeck-us.net>

Reviewed-by: Loic Poulain <loic.poulain@linaro.org>

> ---
> Changes in v2: Add Guenter's Reviewed-by
> ---
>  drivers/watchdog/pm8916_wdt.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/watchdog/pm8916_wdt.c b/drivers/watchdog/pm8916_wdt.c
> index 0937b8d33104..670cd79f4cf9 100644
> --- a/drivers/watchdog/pm8916_wdt.c
> +++ b/drivers/watchdog/pm8916_wdt.c
> @@ -58,9 +58,8 @@ static int pm8916_wdt_ping(struct watchdog_device *wdev)
>  {
>         struct pm8916_wdt *wdt = watchdog_get_drvdata(wdev);
>
> -       return regmap_update_bits(wdt->regmap,
> -                                 wdt->baseaddr + PON_PMIC_WD_RESET_PET,
> -                                 WATCHDOG_PET_BIT, WATCHDOG_PET_BIT);
> +       return regmap_write(wdt->regmap, wdt->baseaddr + PON_PMIC_WD_RESET_PET,
> +                           WATCHDOG_PET_BIT);
>  }
>
>  static int pm8916_wdt_configure_timers(struct watchdog_device *wdev)
> --
> 2.30.2
>
diff mbox series

Patch

diff --git a/drivers/watchdog/pm8916_wdt.c b/drivers/watchdog/pm8916_wdt.c
index 0937b8d33104..670cd79f4cf9 100644
--- a/drivers/watchdog/pm8916_wdt.c
+++ b/drivers/watchdog/pm8916_wdt.c
@@ -58,9 +58,8 @@  static int pm8916_wdt_ping(struct watchdog_device *wdev)
 {
 	struct pm8916_wdt *wdt = watchdog_get_drvdata(wdev);
 
-	return regmap_update_bits(wdt->regmap,
-				  wdt->baseaddr + PON_PMIC_WD_RESET_PET,
-				  WATCHDOG_PET_BIT, WATCHDOG_PET_BIT);
+	return regmap_write(wdt->regmap, wdt->baseaddr + PON_PMIC_WD_RESET_PET,
+			    WATCHDOG_PET_BIT);
 }
 
 static int pm8916_wdt_configure_timers(struct watchdog_device *wdev)