TODO use mutex and mutex_try_lock instead of boolean flag. Avoid that multiple consumers can block the adapter at the same time. This flag is only intended to be used in the shutdown process in which no cleanup is required. Signed-off-by: Stefan Christ <s.christ@xxxxxxxxx> --- drivers/i2c/i2c-core.c | 5 +++++ include/linux/i2c.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 987c124..9db7130 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -2068,6 +2068,11 @@ int i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) { int ret; + if (adap->blocked) { + dev_info(&adap->dev, "No more i2c communication is allowed! pid = %d\n", current->pid); + return -EPERM; + } + /* REVISIT the fault reporting model here is weak: * * - When we get an error after receiving N bytes from a slave, diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 8461841..282ec71 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h @@ -519,6 +519,7 @@ struct i2c_adapter { struct i2c_bus_recovery_info *bus_recovery_info; const struct i2c_adapter_quirks *quirks; + bool blocked; }; #define to_i2c_adapter(d) container_of(d, struct i2c_adapter, dev) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html