* [PATCH] Make i2c-mpc driver use i2c_add_numbered_adapter
@ 2007-05-14 19:11 Grant Likely
2007-05-14 19:32 ` Grant Likely
2007-05-15 13:26 ` [i2c] " Jean Delvare
0 siblings, 2 replies; 9+ messages in thread
From: Grant Likely @ 2007-05-14 19:11 UTC (permalink / raw)
To: David Brownell, rtc-linux, linuxppc-dev, i2c, James Chapman,
Sylvain Munaut
Move the i2c-mpc driver over to using the new i2c infrastructure.
Specifically, it now uses i2c_add_numberd_adapter so that the bus number
can be determined ahead of time and used to register i2c clients before
the bus is instantiated.
Tested on an MPC5200 based board
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
---
This patch will need to be tested to make sure it does not break any 8xxx
board ports.
Work still to be done (in another patch): support for pulling i2c client
registrations out of the device tree.
drivers/i2c/busses/i2c-mpc.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
index c6b6898..a769efc 100644
--- a/drivers/i2c/busses/i2c-mpc.c
+++ b/drivers/i2c/busses/i2c-mpc.c
@@ -327,9 +327,10 @@ static int fsl_i2c_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, i2c);
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_adapter(&i2c->adap)) < 0) {
+ if ((result = i2c_add_numbered_adapter(&i2c->adap)) < 0) {
printk(KERN_ERR "i2c-mpc - failed to add adapter\n");
goto fail_add;
}
^ permalink raw reply related [flat|nested] 9+ messages in thread* Re: [PATCH] Make i2c-mpc driver use i2c_add_numbered_adapter
2007-05-14 19:11 [PATCH] Make i2c-mpc driver use i2c_add_numbered_adapter Grant Likely
@ 2007-05-14 19:32 ` Grant Likely
2007-05-15 13:26 ` [i2c] " Jean Delvare
1 sibling, 0 replies; 9+ messages in thread
From: Grant Likely @ 2007-05-14 19:32 UTC (permalink / raw)
To: David Brownell, rtc-linux, linuxppc-dev, i2c, James Chapman,
Sylvain Munaut
On 5/14/07, Grant Likely <grant.likely@secretlab.ca> wrote:
> Work still to be done (in another patch): support for pulling i2c client
> registrations out of the device tree.
I had also fogotten about Scott Woods patches from last Nov. which
take care of this.
g.
--
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [i2c] [PATCH] Make i2c-mpc driver use i2c_add_numbered_adapter
2007-05-14 19:11 [PATCH] Make i2c-mpc driver use i2c_add_numbered_adapter Grant Likely
2007-05-14 19:32 ` Grant Likely
@ 2007-05-15 13:26 ` Jean Delvare
2007-05-15 15:28 ` David Brownell
1 sibling, 1 reply; 9+ messages in thread
From: Jean Delvare @ 2007-05-15 13:26 UTC (permalink / raw)
To: Grant Likely; +Cc: rtc-linux, James Chapman, David Brownell, linuxppc-dev, i2c
On Mon, 14 May 2007 13:11:23 -0600, Grant Likely wrote:
> Move the i2c-mpc driver over to using the new i2c infrastructure.
> Specifically, it now uses i2c_add_numberd_adapter so that the bus number
i2c_add_numbered_adapter (missing e)
> can be determined ahead of time and used to register i2c clients before
> the bus is instantiated.
>
> Tested on an MPC5200 based board
>
> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Jean Delvare <khali@linux-fr.org>
> ---
> This patch will need to be tested to make sure it does not break any 8xxx
> board ports.
>
> Work still to be done (in another patch): support for pulling i2c client
> registrations out of the device tree.
>
> drivers/i2c/busses/i2c-mpc.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c
> index c6b6898..a769efc 100644
> --- a/drivers/i2c/busses/i2c-mpc.c
> +++ b/drivers/i2c/busses/i2c-mpc.c
> @@ -327,9 +327,10 @@ static int fsl_i2c_probe(struct platform_device *pdev)
> platform_set_drvdata(pdev, i2c);
>
> 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_adapter(&i2c->adap)) < 0) {
> + if ((result = i2c_add_numbered_adapter(&i2c->adap)) < 0) {
> printk(KERN_ERR "i2c-mpc - failed to add adapter\n");
> goto fail_add;
> }
--
Jean Delvare
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [i2c] [PATCH] Make i2c-mpc driver use i2c_add_numbered_adapter
2007-05-15 13:26 ` [i2c] " Jean Delvare
@ 2007-05-15 15:28 ` David Brownell
2007-05-15 15:51 ` Grant Likely
2007-05-16 19:15 ` Scott Wood
0 siblings, 2 replies; 9+ messages in thread
From: David Brownell @ 2007-05-15 15:28 UTC (permalink / raw)
To: Jean Delvare, Grant Likely; +Cc: linuxppc-dev, i2c, rtc-linux, James Chapman
On Tuesday 15 May 2007, Jean Delvare wrote:
> On Mon, 14 May 2007 13:11:23 -0600, Grant Likely wrote:
> > --- a/drivers/i2c/busses/i2c-mpc.c
> > +++ b/drivers/i2c/busses/i2c-mpc.c
> > @@ -327,9 +327,10 @@ static int fsl_i2c_probe(struct platform_device *pdev)
> > platform_set_drvdata(pdev, i2c);
> >
> > i2c->adap = mpc_ops;
> > + i2c->adap.nr = pdev->id;
By the way: mpc_ops is a static i2c_adapter, so given that
the reason for using pdev->id that way was that there might
be more than one such platform device ... shouldn't allocation
of the adapter be moved into allocation of the "i2c->" object?
Or at least, add a check to ensure that the static mpc_ops
structure isn't in use before progressing this probe().
- Dave
> > i2c_set_adapdata(&i2c->adap, i2c);
> > i2c->adap.dev.parent = &pdev->dev;
> > - if ((result = i2c_add_adapter(&i2c->adap)) < 0) {
> > + if ((result = i2c_add_numbered_adapter(&i2c->adap)) < 0) {
> > printk(KERN_ERR "i2c-mpc - failed to add adapter\n");
> > goto fail_add;
> > }
>
> --
> Jean Delvare
>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [i2c] [PATCH] Make i2c-mpc driver use i2c_add_numbered_adapter
2007-05-15 15:28 ` David Brownell
@ 2007-05-15 15:51 ` Grant Likely
2007-05-15 16:05 ` David Brownell
2007-05-16 19:15 ` Scott Wood
1 sibling, 1 reply; 9+ messages in thread
From: Grant Likely @ 2007-05-15 15:51 UTC (permalink / raw)
To: David Brownell; +Cc: rtc-linux, James Chapman, linuxppc-dev, i2c, Jean Delvare
On 5/15/07, David Brownell <david-b@pacbell.net> wrote:
> On Tuesday 15 May 2007, Jean Delvare wrote:
> > On Mon, 14 May 2007 13:11:23 -0600, Grant Likely wrote:
>
> > > --- a/drivers/i2c/busses/i2c-mpc.c
> > > +++ b/drivers/i2c/busses/i2c-mpc.c
> > > @@ -327,9 +327,10 @@ static int fsl_i2c_probe(struct platform_device *pdev)
> > > platform_set_drvdata(pdev, i2c);
> > >
> > > i2c->adap = mpc_ops;
> > > + i2c->adap.nr = pdev->id;
>
> By the way: mpc_ops is a static i2c_adapter, so given that
> the reason for using pdev->id that way was that there might
> be more than one such platform device ... shouldn't allocation
> of the adapter be moved into allocation of the "i2c->" object?
Take another look; this is a funny quirk of the driver. The
assignment is 'i2c->adap = mpc_ops'; not 'i2c->adap = &mpc_ops'. And
in struct mpc_i2c, the field is declared as 'struct i2c_adapter adap',
not 'struct i2c_adapter *adap'. The driver instance gets a copy of
the mpc_ops structure to initialize it, not a pointer to the staticly
defined structure. I got bitten by the same thing when I was looking
at the code.
Not to mention that mpc_ops is poorly named.
Cheers,
g.
--
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [i2c] [PATCH] Make i2c-mpc driver use i2c_add_numbered_adapter
2007-05-15 15:51 ` Grant Likely
@ 2007-05-15 16:05 ` David Brownell
2007-05-16 18:25 ` Jean Delvare
0 siblings, 1 reply; 9+ messages in thread
From: David Brownell @ 2007-05-15 16:05 UTC (permalink / raw)
To: Grant Likely; +Cc: rtc-linux, James Chapman, linuxppc-dev, i2c, Jean Delvare
On Tuesday 15 May 2007, Grant Likely wrote:
>
> Take another look; this is a funny quirk of the driver. The
> assignment is 'i2c->adap = mpc_ops'; not 'i2c->adap = &mpc_ops'. And
> in struct mpc_i2c, the field is declared as 'struct i2c_adapter adap',
> not 'struct i2c_adapter *adap'. The driver instance gets a copy of
> the mpc_ops structure to initialize it, not a pointer to the staticly
> defined structure. I got bitten by the same thing when I was looking
> at the code.
I see -- you're right. That "template" idiom is a good one to get
rid of, FWIW ... not only is it confusing, but it also wastes space.
- Dave
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [i2c] [PATCH] Make i2c-mpc driver use i2c_add_numbered_adapter
2007-05-15 16:05 ` David Brownell
@ 2007-05-16 18:25 ` Jean Delvare
2007-05-16 18:38 ` Grant Likely
0 siblings, 1 reply; 9+ messages in thread
From: Jean Delvare @ 2007-05-16 18:25 UTC (permalink / raw)
To: David Brownell; +Cc: rtc-linux, James Chapman, linuxppc-dev, i2c
On Tue, 15 May 2007 09:05:20 -0700, David Brownell wrote:
> On Tuesday 15 May 2007, Grant Likely wrote:
> >
> > Take another look; this is a funny quirk of the driver. The
> > assignment is 'i2c->adap = mpc_ops'; not 'i2c->adap = &mpc_ops'. And
> > in struct mpc_i2c, the field is declared as 'struct i2c_adapter adap',
> > not 'struct i2c_adapter *adap'. The driver instance gets a copy of
> > the mpc_ops structure to initialize it, not a pointer to the staticly
> > defined structure. I got bitten by the same thing when I was looking
> > at the code.
>
> I see -- you're right. That "template" idiom is a good one to get
> rid of, FWIW ... not only is it confusing, but it also wastes space.
Well, maybe you can submit a patch fixing this one?
--
Jean Delvare
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [i2c] [PATCH] Make i2c-mpc driver use i2c_add_numbered_adapter
2007-05-16 18:25 ` Jean Delvare
@ 2007-05-16 18:38 ` Grant Likely
0 siblings, 0 replies; 9+ messages in thread
From: Grant Likely @ 2007-05-16 18:38 UTC (permalink / raw)
To: Jean Delvare; +Cc: rtc-linux, James Chapman, David Brownell, linuxppc-dev, i2c
On 5/16/07, Jean Delvare <khali@linux-fr.org> wrote:
> On Tue, 15 May 2007 09:05:20 -0700, David Brownell wrote:
> > On Tuesday 15 May 2007, Grant Likely wrote:
> > >
> > > Take another look; this is a funny quirk of the driver. The
> > > assignment is 'i2c->adap = mpc_ops'; not 'i2c->adap = &mpc_ops'. And
> > > in struct mpc_i2c, the field is declared as 'struct i2c_adapter adap',
> > > not 'struct i2c_adapter *adap'. The driver instance gets a copy of
> > > the mpc_ops structure to initialize it, not a pointer to the staticly
> > > defined structure. I got bitten by the same thing when I was looking
> > > at the code.
> >
> > I see -- you're right. That "template" idiom is a good one to get
> > rid of, FWIW ... not only is it confusing, but it also wastes space.
>
> Well, maybe you can submit a patch fixing this one?
Heh, oops.
I had replied to David saying that I would do this bit; but I forgot
to cc the list.
I'll take care of this.
Cheers,
g.
--
Grant Likely, B.Sc. P.Eng.
Secret Lab Technologies Ltd.
grant.likely@secretlab.ca
(403) 399-0195
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [i2c] [PATCH] Make i2c-mpc driver use i2c_add_numbered_adapter
2007-05-15 15:28 ` David Brownell
2007-05-15 15:51 ` Grant Likely
@ 2007-05-16 19:15 ` Scott Wood
1 sibling, 0 replies; 9+ messages in thread
From: Scott Wood @ 2007-05-16 19:15 UTC (permalink / raw)
To: David Brownell; +Cc: rtc-linux, linuxppc-dev, i2c, Jean Delvare
David Brownell wrote:
> On Tuesday 15 May 2007, Jean Delvare wrote:
>
>>On Mon, 14 May 2007 13:11:23 -0600, Grant Likely wrote:
>
>
>>>--- a/drivers/i2c/busses/i2c-mpc.c
>>>+++ b/drivers/i2c/busses/i2c-mpc.c
>>>@@ -327,9 +327,10 @@ static int fsl_i2c_probe(struct platform_device *pdev)
>>> platform_set_drvdata(pdev, i2c);
>>>
>>> i2c->adap = mpc_ops;
>>>+ i2c->adap.nr = pdev->id;
>
>
> By the way: mpc_ops is a static i2c_adapter, so given that
> the reason for using pdev->id that way was that there might
> be more than one such platform device ... shouldn't allocation
> of the adapter be moved into allocation of the "i2c->" object?
>
> Or at least, add a check to ensure that the static mpc_ops
> structure isn't in use before progressing this probe().
The mpc_ops struct is only used as a template; it gets copied into
i2c->adap for each adapter instance.
-Scott
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2007-05-16 19:23 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-14 19:11 [PATCH] Make i2c-mpc driver use i2c_add_numbered_adapter Grant Likely
2007-05-14 19:32 ` Grant Likely
2007-05-15 13:26 ` [i2c] " Jean Delvare
2007-05-15 15:28 ` David Brownell
2007-05-15 15:51 ` Grant Likely
2007-05-15 16:05 ` David Brownell
2007-05-16 18:25 ` Jean Delvare
2007-05-16 18:38 ` Grant Likely
2007-05-16 19:15 ` Scott Wood
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).