public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Warren <swarren@wwwdotorg.org>
To: Doug Anderson <dianders@chromium.org>
Cc: Wolfram Sang <w.sang@pengutronix.de>,
	Simon Glass <sjg@chromium.org>,
	Naveen Krishna Chatradhi <ch.naveen@samsung.com>,
	Grant Likely <grant.likely@secretlab.ca>,
	Yuvaraj Kumar <yuvaraj.cd@gmail.com>,
	Ben Dooks <ben.dooks@codethink.co.uk>,
	u.kleine-koenig@pengutronix.de,
	Mark Brown <broonie@opensource.wolfsonmicro.com>,
	Girish Shivananjappa <girish.shivananjappa@linaro.org>,
	bhushan.r@samsung.com, sreekumar.c@samsung.com,
	Prashanth G <prashanth.g@samsung.com>,
	Olof Johansson <olof@lixom.net>,
	Daniel Kurtz <djkurtz@chromium.org>,
	Grant Grundler <grundler@chromium.org>,
	"Ben Dooks (embedded platforms)" <ben-linux@fluff.org>,
	Peter Korsgaard <peter.korsgaard@barco.com>,
	Guenter Roeck <linux@roeck-us.net>,
	Jean Delvare <khali@linux-fr.org>,
	David Daney <david.daney@cavium.com>,
	Axel Lin <axel.lin@gmail.com>,
	Stephen Warren <swarren@nvidia.com>,
	Barry Song <baohua.song@csr.com>,
	Guan Xuetao <gxt@mprc.pku.edu.cn>,
	linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 4/4] i2c-mux: i2c_add_mux_adapter() should use -1 for auto bus num
Date: Wed, 13 Feb 2013 14:09:08 -0700	[thread overview]
Message-ID: <511C00F4.4080708@wwwdotorg.org> (raw)
In-Reply-To: <1360778532-7480-4-git-send-email-dianders@chromium.org>

On 02/13/2013 11:02 AM, Doug Anderson wrote:
> The force_nr parameter to i2c_add_mux_adapter() uses 0 to signify that
> we don't want to force the bus number of the adapter.  This is
> non-ideal because:
> * 0 is actually a valid bus number to request
> * i2c_add_numbered_adapter() (which i2c_add_mux_adapter() calls) uses
>   -1 to mean the same thing.  That means extra logic in
>   i2c_add_mux_adapter().
> 
> Fix i2c_add_mux_adapter() to use -1 and update all mux drivers
> accordingly.
> 
> Signed-off-by: Doug Anderson <dianders@chromium.org>
> ---
> Notes:
> - If there's a good reason that force_nr uses 0 for auto then feel
>   free to drop this patch.  I've place it at the end of the series to
>   make it easy to just drop it.

IIRC (and I only vaguely do...) it's because:

> diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
> index 9f50ef0..301ed0b 100644
> --- a/drivers/i2c/muxes/i2c-mux-gpio.c
> +++ b/drivers/i2c/muxes/i2c-mux-gpio.c
> @@ -208,7 +208,7 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev)
>  	}
>  
>  	for (i = 0; i < mux->data.n_values; i++) {
> -		u32 nr = mux->data.base_nr ? (mux->data.base_nr + i) : 0;
> +		int nr = mux->data.base_nr ? (mux->data.base_nr + i) : -1;

Here, mux->data.base_nr is platform data (or copied directly from it),
and any field in a platform data struct stored in a global variable not
explicitly initialized would be 0, hence 0 would typically mean "no
explicit bus number desired". Since a mux can't exist without a parent
I2C bus, it's unlikely anyone would want a mux to be I2C bus 0, but
rather the parent to have that number.

  parent reply	other threads:[~2013-02-13 21:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-13 18:02 [PATCH v1 1/4] i2c: mux: Add i2c-arbitrator 'mux' driver Doug Anderson
2013-02-13 18:02 ` [PATCH v1 2/4] ARM: dts: Add i2c-arbitrator bus for exynos5250-snow Doug Anderson
2013-02-13 21:04   ` Stephen Warren
2013-02-14  0:38     ` Doug Anderson
2013-02-14  4:42       ` Stephen Warren
2013-02-13 18:02 ` [PATCH v1 3/4] ARM: dts: Add sbs-battery " Doug Anderson
2013-02-13 18:02 ` [PATCH v1 4/4] i2c-mux: i2c_add_mux_adapter() should use -1 for auto bus num Doug Anderson
2013-02-13 20:34   ` Guenter Roeck
2013-02-13 21:09   ` Stephen Warren [this message]
2013-02-14  7:15     ` Jean Delvare
2013-02-13 18:45 ` [PATCH v1 1/4] i2c: mux: Add i2c-arbitrator 'mux' driver Olof Johansson
2013-02-13 18:49   ` Olof Johansson
2013-02-13 21:02 ` Stephen Warren

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=511C00F4.4080708@wwwdotorg.org \
    --to=swarren@wwwdotorg.org \
    --cc=axel.lin@gmail.com \
    --cc=baohua.song@csr.com \
    --cc=ben-linux@fluff.org \
    --cc=ben.dooks@codethink.co.uk \
    --cc=bhushan.r@samsung.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=ch.naveen@samsung.com \
    --cc=david.daney@cavium.com \
    --cc=dianders@chromium.org \
    --cc=djkurtz@chromium.org \
    --cc=girish.shivananjappa@linaro.org \
    --cc=grant.likely@secretlab.ca \
    --cc=grundler@chromium.org \
    --cc=gxt@mprc.pku.edu.cn \
    --cc=khali@linux-fr.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=olof@lixom.net \
    --cc=peter.korsgaard@barco.com \
    --cc=prashanth.g@samsung.com \
    --cc=sjg@chromium.org \
    --cc=sreekumar.c@samsung.com \
    --cc=swarren@nvidia.com \
    --cc=u.kleine-koenig@pengutronix.de \
    --cc=w.sang@pengutronix.de \
    --cc=yuvaraj.cd@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox