From: Stefan Lengfeld <contact@stefanchrist.eu>
To: wsa+renesas@sang-engineering.com
Cc: linux-i2c@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
preid@electromag.com.au, linux-omap@vger.kernel.org,
linux-arm-kernel@lists.infradead.or, j-keerthy@ti.com,
t-kristo@ti.com, grygorii.strashko@ti.com,
andriy.shevchenko@linux.intel.com
Subject: [RFC PATCH 2/3] watchdog: da9062: avoid regmap in restart handler
Date: Sun, 7 Oct 2018 17:39:36 +0200 [thread overview]
Message-ID: <20181007153937.16787-3-contact@stefanchrist.eu> (raw)
In-Reply-To: <20181007153937.16787-1-contact@stefanchrist.eu>
Using i2c_transfer() directly to set the shutdown bit is more reliable
than using regmap in atomic contexts, because calls to 'schedule()' or
'sleep()' must be avoided in call code paths.
Tested on a phyCORE-i.MX6 Solo board.
Signed-off-by: Stefan Lengfeld <contact@stefanchrist.eu>
---
drivers/mfd/da9062-core.c | 1 +
drivers/watchdog/da9062_wdt.c | 17 +++++++++++++----
include/linux/mfd/da9062/core.h | 1 +
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/mfd/da9062-core.c b/drivers/mfd/da9062-core.c
index 9f6105906c09..b6a01054ba0f 100644
--- a/drivers/mfd/da9062-core.c
+++ b/drivers/mfd/da9062-core.c
@@ -609,6 +609,7 @@ static int da9062_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, chip);
chip->dev = &i2c->dev;
+ chip->i2c = i2c;
if (!i2c->irq) {
dev_err(chip->dev, "No IRQ configured\n");
diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c
index fe169d8e1fb2..ad6483d25f83 100644
--- a/drivers/watchdog/da9062_wdt.c
+++ b/drivers/watchdog/da9062_wdt.c
@@ -11,6 +11,7 @@
#include <linux/platform_device.h>
#include <linux/uaccess.h>
#include <linux/slab.h>
+#include <linux/i2c.h>
#include <linux/delay.h>
#include <linux/jiffies.h>
#include <linux/mfd/da9062/registers.h>
@@ -152,12 +153,20 @@ static int da9062_wdt_restart(struct watchdog_device *wdd, unsigned long action,
void *data)
{
struct da9062_watchdog *wdt = watchdog_get_drvdata(wdd);
+ struct i2c_client *client = wdt->hw->i2c;
+ __u8 buf[3] = {DA9062AA_CONTROL_F, DA9062AA_SHUTDOWN_MASK, 0x0};
+ struct i2c_msg msgs[1] = {
+ {
+ .addr = client->addr,
+ .flags = (client->flags & I2C_M_TEN),
+ .len = sizeof(buf),
+ .buf = buf,
+ }
+ };
int ret;
- ret = regmap_write(wdt->hw->regmap,
- DA9062AA_CONTROL_F,
- DA9062AA_SHUTDOWN_MASK);
- if (ret)
+ ret = i2c_transfer(client->adapter, msgs, sizeof(msgs));
+ if (ret < 0)
dev_alert(wdt->hw->dev, "Failed to shutdown (err = %d)\n",
ret);
diff --git a/include/linux/mfd/da9062/core.h b/include/linux/mfd/da9062/core.h
index 74d33a01ddae..c994293b3aef 100644
--- a/include/linux/mfd/da9062/core.h
+++ b/include/linux/mfd/da9062/core.h
@@ -68,6 +68,7 @@ enum da9062_irqs {
struct da9062 {
struct device *dev;
struct regmap *regmap;
+ struct i2c_client *i2c;
struct regmap_irq_chip_data *regmap_irq;
enum da9062_compatible_types chip_type;
};
--
2.16.4
next prev parent reply other threads:[~2018-10-07 22:47 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-20 16:14 [RFC PATCH 0/4] i2c: core: introduce master_xfer_irqless Wolfram Sang
2018-09-20 16:14 ` [RFC PATCH 1/4] i2c: core: remove outdated DEBUG output Wolfram Sang
2018-09-20 17:23 ` Peter Rosin
2018-10-05 16:14 ` Wolfram Sang
2018-09-20 16:14 ` [RFC PATCH 2/4] i2c: core: remove level of indentation in i2c_transfer Wolfram Sang
2018-09-20 17:26 ` Peter Rosin
2018-09-20 22:46 ` Wolfram Sang
2018-10-05 16:15 ` Wolfram Sang
2018-09-20 16:14 ` [RFC PATCH 3/4] i2c: core: use I2C locking behaviour also for SMBUS Wolfram Sang
2018-09-20 17:31 ` Peter Rosin
2018-09-20 22:48 ` Wolfram Sang
2018-09-20 16:14 ` [RFC PATCH 4/4] i2c: core: introduce master_xfer_irqless callback Wolfram Sang
2018-09-20 17:41 ` Peter Rosin
2018-09-20 22:55 ` Wolfram Sang
2018-10-18 10:44 ` Russell King - ARM Linux
2019-02-09 18:03 ` Wolfram Sang
2018-09-20 22:02 ` [RFC PATCH 0/4] i2c: core: introduce master_xfer_irqless Tony Lindgren
2018-09-20 22:56 ` Wolfram Sang
2018-10-18 10:35 ` Keerthy
2018-09-20 23:01 ` Wolfram Sang
2018-09-23 20:20 ` Stefan Lengfeld
2018-10-07 15:39 ` [RFC PATCH 0/3] " Stefan Lengfeld
2018-10-07 15:39 ` [RFC PATCH 1/3] i2c: imx: implement master_xfer_irqless callback Stefan Lengfeld
2018-10-08 10:06 ` Andy Shevchenko
2018-10-07 15:39 ` Stefan Lengfeld [this message]
2018-10-08 10:07 ` [RFC PATCH 2/3] watchdog: da9062: avoid regmap in restart handler Andy Shevchenko
2018-10-07 15:39 ` [RFC PATCH 3/3] ARM: dts: phyboard-mira-dl: rely on PMIC for reboot and watchdog Stefan Lengfeld
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=20181007153937.16787-3-contact@stefanchrist.eu \
--to=contact@stefanchrist.eu \
--cc=andriy.shevchenko@linux.intel.com \
--cc=grygorii.strashko@ti.com \
--cc=j-keerthy@ti.com \
--cc=linux-arm-kernel@lists.infradead.or \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=preid@electromag.com.au \
--cc=t-kristo@ti.com \
--cc=wsa+renesas@sang-engineering.com \
/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