[i2c] [PATCH] Convert i2c-mpc from a platform driver to an of_platform one

Jean Delvare khali at linux-fr.org
Sun Jun 29 17:17:25 EST 2008


On Sun, 29 Jun 2008 00:58:12 -0600, Grant Likely wrote:
> On Sun, Jun 29, 2008 at 08:31:43AM +0200, Jean Delvare wrote:
> > Hi Jon, Grant,
> > 
> > On Sat, 28 Jun 2008 22:49:40 -0600, Grant Likely wrote:
> > > On Sat, Jun 28, 2008 at 10:05:28PM -0400, Jon Smirl wrote:
> > > > >
> > > > > The driver was previously using i2c_add_numbered_adapter(), giving MPC
> > > > >  platform the possibility to use new-style i2c drivers:
> > > > >  http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=1469fa263870acd890a4b9f6ef557acc5d673b44
> > > > >  You're breaking this, I doubt it's on purpose?
> > > > 
> > > > Grant, what do you want here? You're the one who converted it to
> > > > i2c_add_numbered_adapter. But in other posts you've said that the
> > > > device tree should have nothing to do with bus numbering.
> > > 
> > > Yes, I did make that change, but that was when it was a platform bus
> > > driver.  Converting it to an of_platform bus driver entirely changes the
> > > situation and it should go back to using i2c_add_adapter() with a parse
> > > of the device tree for child nodes.
> > 
> > I am surprised and disappointed, as this sounds like a regression.
> > Registering the i2c buses with random numbers and parsing the device
> > tree later to figure out which devices are where, is what everybody was
> > doing before the new i2c device/driver matching model was implemented,
> > because there was no other way. I'm curious why you are going back to
> > this approach when i2c-core now offers something way cleaner and more
> > efficient.
> 
> Ah, but the whole random number parsing thing is no longer necessary
> because we ensure that registration of i2c devices always occurs
> after the i2c adapter is created (for device tree aware i2c adapter
> drivers.  adapters that aren't device tree aware still need to assign a
> number).
> 
> After the i2c adapter registers itself, of_register_i2c_devices() is called
> which walks through the child nodes of the i2c adapter node in the device
> tree.  Each child node is an i2c device, and it immediately get
> registered with the adapter.  Because this ensures that i2c device
> registration always happens after adapter registration, and since the
> pointer to the i2c_adapter is known, then i2c_new_device() can be used
> directly without ever needing to know the bus number.

Ah, OK. If you use i2c_new_device() then it's alright.

-- 
Jean Delvare



More information about the Linuxppc-dev mailing list