All of lore.kernel.org
 help / color / mirror / Atom feed
From: Karol Lewandowski <k.lewandowsk@samsung.com>
To: w.sang@pengutronix.de, hskinnemoen@gmail.com,
	linux@arm.linux.org.uk, Rade Bozic <rade.bozic.ext@nsn.com>
Cc: Karol Lewandowski <k.lewandowsk@samsung.com>,
	ben-linux@fluff.org, khali@linux-fr.org,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	dirk.brandewie@gmail.com, bigeasy@linutronix.de,
	m.szyprowski@samsung.com, grant.likely@secretlab.ca,
	kyungmin.park@samsung.com,
	David Daney <ddaney@caviumnetworks.com>
Subject: Re: [PATCH 2/2] i2c: Dynamically assign adapter id if it wasn't explictly specified
Date: Thu, 22 Mar 2012 16:28:50 +0100	[thread overview]
Message-ID: <4F6B4532.7090806@samsung.com> (raw)
In-Reply-To: <1331900343-6743-3-git-send-email-k.lewandowsk@samsung.com>

On 16.03.2012 13:19, Karol Lewandowski wrote:

>> Commit 488bf314b ("i2c: Allow i2c_add_numbered_adapter() to assign a
>> bus id") reworked i2c_add_numbered_adapter() to call i2c_add_adapter()
>> if requested bus was -1.

>> This allows to simplify driver's initialization procedure as it allows

>> static and dynamic adapter id registration using one function.
>> 
>> This patch updates few more drivers (missed out in original patch) to
>> use this functionality.
>

> [ I must have lost actual problem description while rewording
>  message itself... ]
>
> Problem arises when multiple drivers (or multiple instances
> of one driver) try to assume the same fixed bus number (0).
>
> This simply causes i2c_add_numbered_bus() to fail.
> Leaving -1 works perfectly, as registration function switches
> to dynamic id registration.

>> Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com>
>> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
>> ---
>>  drivers/i2c/busses/i2c-gpio.c         |    7 +------
>>  drivers/i2c/busses/i2c-octeon.c       |    2 +-
>>  drivers/i2c/busses/i2c-pca-platform.c |    2 +-
>>  drivers/i2c/busses/i2c-versatile.c    |    9 ++-------
>>  4 files changed, 5 insertions(+), 15 deletions(-)


Dear Haavard, Rade, Wolfram and Russel

Could you review following changes for gpio, octeon, pca-platform
and versatile i2c controller drivers (for which you are, or were,
maintainers)?

Grant requested explicit Ack to get this merged.

Thanks!

> 
> diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
> index a651779..50a2a94 100644
> --- a/drivers/i2c/busses/i2c-gpio.c
> +++ b/drivers/i2c/busses/i2c-gpio.c
> @@ -144,12 +144,7 @@ static int __devinit i2c_gpio_probe(struct platform_device *pdev)
>  	adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
>  	adap->dev.parent = &pdev->dev;
>  
> -	/*
> -	 * If "dev->id" is negative we consider it as zero.
> -	 * The reason to do so is to avoid sysfs names that only make
> -	 * sense when there are multiple adapters.
> -	 */
> -	adap->nr = (pdev->id != -1) ? pdev->id : 0;
> +	adap->nr = pdev->id;
>  	ret = i2c_bit_add_numbered_bus(adap);
>  	if (ret)
>  		goto err_add_bus;
> diff --git a/drivers/i2c/busses/i2c-octeon.c b/drivers/i2c/busses/i2c-octeon.c
> index ee139a5..8470232 100644
> --- a/drivers/i2c/busses/i2c-octeon.c
> +++ b/drivers/i2c/busses/i2c-octeon.c
> @@ -581,7 +581,7 @@ static int __devinit octeon_i2c_probe(struct platform_device *pdev)
>  
>  	i2c->adap = octeon_i2c_ops;
>  	i2c->adap.dev.parent = &pdev->dev;
> -	i2c->adap.nr = pdev->id >= 0 ? pdev->id : 0;
> +	i2c->adap.nr = pdev->id;
>  	i2c_set_adapdata(&i2c->adap, i2c);
>  	platform_set_drvdata(pdev, i2c);
>  
> diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
> index 2adbf1a..675878f 100644
> --- a/drivers/i2c/busses/i2c-pca-platform.c
> +++ b/drivers/i2c/busses/i2c-pca-platform.c
> @@ -171,7 +171,7 @@ static int __devinit i2c_pca_pf_probe(struct platform_device *pdev)
>  	i2c->io_size = resource_size(res);
>  	i2c->irq = irq;
>  
> -	i2c->adap.nr = pdev->id >= 0 ? pdev->id : 0;
> +	i2c->adap.nr = pdev->id;
>  	i2c->adap.owner = THIS_MODULE;
>  	snprintf(i2c->adap.name, sizeof(i2c->adap.name),
>  		 "PCA9564/PCA9665 at 0x%08lx",
> diff --git a/drivers/i2c/busses/i2c-versatile.c b/drivers/i2c/busses/i2c-versatile.c
> index 6055601..9458568 100644
> --- a/drivers/i2c/busses/i2c-versatile.c
> +++ b/drivers/i2c/busses/i2c-versatile.c
> @@ -102,13 +102,8 @@ static int i2c_versatile_probe(struct platform_device *dev)
>  	i2c->algo = i2c_versatile_algo;
>  	i2c->algo.data = i2c;
>  
> -	if (dev->id >= 0) {
> -		/* static bus numbering */
> -		i2c->adap.nr = dev->id;
> -		ret = i2c_bit_add_numbered_bus(&i2c->adap);
> -	} else
> -		/* dynamic bus numbering */
> -		ret = i2c_bit_add_bus(&i2c->adap);
> +	i2c->adap.nr = dev->id;
> +	ret = i2c_bit_add_numbered_bus(&i2c->adap);
>  	if (ret >= 0) {
>  		platform_set_drvdata(dev, i2c);
>  		return 0;



-- 
Karol Lewandowski | Samsung Poland R&D Center | Linux/Platform

  reply	other threads:[~2012-03-22 15:28 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-16 12:19 [PATCH 0/2] i2c: Don't assume bus nr 0 if none was specified Karol Lewandowski
     [not found] ` <1331900343-6743-1-git-send-email-k.lewandowsk-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-16 12:19   ` [PATCH 1/2] i2c-pxa: Drop leftover comment Karol Lewandowski
2012-03-16 12:19     ` Karol Lewandowski
2012-03-16 12:19   ` [PATCH 2/2] i2c: Dynamically assign adapter id if it wasn't explictly specified Karol Lewandowski
2012-03-16 12:19     ` Karol Lewandowski
2012-03-22 15:28     ` Karol Lewandowski [this message]
     [not found]       ` <4F6B4532.7090806-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-22 16:11         ` Russell King - ARM Linux
2012-03-22 16:11           ` Russell King - ARM Linux
2012-03-22 17:03           ` Karol Lewandowski
2012-03-22 16:58         ` David Daney
2012-03-22 16:58           ` David Daney
     [not found]           ` <4F6B5A22.1090204-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
2012-03-22 17:48             ` Karol Lewandowski
2012-03-22 17:48               ` Karol Lewandowski
     [not found]               ` <4F6B65D0.1030506-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-22 18:07                 ` David Daney
2012-03-22 18:07                   ` David Daney
2012-03-22 21:47         ` Wolfram Sang
2012-03-22 21:47           ` Wolfram Sang
     [not found]           ` <20120322214714.GA24684-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-03-26  9:14             ` Karol Lewandowski
2012-03-26  9:14               ` Karol Lewandowski
2012-03-16 12:27   ` [PATCH 0/2] i2c: Don't assume bus nr 0 if none was specified Karol Lewandowski
2012-03-16 12:27     ` Karol Lewandowski
     [not found]     ` <4F6331AF.3010007-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2012-03-17 10:50       ` Grant Likely
2012-03-17 10:50         ` Grant Likely
  -- strict thread matches above, loose matches on Subject: below --
2012-03-27  9:10 [PATCH v2 " Karol Lewandowski
2012-03-27  9:10 ` [PATCH 2/2] i2c: Dynamically assign adapter id if it wasn't explictly specified Karol Lewandowski

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=4F6B4532.7090806@samsung.com \
    --to=k.lewandowsk@samsung.com \
    --cc=ben-linux@fluff.org \
    --cc=bigeasy@linutronix.de \
    --cc=ddaney@caviumnetworks.com \
    --cc=dirk.brandewie@gmail.com \
    --cc=grant.likely@secretlab.ca \
    --cc=hskinnemoen@gmail.com \
    --cc=khali@linux-fr.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=m.szyprowski@samsung.com \
    --cc=rade.bozic.ext@nsn.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.