* [RFC] Non-numbered ibm iic driver
@ 2008-06-29 3:20 Sean MacLennan
2008-06-29 3:25 ` Jon Smirl
2008-06-29 18:52 ` Jon Loeliger
0 siblings, 2 replies; 5+ messages in thread
From: Sean MacLennan @ 2008-06-29 3:20 UTC (permalink / raw)
To: linuxppc-dev
This is a patch to the ibm iic driver that uses the non-numbered
i2c call and therefore does not need an index. Instead, it registers the
ibm iic, then walks all the child nodes and adds them. This is required
for new style drivers, old style drivers "just work".
The warp has both a new style driver (ad7414) and old style (eeprom)
devices.
This patch is completely function but not a complete patch (the index
code is not needed for example). It is just for comment.
The warp.dts needed for this to work is, I believe, in Josh's next tree.
Cheers,
Sean
P.S. Do I need a signed-off-by for an RFC?
Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>
---
diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
index 85dbf34..0ec6849 100644
--- a/drivers/i2c/busses/i2c-ibm_iic.c
+++ b/drivers/i2c/busses/i2c-ibm_iic.c
@@ -753,7 +753,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){
*/
adap->nr = dev->idx >= 0 ? dev->idx : 0;
- if ((ret = i2c_add_numbered_adapter(adap)) < 0) {
+ if ((ret = i2c_add_adapter(adap)) < 0) {
printk(KERN_ERR "ibm-iic%d: failed to register i2c adapter\n",
dev->idx);
goto fail;
@@ -874,6 +874,7 @@ static int __devinit iic_probe(struct of_device *ofdev,
const struct of_device_id *match)
{
struct device_node *np = ofdev->node;
+ struct device_node *child;
struct ibm_iic_private *dev;
struct i2c_adapter *adap;
const u32 *indexp, *freq;
@@ -939,12 +940,33 @@ static int __devinit iic_probe(struct of_device *ofdev,
adap->timeout = 1;
adap->nr = dev->idx;
- ret = i2c_add_numbered_adapter(adap);
+ ret = i2c_add_adapter(adap);
if (ret < 0) {
dev_err(&ofdev->dev, "failed to register i2c adapter\n");
goto error_cleanup;
}
+ for_each_child_of_node(np, child) {
+ struct i2c_board_info info;
+ const u32 *reg;
+
+ reg = of_get_property(child, "reg", NULL);
+ if (!reg) {
+ printk(KERN_ERR "Could not find address for %s\n",
+ child->name);
+ continue;
+ }
+
+ memset(&info, 0, sizeof(info));
+ strlcpy(info.type, child->name, I2C_NAME_SIZE);
+ info.addr = *reg;
+
+ if (!i2c_new_device(adap, &info))
+ printk(KERN_ERR "Could not add i2c device %s.\n",
+ child->name);
+ }
+
+
dev_info(&ofdev->dev, "using %s mode\n",
dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [RFC] Non-numbered ibm iic driver
2008-06-29 3:20 [RFC] Non-numbered ibm iic driver Sean MacLennan
@ 2008-06-29 3:25 ` Jon Smirl
2008-06-29 3:43 ` Sean MacLennan
2008-06-29 18:52 ` Jon Loeliger
1 sibling, 1 reply; 5+ messages in thread
From: Jon Smirl @ 2008-06-29 3:25 UTC (permalink / raw)
To: Sean MacLennan; +Cc: linuxppc-dev
On 6/28/08, Sean MacLennan <smaclennan@pikatech.com> wrote:
> This is a patch to the ibm iic driver that uses the non-numbered
> i2c call and therefore does not need an index. Instead, it registers the
> ibm iic, then walks all the child nodes and adds them. This is required
> for new style drivers, old style drivers "just work".
Check out the code in drivers/of/of_i2c.c. Can you use it instead?
>
> The warp has both a new style driver (ad7414) and old style (eeprom)
> devices.
>
> This patch is completely function but not a complete patch (the index
> code is not needed for example). It is just for comment.
>
> The warp.dts needed for this to work is, I believe, in Josh's next tree.
>
> Cheers,
> Sean
>
> P.S. Do I need a signed-off-by for an RFC?
>
> Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>
> ---
>
> diff --git a/drivers/i2c/busses/i2c-ibm_iic.c b/drivers/i2c/busses/i2c-ibm_iic.c
> index 85dbf34..0ec6849 100644
> --- a/drivers/i2c/busses/i2c-ibm_iic.c
> +++ b/drivers/i2c/busses/i2c-ibm_iic.c
> @@ -753,7 +753,7 @@ static int __devinit iic_probe(struct ocp_device *ocp){
> */
> adap->nr = dev->idx >= 0 ? dev->idx : 0;
>
> - if ((ret = i2c_add_numbered_adapter(adap)) < 0) {
> + if ((ret = i2c_add_adapter(adap)) < 0) {
> printk(KERN_ERR "ibm-iic%d: failed to register i2c adapter\n",
> dev->idx);
> goto fail;
> @@ -874,6 +874,7 @@ static int __devinit iic_probe(struct of_device *ofdev,
> const struct of_device_id *match)
> {
> struct device_node *np = ofdev->node;
> + struct device_node *child;
> struct ibm_iic_private *dev;
> struct i2c_adapter *adap;
> const u32 *indexp, *freq;
> @@ -939,12 +940,33 @@ static int __devinit iic_probe(struct of_device *ofdev,
> adap->timeout = 1;
> adap->nr = dev->idx;
>
> - ret = i2c_add_numbered_adapter(adap);
> + ret = i2c_add_adapter(adap);
> if (ret < 0) {
> dev_err(&ofdev->dev, "failed to register i2c adapter\n");
> goto error_cleanup;
> }
>
> + for_each_child_of_node(np, child) {
> + struct i2c_board_info info;
> + const u32 *reg;
> +
> + reg = of_get_property(child, "reg", NULL);
> + if (!reg) {
> + printk(KERN_ERR "Could not find address for %s\n",
> + child->name);
> + continue;
> + }
> +
> + memset(&info, 0, sizeof(info));
> + strlcpy(info.type, child->name, I2C_NAME_SIZE);
> + info.addr = *reg;
> +
> + if (!i2c_new_device(adap, &info))
> + printk(KERN_ERR "Could not add i2c device %s.\n",
> + child->name);
> + }
> +
> +
> dev_info(&ofdev->dev, "using %s mode\n",
> dev->fast_mode ? "fast (400 kHz)" : "standard (100 kHz)");
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>
--
Jon Smirl
jonsmirl@gmail.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] Non-numbered ibm iic driver
2008-06-29 3:25 ` Jon Smirl
@ 2008-06-29 3:43 ` Sean MacLennan
2008-06-29 4:31 ` Grant Likely
0 siblings, 1 reply; 5+ messages in thread
From: Sean MacLennan @ 2008-06-29 3:43 UTC (permalink / raw)
To: Jon Smirl; +Cc: linuxppc-dev
On Sat, 28 Jun 2008 23:25:05 -0400
"Jon Smirl" <jonsmirl@gmail.com> wrote:
> On 6/28/08, Sean MacLennan <smaclennan@pikatech.com> wrote:
> > This is a patch to the ibm iic driver that uses the non-numbered
> > i2c call and therefore does not need an index. Instead, it
> > registers the ibm iic, then walks all the child nodes and adds
> > them. This is required for new style drivers, old style drivers
> > "just work".
>
> Check out the code in drivers/of/of_i2c.c. Can you use it instead?
Sure can. The for loop can be replaced with:
of_register_i2c_devices(adap, np);
I have tested it and it works. I guess it makes sense to put of_i2c.c
under drivers/of, but if it had been under drivers/i2c, I would have
noticed it ;)
But is this the way we want to go? I personally like it. It gets rid of
the index and gets rid of the i2c_register_board_info() from the
platform code.
Cheers,
Sean
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] Non-numbered ibm iic driver
2008-06-29 3:43 ` Sean MacLennan
@ 2008-06-29 4:31 ` Grant Likely
0 siblings, 0 replies; 5+ messages in thread
From: Grant Likely @ 2008-06-29 4:31 UTC (permalink / raw)
To: Sean MacLennan; +Cc: linuxppc-dev
On Sat, Jun 28, 2008 at 11:43:39PM -0400, Sean MacLennan wrote:
> On Sat, 28 Jun 2008 23:25:05 -0400
> "Jon Smirl" <jonsmirl@gmail.com> wrote:
>
> > On 6/28/08, Sean MacLennan <smaclennan@pikatech.com> wrote:
> > > This is a patch to the ibm iic driver that uses the non-numbered
> > > i2c call and therefore does not need an index. Instead, it
> > > registers the ibm iic, then walks all the child nodes and adds
> > > them. This is required for new style drivers, old style drivers
> > > "just work".
> >
> > Check out the code in drivers/of/of_i2c.c. Can you use it instead?
>
> Sure can. The for loop can be replaced with:
>
> of_register_i2c_devices(adap, np);
>
> I have tested it and it works. I guess it makes sense to put of_i2c.c
> under drivers/of, but if it had been under drivers/i2c, I would have
> noticed it ;)
>
> But is this the way we want to go? I personally like it. It gets rid of
> the index and gets rid of the i2c_register_board_info() from the
> platform code.
Oops, forgot to include the list on my first reply...
Yes, this is the way to go. I've got a patch that does the same thing
for SPI busses which I need to post for 2nd review.
g.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC] Non-numbered ibm iic driver
2008-06-29 3:20 [RFC] Non-numbered ibm iic driver Sean MacLennan
2008-06-29 3:25 ` Jon Smirl
@ 2008-06-29 18:52 ` Jon Loeliger
1 sibling, 0 replies; 5+ messages in thread
From: Jon Loeliger @ 2008-06-29 18:52 UTC (permalink / raw)
To: Sean MacLennan; +Cc: linuxppc-dev
Sean MacLennan wrote:
> P.S. Do I need a signed-off-by for an RFC?
>
> Signed-off-by: Sean MacLennan <smaclennan@pikatech.com>
> ---
Not usually. Some intentionally leave the S-o-b: off of
and RFC specifically to ensure that it stays RFC-ish and
doesn't slip into patchness.
jdl
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-06-29 18:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-29 3:20 [RFC] Non-numbered ibm iic driver Sean MacLennan
2008-06-29 3:25 ` Jon Smirl
2008-06-29 3:43 ` Sean MacLennan
2008-06-29 4:31 ` Grant Likely
2008-06-29 18:52 ` Jon Loeliger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).