[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20130214081558.5e3d636e@endymion.delvare>
Date: Thu, 14 Feb 2013 08:15:58 +0100
From: Jean Delvare <khali@...ux-fr.org>
To: Stephen Warren <swarren@...dotorg.org>
Cc: Doug Anderson <dianders@...omium.org>,
Wolfram Sang <w.sang@...gutronix.de>,
Simon Glass <sjg@...omium.org>,
Naveen Krishna Chatradhi <ch.naveen@...sung.com>,
Grant Likely <grant.likely@...retlab.ca>,
Yuvaraj Kumar <yuvaraj.cd@...il.com>,
Ben Dooks <ben.dooks@...ethink.co.uk>,
u.kleine-koenig@...gutronix.de,
Mark Brown <broonie@...nsource.wolfsonmicro.com>,
Girish Shivananjappa <girish.shivananjappa@...aro.org>,
bhushan.r@...sung.com, sreekumar.c@...sung.com,
Prashanth G <prashanth.g@...sung.com>,
Olof Johansson <olof@...om.net>,
Daniel Kurtz <djkurtz@...omium.org>,
Grant Grundler <grundler@...omium.org>,
"Ben Dooks (embedded platforms)" <ben-linux@...ff.org>,
Peter Korsgaard <peter.korsgaard@...co.com>,
Guenter Roeck <linux@...ck-us.net>,
David Daney <david.daney@...ium.com>,
Axel Lin <axel.lin@...il.com>,
Stephen Warren <swarren@...dia.com>,
Barry Song <baohua.song@....com>,
Guan Xuetao <gxt@...c.pku.edu.cn>, linux-i2c@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 4/4] i2c-mux: i2c_add_mux_adapter() should use -1 for
auto bus num
On Wed, 13 Feb 2013 14:09:08 -0700, Stephen Warren wrote:
> 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@...omium.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.
Yes, as I recall this is exactly the reason why the current code is the
way it is.
--
Jean Delvare
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists