[i2c] Client creation failed but module still loaded

Jean Delvare khali at linux-fr.org
Mon Jun 25 20:15:21 CEST 2007


Hi Juerg,

On Sat, 23 Jun 2007 09:56:01 -0700, Juerg Haefliger wrote:
> On 6/23/07, Jean Delvare <khali at linux-fr.org> wrote:
> > On Fri, 22 Jun 2007 14:23:50 -0700, Juerg Haefliger wrote:
> > > I noticed that when the .attach_adapter callback fails, something like
> > > the following gets written to the log and the module is still getting
> > > loaded:
> > > i2c_adapter i2c-0: Client creation failed at 0xXY (-12)
> >
> > Actually you get this message when i2c_probe() fails, not
> > the .attach_adapter callback itself.
> >
> > > Why is the module getting loaded even though the attaching of the I2C
> > > client apparently failed?
> >
> > You assume that there's a single I2C client involved, which isn't
> > necessarily true. You don't want to prevent the driver from loading if
> > one client failed but others succeeded.
> 
> Hmm... I don't get it. I'm specifically talking about a module that
> supports a single i2c device (like the dme1737 for example). How come
> it can be loaded even on a system that doesn't have the chip?
> Shouldn't the module load fail in this case?

Your driver actually supports several devices. It just happens that, in
practice, there can't be more than one. But i2c-core doesn't know that!
The dme1737 driver (and the smsc47m192 driver, too) is very special in
that respect, because it's an i2c driver for a LPC device. If you want
it to fail loading when no supported Super-I/O is found, feel free to
add specific code for that. It makes sense. But don't ask i2c-core to
do it for you, it's simply not its job.

> > Also note that its is possible to load the i2c chip driver first, and
> > the i2c bus driver second. You don't wan't to prevent the i2c bus
> > driver from loading because one chip driver failed while probing it.
> 
> That statement is even more confusing. How does chip probing work if
> you don't have the bus driver loaded? Is it deferred until the bus
> driver is loaded?

Yes.

That's not very different from USB (or anything else which supports
hotplug): you can load an usb driver before its device is connected.
Loading the driver will succeed, and when a supported device is finally
plugged in, the driver's probing will start.

-- 
Jean Delvare



More information about the i2c mailing list