From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Michael Lawnick <ml.lawnick-Mmb7MZpHnFY@public.gmane.org>
Cc: Linux I2C <linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Rodolfo Giometti
<giometti-AVVDYK/kqiJWk0Htik3J/w@public.gmane.org>
Subject: Re: [PATCH v2 2/2] i2c: Multiplexed I2C bus multiplexer driver pca954x
Date: Sun, 13 Jun 2010 14:11:22 +0200 [thread overview]
Message-ID: <20100613141122.1d5b1423@hyperion.delvare> (raw)
In-Reply-To: <4BE01795.1090605-Mmb7MZpHnFY@public.gmane.org>
Hi Michael,
I just hit a bug...
On Tue, 04 May 2010 14:48:21 +0200, Michael Lawnick wrote:
> +static int pca954x_select_chan(struct i2c_adapter *adap,
> + void *client, u32 chan)
> +{
> + struct pca954x *data = i2c_get_clientdata(client);
> + const struct chip_desc *chip = &chips[data->type];
> + u8 regval;
> + int ret = 0;
> +
> + /* we make switches look like muxes, not sure how to be smarter */
> + if (chip->muxtype == pca954x_ismux)
> + regval = chan | chip->enable;
> + else
> + regval = 1 << chan;
> +
> + /* Only select the channel if its different from the last channel */
> + if (data->last_chan != chan) {
That's not right. data->last_chan is 0 after initialization or
deselection, but selecting channel 0 is valid and must be possible.
So you either want to use a different initialization value (e.g. 0xff)
or store the register value in data->last_chan instead of the channel
number. I went for the latter.
> + ret = pca954x_reg_write(adap, client, regval);
> + data->last_chan = chan;
> + }
> +
> + return ret;
> +}
--
Jean Delvare
next prev parent reply other threads:[~2010-06-13 12:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-04 12:46 [PATCH v2 1/2] i2c: Multiplexed I2C bus core support Michael Lawnick
[not found] ` <4BE01741.1010909-Mmb7MZpHnFY@public.gmane.org>
2010-05-04 12:48 ` [PATCH v2 2/2] i2c: Multiplexed I2C bus multiplexer driver pca954x Michael Lawnick
[not found] ` <4BE01795.1090605-Mmb7MZpHnFY@public.gmane.org>
2010-05-04 12:52 ` Rodolfo Giometti
2010-06-09 16:41 ` Jean Delvare
[not found] ` <20100609184143.06488f2f-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-06-10 10:15 ` Michael Lawnick
2010-06-13 12:11 ` Jean Delvare [this message]
[not found] ` <20100613141122.1d5b1423-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-06-14 9:09 ` Michael Lawnick
2010-05-04 12:52 ` [PATCH v2 1/2] i2c: Multiplexed I2C bus core support Rodolfo Giometti
2010-05-17 7:36 ` Michael Lawnick
[not found] ` <4BF0F200.5090604-Mmb7MZpHnFY@public.gmane.org>
2010-05-17 8:15 ` Jean Delvare
2010-06-10 13:24 ` Jean Delvare
[not found] ` <20100610152411.5497461c-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-06-11 6:31 ` Michael Lawnick
[not found] ` <4C11D85F.7010604-Mmb7MZpHnFY@public.gmane.org>
2010-06-11 9:40 ` Jean Delvare
[not found] ` <20100611114003.01c15f62-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2010-06-15 8:53 ` Michael Lawnick
2010-06-15 8:52 ` Michael Lawnick
[not found] ` <4C173F61.8000007-Mmb7MZpHnFY@public.gmane.org>
2010-06-15 9:00 ` Jean Delvare
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=20100613141122.1d5b1423@hyperion.delvare \
--to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
--cc=giometti-AVVDYK/kqiJWk0Htik3J/w@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=ml.lawnick-Mmb7MZpHnFY@public.gmane.org \
/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;
as well as URLs for NNTP newsgroup(s).