[i2c] [PATCH] 1/2: I2C && DVB: fix recursive locking lockped warning in i2c_transfer()

Jean Delvare khali at linux-fr.org
Thu Oct 19 16:45:15 CEST 2006


Hi Jiri,

On Wed, 18 Oct 2006 18:37:34 +0200 (CEST), Jiri Kosina wrote:
> 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 at jikos.cz>
> 
> --- 
> 
>  drivers/i2c/i2c-core.c |    2 +-
>  include/linux/i2c.h    |    1 +
>  2 files changed, 2 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 7ca81f4..79eaa12 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -603,7 +603,7 @@ #ifdef DEBUG
>  		}
>  #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);
>  
> diff --git a/include/linux/i2c.h b/include/linux/i2c.h
> index 9b5d047..08df416 100644
> --- a/include/linux/i2c.h
> +++ b/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;
>  

Applied, thanks. This patch will be in next -mm, and is planned for
merge in 2.6.20-rc1.

-- 
Jean Delvare



More information about the i2c mailing list