From 4db61c2a16fce2ef85d82751de4ba43a39347cfb Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Thu, 25 Apr 2019 16:19:47 +0200 Subject: i2c: core: ratelimit 'transfer when suspended' errors There are two problems with WARN_ON() here. One: It is not ratelimited. Two: We don't see which adapter was used when trying to transfer something when already suspended. Implement a custom ratelimit once per adapter and use dev_WARN there. This fixes both issues. Drawback is that we don't see if multiple drivers are trying to transfer with the same adapter while suspended. They need to be discovered one after the other now. This is better than a high CPU load because a really broken driver might try to resend endlessly. Fixes: 9ac6cb5fbb17 ("i2c: add suspended flag and accessors for i2c adapters") Signed-off-by: Wolfram Sang Reviewed-by: Simon Horman Signed-off-by: Wolfram Sang Cc: stable@vger.kernel.org # v5.1+ --- include/linux/i2c.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/linux/i2c.h') diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 03755d4c9229..be27062f8ed1 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -694,7 +694,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]; -- cgit