All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c-gpio: Add support for new-style clients
@ 2007-06-12 15:43 Atsushi Nemoto
  2007-06-13 11:15 ` Haavard Skinnemoen
  2007-06-14  6:24 ` Jean Delvare
  0 siblings, 2 replies; 5+ messages in thread
From: Atsushi Nemoto @ 2007-06-12 15:43 UTC (permalink / raw)
  To: Haavard Skinnemoen; +Cc: linux-kernel, i2c, khali

Use i2c_bit_add_numbered_bus() if device id specified, so that the
i2c-gpio adapter works well with new-style pre-declared devices.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index a7dd546..8a62c26 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -142,7 +142,10 @@ static int __init i2c_gpio_probe(struct platform_device *pdev)
 	adap->algo_data = bit_data;
 	adap->dev.parent = &pdev->dev;
 
-	ret = i2c_bit_add_bus(adap);
+	if (pdev->id == -1)
+		ret = i2c_bit_add_bus(adap);
+	else
+		ret = i2c_bit_add_numbered_bus(adap);
 	if (ret)
 		goto err_add_bus;
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] i2c-gpio: Add support for new-style clients
  2007-06-12 15:43 [PATCH] i2c-gpio: Add support for new-style clients Atsushi Nemoto
@ 2007-06-13 11:15 ` Haavard Skinnemoen
  2007-06-14  6:24 ` Jean Delvare
  1 sibling, 0 replies; 5+ messages in thread
From: Haavard Skinnemoen @ 2007-06-13 11:15 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: linux-kernel, i2c, khali

On Wed, 13 Jun 2007 00:43:16 +0900 (JST)
Atsushi Nemoto <anemo@mba.ocn.ne.jp> wrote:

> Use i2c_bit_add_numbered_bus() if device id specified, so that the
> i2c-gpio adapter works well with new-style pre-declared devices.
> 
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>

Makes sense to me. I haven't got any test setup with multiple i2c
busses, but using the platform_device id seems like the obvious way to
number the busses from a board developer's point of view.

Acked-by: Haavard Skinnemoen <hskinnemoen@atmel.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] i2c-gpio: Add support for new-style clients
  2007-06-12 15:43 [PATCH] i2c-gpio: Add support for new-style clients Atsushi Nemoto
  2007-06-13 11:15 ` Haavard Skinnemoen
@ 2007-06-14  6:24 ` Jean Delvare
  2007-06-14  6:40   ` Atsushi Nemoto
  1 sibling, 1 reply; 5+ messages in thread
From: Jean Delvare @ 2007-06-14  6:24 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: Haavard Skinnemoen, linux-kernel, i2c

Hi Atsushi,

On Wed, 13 Jun 2007 00:43:16 +0900 (JST), Atsushi Nemoto wrote:
> Use i2c_bit_add_numbered_bus() if device id specified, so that the
> i2c-gpio adapter works well with new-style pre-declared devices.
> 
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> ---
> diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
> index a7dd546..8a62c26 100644
> --- a/drivers/i2c/busses/i2c-gpio.c
> +++ b/drivers/i2c/busses/i2c-gpio.c
> @@ -142,7 +142,10 @@ static int __init i2c_gpio_probe(struct platform_device *pdev)
>  	adap->algo_data = bit_data;
>  	adap->dev.parent = &pdev->dev;
>  
> -	ret = i2c_bit_add_bus(adap);
> +	if (pdev->id == -1)
> +		ret = i2c_bit_add_bus(adap);
> +	else
> +		ret = i2c_bit_add_numbered_bus(adap);
>  	if (ret)
>  		goto err_add_bus;
>  

This isn't sufficient. Before you call i2c_bit_add_numbered_bus(adap),
you are supposed to set adap->nr to the desired i2c adapter number.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] i2c-gpio: Add support for new-style clients
  2007-06-14  6:24 ` Jean Delvare
@ 2007-06-14  6:40   ` Atsushi Nemoto
  2007-06-15 15:59     ` Jean Delvare
  0 siblings, 1 reply; 5+ messages in thread
From: Atsushi Nemoto @ 2007-06-14  6:40 UTC (permalink / raw)
  To: khali; +Cc: hskinnemoen, linux-kernel, i2c

On Thu, 14 Jun 2007 08:24:17 +0200, Jean Delvare <khali@linux-fr.org> wrote:
> > +	if (pdev->id == -1)
> > +		ret = i2c_bit_add_bus(adap);
> > +	else
> > +		ret = i2c_bit_add_numbered_bus(adap);
> >  	if (ret)
> >  		goto err_add_bus;
> >  
> 
> This isn't sufficient. Before you call i2c_bit_add_numbered_bus(adap),
> you are supposed to set adap->nr to the desired i2c adapter number.

Oh, indeed.  That worked for me just I only used bus number 0.
Here is a revised patch.


Subject: [PATCH] i2c-gpio: Add support for new-style clients (take 2)

Use i2c_bit_add_numbered_bus() if platform_device id specified, so
that the i2c-gpio adapter works well with new-style pre-declared
devices.

Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
---
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index a7dd546..88c5735 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -142,7 +142,12 @@ static int __init i2c_gpio_probe(struct platform_device *pdev)
 	adap->algo_data = bit_data;
 	adap->dev.parent = &pdev->dev;
 
-	ret = i2c_bit_add_bus(adap);
+	if (pdev->id == -1)
+		ret = i2c_bit_add_bus(adap);
+	else {
+		adap->nr = pdev->id;
+		ret = i2c_bit_add_numbered_bus(adap);
+	}
 	if (ret)
 		goto err_add_bus;
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] i2c-gpio: Add support for new-style clients
  2007-06-14  6:40   ` Atsushi Nemoto
@ 2007-06-15 15:59     ` Jean Delvare
  0 siblings, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2007-06-15 15:59 UTC (permalink / raw)
  To: Atsushi Nemoto; +Cc: hskinnemoen, linux-kernel, i2c

On Thu, 14 Jun 2007 15:40:46 +0900 (JST), Atsushi Nemoto wrote:
> On Thu, 14 Jun 2007 08:24:17 +0200, Jean Delvare <khali@linux-fr.org> wrote:
> > > +	if (pdev->id == -1)
> > > +		ret = i2c_bit_add_bus(adap);
> > > +	else
> > > +		ret = i2c_bit_add_numbered_bus(adap);
> > >  	if (ret)
> > >  		goto err_add_bus;
> > >  
> > 
> > This isn't sufficient. Before you call i2c_bit_add_numbered_bus(adap),
> > you are supposed to set adap->nr to the desired i2c adapter number.
> 
> Oh, indeed.  That worked for me just I only used bus number 0.
> Here is a revised patch.
> 
> 
> Subject: [PATCH] i2c-gpio: Add support for new-style clients (take 2)
> 
> Use i2c_bit_add_numbered_bus() if platform_device id specified, so
> that the i2c-gpio adapter works well with new-style pre-declared
> devices.
> 
> Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
> ---
> diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
> index a7dd546..88c5735 100644
> --- a/drivers/i2c/busses/i2c-gpio.c
> +++ b/drivers/i2c/busses/i2c-gpio.c
> @@ -142,7 +142,12 @@ static int __init i2c_gpio_probe(struct platform_device *pdev)
>  	adap->algo_data = bit_data;
>  	adap->dev.parent = &pdev->dev;
>  
> -	ret = i2c_bit_add_bus(adap);
> +	if (pdev->id == -1)
> +		ret = i2c_bit_add_bus(adap);
> +	else {
> +		adap->nr = pdev->id;
> +		ret = i2c_bit_add_numbered_bus(adap);
> +	}
>  	if (ret)
>  		goto err_add_bus;
>  

That's better. Patch applied, thanks.

-- 
Jean Delvare

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-06-15 15:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-12 15:43 [PATCH] i2c-gpio: Add support for new-style clients Atsushi Nemoto
2007-06-13 11:15 ` Haavard Skinnemoen
2007-06-14  6:24 ` Jean Delvare
2007-06-14  6:40   ` Atsushi Nemoto
2007-06-15 15:59     ` Jean Delvare

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.