i2c: add suspended flag and accessors for i2c adapters
A few drivers open code the handling of suspended adapters. It could be handled by the core, though, to ensure generic handling. This patch adds the flag and accessor functions. The usage of these helpers is optional, though. See the kerneldoc in this patch. Using the new flag, we now reject further transfers if the adapter is already marked suspended. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
This commit is contained in:

committed by
Wolfram Sang

parent
bfeffd1552
commit
9ac6cb5fbb
@@ -1232,6 +1232,7 @@ static int i2c_register_adapter(struct i2c_adapter *adap)
|
||||
if (!adap->lock_ops)
|
||||
adap->lock_ops = &i2c_adapter_lock_ops;
|
||||
|
||||
adap->locked_flags = 0;
|
||||
rt_mutex_init(&adap->bus_lock);
|
||||
rt_mutex_init(&adap->mux_lock);
|
||||
mutex_init(&adap->userspace_clients_lock);
|
||||
@@ -1865,6 +1866,8 @@ 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)))
|
||||
return -ESHUTDOWN;
|
||||
|
||||
if (adap->quirks && i2c_check_for_quirks(adap, msgs, num))
|
||||
return -EOPNOTSUPP;
|
||||
|
Reference in New Issue
Block a user