[i2c] [patch 2.6.21-rc3-git +i2c 4/5] i2c board_info and i2c_new_device()

Jean Delvare khali at linux-fr.org
Thu Mar 15 17:15:38 CET 2007


Hi David,

On Thu, 15 Mar 2007 09:26:20 -0700, David Brownell wrote:
> On Thursday 15 March 2007 2:29 am, Jean Delvare wrote:
> > > @@ -541,9 +616,14 @@ int i2c_attach_client(struct i2c_client 
> > >  	client->usage_count = 0;
> > >  
> > >  	client->dev.parent = &client->adapter->dev;
> > > -	client->dev.driver = &client->driver->driver;
> > >  	client->dev.bus = &i2c_bus_type;
> > > -	client->dev.release = &i2c_client_release;
> > > +
> > > +	if (client->driver) {
> > > +		client->dev.driver = &client->driver->driver;
> > > +		if (!is_newstyle_driver(client->driver))
> > > +			client->dev.release = i2c_client_release;
> > > +	} else
> > > +		client->dev.release = i2c_client_dev_release;
> > >  
> > >  	snprintf(&client->dev.bus_id[0], sizeof(client->dev.bus_id),
> > >  		"%d-%04x", i2c_adapter_id(adapter), client->addr);
> > 
> > I'm surprised by this. It means that in some cases client->dev.release
> > would not be set at all. Is this intended? 
> 
> No, I noticed that after I sent the patch.  Incorrect merge of two
> blocks of code testing client->driver.  I'll update that patch;
> that case won't be common.  Meanwhile, does the rest behave?

Yes, the rest looks OK and the patches passed my basic testing,
covering both legacy and new-style drivers.

> > That being said, is the case 
> > client->driver && is_newstyle_driver(client->driver) possible at all in
> > i2c_attach_client()? I thought not.
> 
> Yes, possible.  It's legit to set up a device with a driver
> already bound to it, then register the device; the driver model
> core will try to bind that driver to the device.  Not the most
> common idiom, but it's been around since the driver model began.

OK, I didn't know that.

-- 
Jean Delvare



More information about the i2c mailing list