瀏覽代碼

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: Jiri Kosina <jikos@jikos.cz>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Jiri Kosina 18 年之前
父節點
當前提交
6ea23039cb
共有 2 個文件被更改,包括 2 次插入1 次删除
  1. 1 1
      drivers/i2c/i2c-core.c
  2. 1 0
      include/linux/i2c.h

+ 1 - 1
drivers/i2c/i2c-core.c

@@ -603,7 +603,7 @@ int i2c_transfer(struct i2c_adapter * adap, struct i2c_msg *msgs, int num)
 		}
 #endif
 
-		mutex_lock(&adap->bus_lock);
+		mutex_lock_nested(&adap->bus_lock, adap->level);
 		ret = adap->algo->master_xfer(adap,msgs,num);
 		mutex_unlock(&adap->bus_lock);
 

+ 1 - 0
include/linux/i2c.h

@@ -216,6 +216,7 @@ struct i2c_adapter {
 	int (*client_unregister)(struct i2c_client *);
 
 	/* data fields that are valid for all devices	*/
+	u8 level; 			/* nesting level for lockdep */
 	struct mutex bus_lock;
 	struct mutex clist_lock;