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

David Brownell david-b at pacbell.net
Thu Mar 15 17:26:20 CET 2007


On Thursday 15 March 2007 2:29 am, Jean Delvare wrote:
> Hi David,
> 
> On Wed, 14 Mar 2007 13:16:11 -0700, David Brownell wrote:
> > UPDATED by fixing device unregister refcount issues to match
> > standard driver model usage with "new style" devices and drivers.
> > (...)
> > @@ -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?


> 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.

- Dave



More information about the i2c mailing list