Home Home > GIT Browse > stable
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-05-17 06:38:43 +0200
committerJiri Slaby <jslaby@suse.cz>2019-05-17 06:38:46 +0200
commit4d44a923b03a27461ff03bd25da20f61b87f4e9b (patch)
treeac14d537f1e84b2c129aded0d58b8262b6710a0d
parentdc19148d01c66967ea0b2c4cf261534efee3a2a8 (diff)
i2c: core: ratelimit 'transfer when suspended' errors
-rw-r--r--drivers/i2c/i2c-core-base.c5
-rw-r--r--include/linux/i2c.h3
2 files changed, 6 insertions, 2 deletions
diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c
index 688aa3b5f3ac..2f0f88b79c4b 100644
--- a/drivers/i2c/i2c-core-base.c
+++ b/drivers/i2c/i2c-core-base.c
@@ -1871,8 +1871,11 @@ int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
if (WARN_ON(!msgs || num < 1))
return -EINVAL;
- if (WARN_ON(test_bit(I2C_ALF_IS_SUSPENDED, &adap->locked_flags)))
+ if (test_bit(I2C_ALF_IS_SUSPENDED, &adap->locked_flags)) {
+ if (!test_and_set_bit(I2C_ALF_SUSPEND_REPORTED, &adap->locked_flags))
+ dev_WARN(&adap->dev, "Transfer while suspended\n");
return -ESHUTDOWN;
+ }
if (adap->quirks && i2c_check_for_quirks(adap, msgs, num))
return -EOPNOTSUPP;
diff --git a/include/linux/i2c.h b/include/linux/i2c.h
index 383510b4f083..646dd962d6a1 100644
--- a/include/linux/i2c.h
+++ b/include/linux/i2c.h
@@ -682,7 +682,8 @@ struct i2c_adapter {
int retries;
struct device dev; /* the adapter device */
unsigned long locked_flags; /* owned by the I2C core */
-#define I2C_ALF_IS_SUSPENDED 0
+#define I2C_ALF_IS_SUSPENDED 0
+#define I2C_ALF_SUSPEND_REPORTED 1
int nr;
char name[48];