All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Genoud <richard.genoud@gmail.com>
To: Axel Lin <axel.lin@ingics.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Stephen Warren <swarren@nvidia.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] BUG: pinmux: release only taken pins on error
Date: Wed, 20 Mar 2013 15:19:08 +0100	[thread overview]
Message-ID: <CACQ1gAhTdaRJUWss_gyvDQd14aJsqoVOGY9LWUPBReNQ9VMgSA@mail.gmail.com> (raw)
In-Reply-To: <CAFRkauA3_wOMvn05q4nRBA7_S2UnkUs6T1ma8H91o_uFQ-9zxg@mail.gmail.com>

2013/3/20 Axel Lin <axel.lin@ingics.com>:
> 2013/3/20 Richard Genoud <richard.genoud@gmail.com>:
>> commit e38d457de7be63e6ced1ea254aa51466deb1fef0
>> pinctrl: pinmux: Release all taken pins in pinmux_enable_setting
>>
>> Introduced a bug in the release pin mechanism.
>> All the pins (taken or not) where released.
>> For instance, if a i2c function has already taken pins 5 and 6.
>> And the pins of function PHY are requested (pins 3 4 5 6 7).
>> The pins 3 and 4 will be taken, pin 5 is already taken, so the function
>> fails.
>> And we have pins 3 and 4 release, which is ok. But also pins 5 and 6 !.
>> And also pin 7 (which will have its mux_usecount to -1...)
>>
>> This patch reset the original behaviour.
>>
>> Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
>> ---
>>  drivers/pinctrl/pinmux.c |    2 ++
>>  1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
>> index 1a00658..917e830 100644
>> --- a/drivers/pinctrl/pinmux.c
>> +++ b/drivers/pinctrl/pinmux.c
>> @@ -409,6 +409,8 @@ int pinmux_enable_setting(struct pinctrl_setting const *setting)
>>                         dev_err(pctldev->dev,
>>                                 "could not request pin %d on device %s\n",
>>                                 pins[i], pinctrl_dev_get_name(pctldev));
>> +                       /* On error release *only* taken pins */
>> +                       num_pins = i - 1; /* this pin just failed */
> This seems pointless, in the goto err_pin_request path, the code does
> not use num_pins variable at all.
>
>>                         goto err_pin_request;
>
> see the code in err_pin_request,
> it actually does "while (--i>-0", so it won't call pin_free for the
> just failed pin.
>
> err_pin_request:
>         /* On error release all taken pins */
>         while (--i >= 0)
>                 pin_free(pctldev, pins[i], NULL);
>
>         return ret;

arrrrgg !
it's only Wednesday, and I'm already doing such mistakes !
sorry for that...
This patch can be tossed away with no regret.

The other 2 patches are better I guess

      reply	other threads:[~2013-03-20 14:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-20 11:31 [PATCH] BUG: pinmux: release only taken pins on error Richard Genoud
2013-03-20 11:31 ` [PATCH] BUG: pinmux: forbid mux_usecount to be set at UINT_MAX Richard Genoud
2013-03-20 16:14   ` Stephen Warren
2013-03-20 16:59     ` Richard Genoud
2013-03-20 17:08       ` Stephen Warren
2013-03-21 11:21         ` Richard Genoud
2013-03-21 17:33           ` Stephen Warren
2013-03-21 18:28           ` Linus Walleij
2013-03-20 11:31 ` [PATCH] BUG: [RFC] pinctrl: pins are freed 2 times in pinctrl_bind_pins Richard Genoud
2013-03-20 16:23   ` Stephen Warren
2013-03-21 11:31     ` Richard Genoud
2013-03-20 13:21 ` [PATCH] BUG: pinmux: release only taken pins on error Axel Lin
2013-03-20 14:19   ` Richard Genoud [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=CACQ1gAhTdaRJUWss_gyvDQd14aJsqoVOGY9LWUPBReNQ9VMgSA@mail.gmail.com \
    --to=richard.genoud@gmail.com \
    --cc=axel.lin@ingics.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=swarren@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.