[i2c] [patch 2.6.19-rc5] some i2c driver model updates

Jean Delvare khali at linux-fr.org
Thu Nov 16 22:48:37 CET 2006

Hi David,

On Thu, 16 Nov 2006 11:34:38 -0800, David Brownell wrote:
> > I don't get how i2c_do_add_adapter can be called recursively that
> > way... Could be a bad interaction with another patch in my stack, I'm
> > investigating.
> Could also be bad stack backtrace.  I've used that patch on an
> x86_64 and an ARM, no problems ...

I think I found the problem. You replaced the "drivers" list maintained
by i2c-core by the list of drivers maintained by the driver core,
assuming they were equal. However, the i2c-core only listed i2c chip
drivers (struct i2c_driver), while it looks to me like the driver core
lists the i2c chip drivers (struct i2c_driver) _and_ the "i2c_adapter"
driver (i2c_adapter_driver), which you can see in /sys/bus/i2c/drivers.
When you call to_i2c_driver() on this one in i2c_do_add_adapter(),
well... you can't. I guess sometimes you're lucky and
driver->attach_adapter is NULL, so it's silently skipped, and I wasn't
lucky and it crashed on me.

So we need to catch this exception in i2c_do_add_adapter(), and then
things should work. And I suspect i2c-dev will need a similar exception.

OTOH I admit I wonder why i2c_adapter_driver is listed with all
i2c_driver structs at the driver core level, while they are of
different nature. But then again I'm not familiar with the driver
model. Greg?

Jean Delvare

More information about the i2c mailing list