[i2c] [patch 2.6.20-rc1 2/6] I2C adapters (mostly) stop using i2c_adapter.dev

Jean Delvare khali at linux-fr.org
Thu Jan 4 13:53:13 CET 2007


On Mon, 18 Dec 2006 13:19:27 -0800, David Brownell wrote:
> Index: g26/drivers/i2c/busses/i2c-s3c2410.c
> ===================================================================
> --- g26.orig/drivers/i2c/busses/i2c-s3c2410.c	2006-12-18 11:45:46.000000000 -0800
> +++ g26/drivers/i2c/busses/i2c-s3c2410.c	2006-12-18 11:52:25.000000000 -0800
> @@ -694,7 +694,7 @@ static int s3c24xx_i2c_init(struct s3c24
>  	/* get the plafrom data */
> -	pdata = s3c24xx_i2c_get_platformdata(i2c->adap.dev.parent);
> +	pdata = s3c24xx_i2c_get_platformdata(i2c->adap.class_dev.dev);
>  	/* inititalise the gpio */

After careful examination, this one looks broken to me.
s3c24xx_i2c_init() is sometimes called before i2c_add_adapter() is
called, so at this point class_dev.dev is not set yet.

We could move that change to patch #5, but that patch, in its current
incarnation, has the side effect of changing class_dev.dev from the
parent device to the fake i2c_adapter device when i2c_add_adapter() is
called, which would break when s3c24xx_i2c_init() is called _after_
i2c_add_adapter(), from s3c24xx_i2c_resume().

It looks to me that a valid fix would be to use i2c->dev instead, which
points to the platform device. I don't know why i2c->dev wasn't used
here in the first place, as is done in the rest of the driver, maybe
Ben can tell?

I want to think about that side effect of i2c_add_adapter() before
pushing patch #5 to -mm, I don't like it, it's error prone.

Jean Delvare

More information about the i2c mailing list