All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] watchdog: da9063: use atomic safe i2c transfer in reset handler
@ 2021-11-24  8:06 Andrej Picej
  2021-11-24  9:44 ` Adam Thomson
  2021-11-24 14:10 ` Guenter Roeck
  0 siblings, 2 replies; 3+ messages in thread
From: Andrej Picej @ 2021-11-24  8:06 UTC (permalink / raw)
  To: support.opensource, wim, linux, linux-watchdog; +Cc: andrej.picej, y.bas

From: Yunus Bas <y.bas@phytec.de>

This patch is based on commit 057b52b4b3d5 ("watchdog: da9062: make restart
handler atomic safe"), which uses the atomic transfer capability of the
i2c framework.

Signed-off-by: Yunus Bas <y.bas@phytec.de>
Signed-off-by: Andrej Picej <andrej.picej@norik.com>
---
 drivers/watchdog/da9063_wdt.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
index d79ce64e26a9..9adad1862bbd 100644
--- a/drivers/watchdog/da9063_wdt.c
+++ b/drivers/watchdog/da9063_wdt.c
@@ -14,6 +14,7 @@
 #include <linux/platform_device.h>
 #include <linux/uaccess.h>
 #include <linux/slab.h>
+#include <linux/i2c.h>
 #include <linux/delay.h>
 #include <linux/mfd/da9063/registers.h>
 #include <linux/mfd/da9063/core.h>
@@ -169,14 +170,19 @@ static int da9063_wdt_restart(struct watchdog_device *wdd, unsigned long action,
 			      void *data)
 {
 	struct da9063 *da9063 = watchdog_get_drvdata(wdd);
+	struct i2c_client *client = to_i2c_client(da9063->dev);
 	int ret;
 
-	ret = regmap_write(da9063->regmap, DA9063_REG_CONTROL_F,
-			   DA9063_SHUTDOWN);
-	if (ret)
+	/* Don't use regmap because it is not atomic safe */
+	ret = i2c_smbus_write_byte_data(client, DA9063_REG_CONTROL_F,
+					DA9063_SHUTDOWN);
+	if (ret < 0)
 		dev_alert(da9063->dev, "Failed to shutdown (err = %d)\n",
 			  ret);
 
+	/* wait for reset to assert... */
+	mdelay(500);
+
 	return ret;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] watchdog: da9063: use atomic safe i2c transfer in reset handler
  2021-11-24  8:06 [PATCH] watchdog: da9063: use atomic safe i2c transfer in reset handler Andrej Picej
@ 2021-11-24  9:44 ` Adam Thomson
  2021-11-24 14:10 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Adam Thomson @ 2021-11-24  9:44 UTC (permalink / raw)
  To: Andrej Picej, Support Opensource, wim, linux, linux-watchdog; +Cc: y.bas

On 24 November 2021 08:07, Andrej Picej wrote:

> From: Yunus Bas <y.bas@phytec.de>
> 
> This patch is based on commit 057b52b4b3d5 ("watchdog: da9062: make restart
> handler atomic safe"), which uses the atomic transfer capability of the
> i2c framework.
> 
> Signed-off-by: Yunus Bas <y.bas@phytec.de>
> Signed-off-by: Andrej Picej <andrej.picej@norik.com>
> ---

Reviewed-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] watchdog: da9063: use atomic safe i2c transfer in reset handler
  2021-11-24  8:06 [PATCH] watchdog: da9063: use atomic safe i2c transfer in reset handler Andrej Picej
  2021-11-24  9:44 ` Adam Thomson
@ 2021-11-24 14:10 ` Guenter Roeck
  1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2021-11-24 14:10 UTC (permalink / raw)
  To: Andrej Picej; +Cc: support.opensource, wim, linux-watchdog, y.bas

On Wed, Nov 24, 2021 at 09:06:54AM +0100, Andrej Picej wrote:
> From: Yunus Bas <y.bas@phytec.de>
> 
> This patch is based on commit 057b52b4b3d5 ("watchdog: da9062: make restart
> handler atomic safe"), which uses the atomic transfer capability of the
> i2c framework.
> 
> Signed-off-by: Yunus Bas <y.bas@phytec.de>
> Signed-off-by: Andrej Picej <andrej.picej@norik.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/da9063_wdt.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/watchdog/da9063_wdt.c b/drivers/watchdog/da9063_wdt.c
> index d79ce64e26a9..9adad1862bbd 100644
> --- a/drivers/watchdog/da9063_wdt.c
> +++ b/drivers/watchdog/da9063_wdt.c
> @@ -14,6 +14,7 @@
>  #include <linux/platform_device.h>
>  #include <linux/uaccess.h>
>  #include <linux/slab.h>
> +#include <linux/i2c.h>
>  #include <linux/delay.h>
>  #include <linux/mfd/da9063/registers.h>
>  #include <linux/mfd/da9063/core.h>
> @@ -169,14 +170,19 @@ static int da9063_wdt_restart(struct watchdog_device *wdd, unsigned long action,
>  			      void *data)
>  {
>  	struct da9063 *da9063 = watchdog_get_drvdata(wdd);
> +	struct i2c_client *client = to_i2c_client(da9063->dev);
>  	int ret;
>  
> -	ret = regmap_write(da9063->regmap, DA9063_REG_CONTROL_F,
> -			   DA9063_SHUTDOWN);
> -	if (ret)
> +	/* Don't use regmap because it is not atomic safe */
> +	ret = i2c_smbus_write_byte_data(client, DA9063_REG_CONTROL_F,
> +					DA9063_SHUTDOWN);
> +	if (ret < 0)
>  		dev_alert(da9063->dev, "Failed to shutdown (err = %d)\n",
>  			  ret);
>  
> +	/* wait for reset to assert... */
> +	mdelay(500);
> +
>  	return ret;
>  }
>  
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-24 14:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-24  8:06 [PATCH] watchdog: da9063: use atomic safe i2c transfer in reset handler Andrej Picej
2021-11-24  9:44 ` Adam Thomson
2021-11-24 14:10 ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.