From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: linux-i2c@vger.kernel.org
Cc: Wolfram Sang <wsa+renesas@sang-engineering.com>,
Wolfram Sang <wsa@the-dreams.de>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-renesas-soc@vger.kernel.org,
Hans de Goede <hdegoede@redhat.com>,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/9] i2c: reject new transfers when adapters are suspended
Date: Sat, 22 Dec 2018 21:26:16 +0100 [thread overview]
Message-ID: <20181222202623.4521-3-wsa+renesas@sang-engineering.com> (raw)
In-Reply-To: <20181222202623.4521-1-wsa+renesas@sang-engineering.com>
Using the 'is_suspended' flag from the PM core, we now reject new
transfers if the parent of the adapter is already marked suspended.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
Documentation/i2c/fault-codes | 4 ++++
drivers/i2c/i2c-core-base.c | 3 +++
drivers/i2c/i2c-core-smbus.c | 4 ++++
3 files changed, 11 insertions(+)
diff --git a/Documentation/i2c/fault-codes b/Documentation/i2c/fault-codes
index 47c25abb7d52..0cee0fc545b4 100644
--- a/Documentation/i2c/fault-codes
+++ b/Documentation/i2c/fault-codes
@@ -112,6 +112,10 @@ EPROTO
case is when the length of an SMBus block data response
(from the SMBus slave) is outside the range 1-32 bytes.
+ESHUTDOWN
+ Returned when a transfer was requested using an adapter
+ which is already suspended.
+
ETIMEDOUT
This is returned by drivers when an operation took too much
time, and was aborted before it completed.
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 28460f6a60cc..3ce238b782f3 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1865,6 +1865,9 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
if (WARN_ON(!msgs || num < 1))
return -EINVAL;
+ if (WARN(device_is_suspended(adap->dev.parent),
+ "Accessing already suspended I2C/SMBus adapter"))
+ return -ESHUTDOWN;
if (adap->quirks && i2c_check_for_quirks(adap, msgs, num))
return -EOPNOTSUPP;
diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c
index 9cd66cabb84f..e0f7f22feabd 100644
--- a/drivers/i2c/i2c-core-smbus.c
+++ b/drivers/i2c/i2c-core-smbus.c
@@ -547,6 +547,10 @@ s32 __i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
int try;
s32 res;
+ if (WARN(device_is_suspended(adapter->dev.parent),
+ "Accessing already suspended I2C/SMBus adapter"))
+ return -ESHUTDOWN;
+
/* If enabled, the following two tracepoints are conditional on
* read_write and protocol.
*/
--
2.19.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2018-12-22 20:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-22 20:26 [PATCH v2 0/9] i2c: move handling of suspended adapters to the core Wolfram Sang
2018-12-22 20:26 ` [PATCH v2 1/9] PM / core: add helper to return suspend status of a device Wolfram Sang
2018-12-22 20:26 ` Wolfram Sang [this message]
2018-12-24 21:32 ` [PATCH v2 2/9] i2c: reject new transfers when adapters are suspended Hans de Goede
2019-01-03 18:59 ` Wolfram Sang
2019-01-03 20:49 ` Hans de Goede
2018-12-22 20:26 ` [PATCH v2 3/9] i2c: synquacer: remove unused is_suspended flag Wolfram Sang
2018-12-22 20:26 ` [PATCH v2 4/9] i2c: brcmstb: don't open code to reject transfers when suspended Wolfram Sang
2018-12-22 20:26 ` [PATCH v2 5/9] i2c: zx2967: " Wolfram Sang
2018-12-26 1:06 ` Jun Nie
2018-12-22 20:26 ` [PATCH v2 6/9] i2c: sprd: don't use pdev as variable name for struct device * Wolfram Sang
2018-12-22 20:26 ` [PATCH v2 7/9] i2c: sprd: don't open code to reject transfers when suspended Wolfram Sang
2018-12-22 20:26 ` [PATCH v2 8/9] i2c: exynos5: " Wolfram Sang
2018-12-22 20:26 ` [PATCH v2 9/9] i2c: s3c2410: " Wolfram Sang
2018-12-24 8:55 ` [PATCH v2 0/9] i2c: move handling of suspended adapters to the core Hans de Goede
2018-12-26 11:01 ` Geert Uytterhoeven
2018-12-26 11:46 ` Hans de Goede
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=20181222202623.4521-3-wsa+renesas@sang-engineering.com \
--to=wsa+renesas@sang-engineering.com \
--cc=hdegoede@redhat.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=wsa@the-dreams.de \
/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;
as well as URLs for NNTP newsgroup(s).