From: jacopo mondi <jacopo@jmondi.org>
To: Tony Lindgren <tony@atomide.com>
Cc: Linus Walleij <linus.walleij@linaro.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Haojian Zhuang <haojian.zhuang@linaro.org>,
Jacopo Mondi <jacopo+renesas@jmondi.org>,
Paul Cercueil <paul@crapouillou.net>,
Sean Wang <sean.wang@mediatek.com>
Subject: Re: [PATCH 4/5] pinctrl: rza1: Fix selector use for groups and functions
Date: Tue, 19 Jun 2018 06:16:22 +0200 [thread overview]
Message-ID: <20180619041622.GA4956@w540> (raw)
In-Reply-To: <20180615111141.37184-5-tony@atomide.com>
[-- Attachment #1: Type: text/plain, Size: 3029 bytes --]
Hi Tony,
thanks for doing this!
I cannot find the original bug report in linux-gpio, so I'll comment
on this single patch only.
On Fri, Jun 15, 2018 at 04:11:40AM -0700, Tony Lindgren wrote:
> We must use a mutex around the generic_add functions and save the
> function and group selector in case we need to remove them. Otherwise
> the selector use will be racy for deferred probe at least.
>
> Fixes: 5a49b644b307 ("pinctrl: Renesas RZ/A1 pin and gpio controller")
> Reported-by: H. Nikolaus Schaller <hns@goldelico.com>
> Cc: Haojian Zhuang <haojian.zhuang@linaro.org>
> Cc: Jacopo Mondi <jacopo+renesas@jmondi.org>
> Cc: Paul Cercueil <paul@crapouillou.net>
> Cc: Sean Wang <sean.wang@mediatek.com>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
> ---
> drivers/pinctrl/pinctrl-rza1.c | 25 +++++++++++++------------
> 1 file changed, 13 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/pinctrl/pinctrl-rza1.c b/drivers/pinctrl/pinctrl-rza1.c
> --- a/drivers/pinctrl/pinctrl-rza1.c
> +++ b/drivers/pinctrl/pinctrl-rza1.c
> @@ -1005,7 +1005,7 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev,
> struct device_node *child;
> const char *grpname;
> const char **fngrps;
> - int ret, npins;
> + int ret, npins, gsel, fsel;
Nit: can you move this 3 lines up to keep the variable declarations in reverse
xmas tree order? or if you prefer declare one variable per line...
With this minor comment fixed:
Acked-by: Jacopo Mondi <jacopo@jmondi.org>
Thanks
j
>
> npins = rza1_dt_node_pin_count(np);
> if (npins < 0) {
> @@ -1055,18 +1055,19 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev,
> fngrps[0] = grpname;
>
> mutex_lock(&rza1_pctl->mutex);
> - ret = pinctrl_generic_add_group(pctldev, grpname, grpins, npins,
> - NULL);
> - if (ret) {
> + gsel = pinctrl_generic_add_group(pctldev, grpname, grpins, npins,
> + NULL);
> + if (gsel < 0) {
> mutex_unlock(&rza1_pctl->mutex);
> - return ret;
> + return gsel;
> }
>
> - ret = pinmux_generic_add_function(pctldev, grpname, fngrps, 1,
> - mux_confs);
> - if (ret)
> + fsel = pinmux_generic_add_function(pctldev, grpname, fngrps, 1,
> + mux_confs);
> + if (fsel < 0) {
> + ret = fsel;
> goto remove_group;
> - mutex_unlock(&rza1_pctl->mutex);
> + }
>
> dev_info(rza1_pctl->dev, "Parsed function and group %s with %d pins\n",
> grpname, npins);
> @@ -1083,15 +1084,15 @@ static int rza1_dt_node_to_map(struct pinctrl_dev *pctldev,
> (*map)->data.mux.group = np->name;
> (*map)->data.mux.function = np->name;
> *num_maps = 1;
> + mutex_unlock(&rza1_pctl->mutex);
>
> return 0;
>
> remove_function:
> - mutex_lock(&rza1_pctl->mutex);
> - pinmux_generic_remove_last_function(pctldev);
> + pinmux_generic_remove_function(pctldev, fsel);
>
> remove_group:
> - pinctrl_generic_remove_last_group(pctldev);
> + pinctrl_generic_remove_group(pctldev, gsel);
> mutex_unlock(&rza1_pctl->mutex);
>
> dev_info(rza1_pctl->dev, "Unable to parse function and group %s\n",
> --
> 2.17.1
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2018-06-19 4:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-15 11:11 [PATCH 0/5] pinctrl fixes for generic functions and groups Tony Lindgren
2018-06-15 11:11 ` [PATCH 1/5] pinctrl: core: Return selector to the pinctrl driver Tony Lindgren
2018-06-17 16:50 ` Andy Shevchenko
2018-06-18 6:48 ` Tony Lindgren
2018-06-15 11:11 ` [PATCH 2/5] pinctrl: pinmux: " Tony Lindgren
2018-06-17 16:51 ` Andy Shevchenko
2018-06-15 11:11 ` [PATCH 3/5] pinctrl: single: Fix group and function selector use Tony Lindgren
2018-06-15 11:11 ` [PATCH 4/5] pinctrl: rza1: Fix selector use for groups and functions Tony Lindgren
2018-06-19 4:16 ` jacopo mondi [this message]
2018-06-15 11:11 ` [PATCH 5/5] pinctrl: core: Remove broken remove_last group and pinmux functions Tony Lindgren
-- strict thread matches above, loose matches on Subject: below --
2018-06-19 9:31 [PATCHv2 0/5] pinctrl fixes for generic functions and groups Tony Lindgren
2018-06-19 9:31 ` [PATCH 4/5] pinctrl: rza1: Fix selector use for groups and functions Tony Lindgren
2018-07-05 9:10 [PATCHv3 0/5] pinctrl fixes for generic functions and groups Tony Lindgren
2018-07-05 9:10 ` [PATCH 4/5] pinctrl: rza1: Fix selector use for groups and functions Tony Lindgren
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=20180619041622.GA4956@w540 \
--to=jacopo@jmondi.org \
--cc=haojian.zhuang@linaro.org \
--cc=jacopo+renesas@jmondi.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paul@crapouillou.net \
--cc=sean.wang@mediatek.com \
--cc=tony@atomide.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 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).