linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Petri Gynther <pgynther-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Cc: Rodolfo Giometti <giometti-k2GhghHVRtY@public.gmane.org>,
	Kumar Gala
	<galak-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] pca954x: Initialize the mux to disconnected state in pca954x_probe()
Date: Sat, 18 Jun 2011 10:47:32 +0200	[thread overview]
Message-ID: <20110618104732.62a19129@endymion.delvare> (raw)
In-Reply-To: <20110618005949.2F442E0866-z1f3I2EsBvXHt/MElyovVYaSKrA+ACpX0E9HWUfgJXw@public.gmane.org>

On Fri, 17 Jun 2011 18:00:00 -0700, Petri Gynther wrote:
> pca954x power-on default is channel 0 connected. If multiple pca954x
> muxes are connected to the same physical I2C bus, the parent bus will
> see channel 0 devices behind both muxes by default. This is bad.
> 
> Scenario:
>             -- pca954x @ 0x70 -- ch 0 (I2C-bus-101) -- EEPROM @ 0x50
>             |
> I2C-bus-1 ---
>             |
>             -- pca954x @ 0x71 -- ch 0 (I2C-bus-111) -- EEPROM @ 0x50
> 
> 1. Load I2C bus driver: creates I2C-bus-1
> 2. Load pca954x driver: creates virtual I2C-bus-101 and I2C-bus-111
> 3. Load eeprom driver
> 4. Try to read EEPROM @ 0x50 on I2C-bus-101. The transaction will also bleed
>    onto I2C-bus-111 because pca954x @ 0x71 channel 0 is connected by default.
> 
> Fix: Initialize pca954x to disconnected state in pca954x_probe()
> 
> Signed-off-by: Petri Gynther <pgynther-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
> ---
>  drivers/i2c/muxes/pca954x.c |    7 ++++---
>  1 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c
> index 54e1ce7..6f89536 100644
> --- a/drivers/i2c/muxes/pca954x.c
> +++ b/drivers/i2c/muxes/pca954x.c
> @@ -201,10 +201,11 @@ static int pca954x_probe(struct i2c_client *client,
>  
>  	i2c_set_clientdata(client, data);
>  
> -	/* Read the mux register at addr to verify
> -	 * that the mux is in fact present.
> +	/* Write the mux register at addr to verify
> +	 * that the mux is in fact present. This also
> +	 * initializes the mux to disconnected state.
>  	 */
> -	if (i2c_smbus_read_byte(client) < 0) {
> +	if (i2c_smbus_write_byte(client, 0) < 0) {
>  		dev_warn(&client->dev, "probe failed\n");
>  		goto exit_free;
>  	}

Good fix, applied, thanks.

-- 
Jean Delvare

      parent reply	other threads:[~2011-06-18  8:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-18  1:00 [PATCH] pca954x: Initialize the mux to disconnected state in pca954x_probe() Petri Gynther
     [not found] ` <20110618005949.2F442E0866-z1f3I2EsBvXHt/MElyovVYaSKrA+ACpX0E9HWUfgJXw@public.gmane.org>
2011-06-18  8:47   ` Jean Delvare [this message]

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=20110618104732.62a19129@endymion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=galak-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org \
    --cc=giometti-k2GhghHVRtY@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=pgynther-hpIqsD4AKlfQT0dZR+AlfA@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).