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

Greg KH greg at kroah.com
Fri Nov 17 00:56:01 CET 2006


On Thu, Nov 16, 2006 at 10:48:37PM +0100, Jean Delvare wrote:
> 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?

Ick, yeah, sorry about that.  It's not the correct thing to do, but was
the best I could do at the time.

I agree with David that the adapter needs to be a class, we spoke a
little about this a few months ago in the Czech Republic, but I haven't
had the time to follow up with the changes due to other real-life work
issues.

As to how to fix this, I'm not really sure, I'll have to look at the
code some more...

thanks,

greg k-h



More information about the i2c mailing list