Skip to content

Commit 968011a

Browse files
yubas28Wim Van Sebroeck
authored andcommitted
watchdog: da9063: use atomic safe i2c transfer in reset handler
This patch is based on commit 057b52b ("watchdog: da9062: make restart handler atomic safe"), which uses the atomic transfer capability of the i2c framework. Signed-off-by: Yunus Bas <[email protected]> Signed-off-by: Andrej Picej <[email protected]> Reviewed-by: Adam Thomson <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 1fc8a2c commit 968011a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/watchdog/da9063_wdt.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/platform_device.h>
1515
#include <linux/uaccess.h>
1616
#include <linux/slab.h>
17+
#include <linux/i2c.h>
1718
#include <linux/delay.h>
1819
#include <linux/mfd/da9063/registers.h>
1920
#include <linux/mfd/da9063/core.h>
@@ -169,14 +170,19 @@ static int da9063_wdt_restart(struct watchdog_device *wdd, unsigned long action,
169170
void *data)
170171
{
171172
struct da9063 *da9063 = watchdog_get_drvdata(wdd);
173+
struct i2c_client *client = to_i2c_client(da9063->dev);
172174
int ret;
173175

174-
ret = regmap_write(da9063->regmap, DA9063_REG_CONTROL_F,
175-
DA9063_SHUTDOWN);
176-
if (ret)
176+
/* Don't use regmap because it is not atomic safe */
177+
ret = i2c_smbus_write_byte_data(client, DA9063_REG_CONTROL_F,
178+
DA9063_SHUTDOWN);
179+
if (ret < 0)
177180
dev_alert(da9063->dev, "Failed to shutdown (err = %d)\n",
178181
ret);
179182

183+
/* wait for reset to assert... */
184+
mdelay(500);
185+
180186
return ret;
181187
}
182188

0 commit comments

Comments
 (0)