public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Peter Korsgaard
	<peter.korsgaard-ob4gmnvZ1/cAvxtiuMwx3w@public.gmane.org>
Cc: ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	ml.lawnick-Mmb7MZpHnFY@public.gmane.org
Subject: Re: [PATCHv4] i2c: add generic I2C multiplexer using gpio api
Date: Tue, 30 Nov 2010 21:03:07 +0100	[thread overview]
Message-ID: <20101130210307.000f98fd@endymion.delvare> (raw)
In-Reply-To: <871v62y4ts.fsf-uXGAPMMVk8amE9MCos8gUmSdvHPH+/yF@public.gmane.org>

Hi Peter,

On Tue, 30 Nov 2010 20:44:15 +0100, Peter Korsgaard wrote:
> >>>>> "Jean" == Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> writes:
>  >> +	for (i = 0; i < pdata->n_gpios; i++) {
>  >> +		ret = gpio_request(pdata->gpios[i], "gpio-i2cmux");
>  >> +		if (ret)
>  >> +			goto err_request_gpio;
>  >> +		gpio_direction_output(pdata->gpios[i], pdata->idle & (1 << i));
> 
>  Jean> This looks wrong if pdata->idle == GPIO_I2CMUX_NO_IDLE. I think we want
>  Jean> something along the lines of:
> 
>  Jean> 	unsigned initial_state;
> 
>  Jean> 	initial_state = pdata->idle == GPIO_I2CMUX_NO_IDLE ?
>  Jean>       pdata->values[0] : pdata->idle;
> 
>  Jean> 		(...)
>  Jean> 		gpio_direction_output(pdata->gpios[i], initial_state & (1 << i));
> 
>  Jean> What do you think? An alternative is to leave the direction
>  Jean> uninitialized and hope it's already OK, but I'm not sure how realistic
>  Jean> this is.
> 
> Yeah, going for values[0] is probably the most sensible thing to do if
> we don't have an idle state. Relying on the firmware to setup the right
> direction in advance is imho not that nice.
> 
> Will you do the change yourself, or should I resend the patch?

I will do it, I was just waiting for you to confirm you agreed with my
analysis and proposal.

>  >> +	if (pdata->idle != GPIO_I2CMUX_NO_IDLE)
>  >> +		deselect = gpiomux_deselect;
> 
> We could probably move this up and add the assignment of init_state to
> this contional, instead of testing against GPIO_I2CMUX_NO_IDLE twice.

Yes of course. The above was kind of pseudo code to express my
proposal, not the definitive code.

I've added your patch to my i2c tree, it's now scheduled for merge in
kernel 2.6.38-rc1:
ftp://ftp.kernel.org/pub/linux/kernel/people/jdelvare/linux-2.6/jdelvare-i2c/i2c-add-generic-i2c-multiplexer-using-gpio-api.patch

Thanks for your contribution!

-- 
Jean Delvare

      parent reply	other threads:[~2010-11-30 20:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-30 14:03 [PATCHv4] i2c: add generic I2C multiplexer using gpio api Peter Korsgaard
     [not found] ` <1291125788-9433-1-git-send-email-peter.korsgaard-ob4gmnvZ1/cAvxtiuMwx3w@public.gmane.org>
2010-11-30 16:15   ` Jean Delvare
     [not found]     ` <20101130171539.73e8e799-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2010-11-30 19:44       ` Peter Korsgaard
     [not found]         ` <871v62y4ts.fsf-uXGAPMMVk8amE9MCos8gUmSdvHPH+/yF@public.gmane.org>
2010-11-30 20:03           ` 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=20101130210307.000f98fd@endymion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=ml.lawnick-Mmb7MZpHnFY@public.gmane.org \
    --cc=peter.korsgaard-ob4gmnvZ1/cAvxtiuMwx3w@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