提交 6ea23039 编写于 作者: J Jiri Kosina 提交者: Jean Delvare

i2c: Add support for nested i2c bus locking

This patch adds the 'level' field into the i2c_adapter structure, which is 
used to represent the 'logical' level of nesting for the purposes of 
lockdep. This field is then used in the i2c_transfer() function, to 
acquire the per-adapter bus_lock with correct nesting level.
Signed-off-by: NJiri Kosina <jikos@jikos.cz>
Signed-off-by: NJean Delvare <khali@linux-fr.org>
上级 ad04d5c3
...@@ -603,7 +603,7 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num) ...@@ -603,7 +603,7 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num)
} }
#endif #endif
mutex_lock(&adap->bus_lock); mutex_lock_nested(&adap->bus_lock, adap->level);
ret = adap->algo->master_xfer(adap,msgs,num); ret = adap->algo->master_xfer(adap,msgs,num);
mutex_unlock(&adap->bus_lock); mutex_unlock(&adap->bus_lock);
......
...@@ -216,6 +216,7 @@ struct i2c_adapter { ...@@ -216,6 +216,7 @@ struct i2c_adapter {
int (*client_unregister)(struct i2c_client *); int (*client_unregister)(struct i2c_client *);
/* data fields that are valid for all devices */ /* data fields that are valid for all devices */
u8 level; /* nesting level for lockdep */
struct mutex bus_lock; struct mutex bus_lock;
struct mutex clist_lock; struct mutex clist_lock;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册