Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1482193 > unrolled thread

[PATCH] driver: base: pinctrl: return error from pinctrl_bind_pins()

Started byDeepak <deepak_das@mentor.com>
First post2016-09-13 09:20 +0200
Last post2016-09-14 08:30 +0200
Articles 5 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] driver: base: pinctrl: return error from pinctrl_bind_pins() Deepak <deepak_das@mentor.com> - 2016-09-13 09:20 +0200
    Re: [PATCH] driver: base: pinctrl: return error from pinctrl_bind_pins() Linus Walleij <linus.walleij@linaro.org> - 2016-09-13 14:10 +0200
      Re: [PATCH] driver: base: pinctrl: return error from  pinctrl_bind_pins() Deepak Das <deepak_das@mentor.com> - 2016-09-13 15:50 +0200
        Re: [PATCH] driver: base: pinctrl: return error from pinctrl_bind_pins() Linus Walleij <linus.walleij@linaro.org> - 2016-09-13 23:10 +0200
          Re: [PATCH] driver: base: pinctrl: return error from  pinctrl_bind_pins() Deepak Das <deepak_das@mentor.com> - 2016-09-14 08:30 +0200

#1482193 — [PATCH] driver: base: pinctrl: return error from pinctrl_bind_pins()

FromDeepak <deepak_das@mentor.com>
Date2016-09-13 09:20 +0200
Subject[PATCH] driver: base: pinctrl: return error from pinctrl_bind_pins()
Message-ID<sgQaC-72V-7@gated-at.bofh.it>
strict pin controller returns -EINVAL in case of pin request which
is already claimed by somebody else.
Following is the sequence of calling pin_request() from
pinctrl_bind_pins():-
pinctrl_bind_pins()->pinctrl_select_state()->pinmux_enable_setting()->
pin_request()

But pinctrl_bind_pins() only returns -EPROBE_DEFER which makes device
driver probe successful even if the pin request is rejected by the pin
controller subsystem.

This commit modifies pinctrl_bind_pins() to return error if the pin is
rejected by pin control subsystem.

Signed-off-by: Deepak Das <deepak_das@mentor.com>
---
  drivers/base/pinctrl.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/pinctrl.c b/drivers/base/pinctrl.c
index 0762975..e65c1af 100644
--- a/drivers/base/pinctrl.c
+++ b/drivers/base/pinctrl.c
@@ -92,7 +92,7 @@ cleanup_alloc:
      dev->pins = NULL;

      /* Only return deferrals */
-    if (ret != -EPROBE_DEFER)
+    if ((ret != -EPROBE_DEFER) && (ret != -EINVAL))
          ret = 0;

      return ret;
-- 
1.9.1

[toc] | [next] | [standalone]


#1482395

FromLinus Walleij <linus.walleij@linaro.org>
Date2016-09-13 14:10 +0200
Message-ID<sgUHf-1D2-7@gated-at.bofh.it>
In reply to#1482193
On Tue, Sep 13, 2016 at 9:13 AM, Deepak <deepak_das@mentor.com> wrote:

> strict pin controller returns -EINVAL in case of pin request which
> is already claimed by somebody else.
> Following is the sequence of calling pin_request() from
> pinctrl_bind_pins():-
> pinctrl_bind_pins()->pinctrl_select_state()->pinmux_enable_setting()->
> pin_request()
>
> But pinctrl_bind_pins() only returns -EPROBE_DEFER which makes device
> driver probe successful even if the pin request is rejected by the pin
> controller subsystem.
>
> This commit modifies pinctrl_bind_pins() to return error if the pin is
> rejected by pin control subsystem.
>
> Signed-off-by: Deepak Das <deepak_das@mentor.com>

Aha

>      /* Only return deferrals */
> -    if (ret != -EPROBE_DEFER)
> +    if ((ret != -EPROBE_DEFER) && (ret != -EINVAL))
>          ret = 0;

I rewrote this when applying, like this:

-       /* Only return deferrals */
-       if (ret != -EPROBE_DEFER)
-               ret = 0;
+       /* Return deferrals */
+       if (ret == -EPROBE_DEFER)
+               return ret;
+       if (ret == -EINVAL) {
+               dev_err(dev, "could not initialize pin control state\n");
+               return ret;
+       }
+       /* We ignore errors like -ENOENT meaning no pinctrl state */

-       return ret;
+       return 0;

Can you confim that this works for you too?

Yours,
Linus Walleij

[toc] | [prev] | [next] | [standalone]


#1482503 — Re: [PATCH] driver: base: pinctrl: return error from pinctrl_bind_pins()

FromDeepak Das <deepak_das@mentor.com>
Date2016-09-13 15:50 +0200
SubjectRe: [PATCH] driver: base: pinctrl: return error from pinctrl_bind_pins()
Message-ID<sgWg2-2C0-21@gated-at.bofh.it>
In reply to#1482395

On Tuesday 13 September 2016 05:29 PM, Linus Walleij wrote:
> On Tue, Sep 13, 2016 at 9:13 AM, Deepak <deepak_das@mentor.com> wrote:
>
>> strict pin controller returns -EINVAL in case of pin request which
>> is already claimed by somebody else.
>> Following is the sequence of calling pin_request() from
>> pinctrl_bind_pins():-
>> pinctrl_bind_pins()->pinctrl_select_state()->pinmux_enable_setting()->
>> pin_request()
>>
>> But pinctrl_bind_pins() only returns -EPROBE_DEFER which makes device
>> driver probe successful even if the pin request is rejected by the pin
>> controller subsystem.
>>
>> This commit modifies pinctrl_bind_pins() to return error if the pin is
>> rejected by pin control subsystem.
>>
>> Signed-off-by: Deepak Das <deepak_das@mentor.com>
>
> Aha
>
>>       /* Only return deferrals */
>> -    if (ret != -EPROBE_DEFER)
>> +    if ((ret != -EPROBE_DEFER) && (ret != -EINVAL))
>>           ret = 0;
>
> I rewrote this when applying, like this:
>
> -       /* Only return deferrals */
> -       if (ret != -EPROBE_DEFER)
> -               ret = 0;
> +       /* Return deferrals */
> +       if (ret == -EPROBE_DEFER)
> +               return ret;
> +       if (ret == -EINVAL) {
> +               dev_err(dev, "could not initialize pin control state\n");
> +               return ret;
> +       }
> +       /* We ignore errors like -ENOENT meaning no pinctrl state */
>
> -       return ret;
> +       return 0;
>
> Can you confim that this works for you too?

Yes, This works for me as well but do we really need this extra error 
message ?
error message is printed before returning -EINVAL from most places, 
Although I did not checked all places. For example, error message in 
pin_request():-
dev_err(pctldev->dev, "pin %s already requested by %s; cannot claim for 
%s\n", desc->name, desc->mux_owner, owner);

Thanks,
Deepak Das
>
> Yours,
> Linus Walleij
>

[toc] | [prev] | [next] | [standalone]


#1482779

FromLinus Walleij <linus.walleij@linaro.org>
Date2016-09-13 23:10 +0200
Message-ID<sh37P-7gw-17@gated-at.bofh.it>
In reply to#1482503
On Tue, Sep 13, 2016 at 3:41 PM, Deepak Das <deepak_das@mentor.com> wrote:

>> Can you confim that this works for you too?
>
> Yes, This works for me as well but do we really need this extra error
> message ?

Nah, good point. I'll go in and drop it then.

Yours,
Linus Walleij

[toc] | [prev] | [next] | [standalone]


#1482952 — Re: [PATCH] driver: base: pinctrl: return error from pinctrl_bind_pins()

FromDeepak Das <deepak_das@mentor.com>
Date2016-09-14 08:30 +0200
SubjectRe: [PATCH] driver: base: pinctrl: return error from pinctrl_bind_pins()
Message-ID<shbRL-5F6-1@gated-at.bofh.it>
In reply to#1482779

On Wednesday 14 September 2016 02:31 AM, Linus Walleij wrote:
> On Tue, Sep 13, 2016 at 3:41 PM, Deepak Das <deepak_das@mentor.com> wrote:
>
>>> Can you confim that this works for you too?
>>
>> Yes, This works for me as well but do we really need this extra error
>> message ?
>
> Nah, good point. I'll go in and drop it then.

Hi Linus,

I will release V2 version of this patch with following change :-
-       /* Only return deferrals */
+       /* Return deferrals & invalid pin requests */
         if ((ret != -EPROBE_DEFER) && (ret != -EINVAL))
                 ret = 0;

Thanks & regards,
Deepak Das

>
> Yours,
> Linus Walleij
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web