From: Grant Likely <grant.likely@secretlab.ca>
To: Jon Smirl <jonsmirl@gmail.com>
Cc: Wolfram Sang <w.sang@pengutronix.de>,
linuxppc-dev list <Linuxppc-dev@ozlabs.org>,
Linux I2C <i2c@lm-sensors.org>, Jean Delvare <khali@linux-fr.org>,
Timur Tabi <timur@freescale.com>
Subject: Re: [i2c] [PATCH] Convert i2c-mpc from a platform driver to an of_platform one
Date: Sat, 28 Jun 2008 22:49:40 -0600 [thread overview]
Message-ID: <20080629044940.GC13658@secretlab.ca> (raw)
In-Reply-To: <9e4733910806281905l61714e33h8b26870e2c93539e@mail.gmail.com>
On Sat, Jun 28, 2008 at 10:05:28PM -0400, Jon Smirl wrote:
> On 6/25/08, Jean Delvare <khali@linux-fr.org> wrote:
> > >
> > > i2c->adap = mpc_ops;
> > > - i2c->adap.nr = pdev->id;
> > > i2c_set_adapdata(&i2c->adap, i2c);
> > > - i2c->adap.dev.parent = &pdev->dev;
> > > - if ((result = i2c_add_numbered_adapter(&i2c->adap)) < 0) {
> > > + i2c->adap.dev.parent = &op->dev;
> > > +
> > > + result = i2c_add_adapter(&i2c->adap);
> >
> >
> > 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.
> Once this driver is converted to an OF one it shouldn't need bus ids
> since all of the i2c devices will be children of the bus node. We can
> just let the i2c subsystem assign a bus number.
Exactly.
> Timur has some issues with the i2c bus number in his ALSA driver. The
> problem is locating the i2c device when the i2s driver loads. Parsing
> the device tree to extract an i2c bus and device number is not a good
> solution.
The trick here is to store the pointer to the device node inside the
i2c device. I do this with SPI devices like this:
/* Store a pointer to the node in the device structure */
of_node_get(nc);
spi->dev.archdata.of_node = nc;
Then, when you've got a device_node pointer, you can parse through the
set of registered SPI devices and match against the one that has the
same device node pointer.
> codec-handle should give you the i2c device node. But then we can't
> use of_find_device_by_node because the i2c device is not an of_device,
> it's a cross platform i2c_device. Should of_find_device_by_node()
> return a 'struct device' instead of a 'struct of_device' and leave it
> as a user exercise to cast up? It is used nine times in the kernel,
> mostly sparc.
No, this doesn't work because I2C and SPI devices are not of_platform
devices. They aren't even platform devices. of_find_device_by_node()
only works for the of_platform bus.
Using archdata.of_node is part of the device structure and works for
every bus type (platform, of_platform, SPI, I2C, PCI, etc.)
g.
next prev parent reply other threads:[~2008-06-29 4:49 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-11 2:40 [PATCH] Convert i2c-mpc from a platform driver to an of_platform one Jon Smirl
2008-06-11 16:00 ` [i2c] " Wolfram Sang
2008-06-11 16:00 ` Wolfram Sang
2008-06-11 16:14 ` Jon Smirl
2008-06-25 13:25 ` Jean Delvare
2008-06-25 13:58 ` Jean Delvare
2008-06-29 2:05 ` Jon Smirl
2008-06-29 4:49 ` Grant Likely [this message]
2008-06-29 6:31 ` Jean Delvare
2008-06-29 6:31 ` Jean Delvare
2008-06-29 6:58 ` Grant Likely
[not found] ` <20080629065812.GO13876-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org>
2008-06-29 7:17 ` Jean Delvare
2008-06-29 7:17 ` [i2c] " Jean Delvare
2008-06-29 16:24 ` Sean MacLennan
2008-06-29 16:35 ` Jean Delvare
2008-06-30 2:51 ` David Brownell
2008-06-29 4:57 ` Grant Likely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080629044940.GC13658@secretlab.ca \
--to=grant.likely@secretlab.ca \
--cc=Linuxppc-dev@ozlabs.org \
--cc=i2c@lm-sensors.org \
--cc=jonsmirl@gmail.com \
--cc=khali@linux-fr.org \
--cc=timur@freescale.com \
--cc=w.sang@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.