diff mbox

pinctrl: zynq: change error code for pinctrl_register failure

Message ID 1432613909-13457-1-git-send-email-yamada.masahiro@socionext.com
State New
Headers show

Commit Message

Masahiro Yamada May 26, 2015, 4:18 a.m. UTC
pinctrl_register() could fail for memory unrelated errors.
Returning -EINVAL (or -ENODEV) seems more suitable for here.
At least, the other pinctrl drivers do so.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/pinctrl/pinctrl-zynq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Arnd Bergmann May 26, 2015, 8:12 a.m. UTC | #1
On Tuesday 26 May 2015 13:18:29 Masahiro Yamada wrote:
> diff --git a/drivers/pinctrl/pinctrl-zynq.c b/drivers/pinctrl/pinctrl-zynq.c
> index 04748a4..0ff653c 100644
> --- a/drivers/pinctrl/pinctrl-zynq.c
> +++ b/drivers/pinctrl/pinctrl-zynq.c
> @@ -1141,7 +1141,7 @@ static int zynq_pinctrl_probe(struct platform_device *pdev)
>  
>         pctrl->pctrl = pinctrl_register(&zynq_desc, &pdev->dev, pctrl);
>         if (!pctrl->pctrl)
> -               return -ENOMEM;
> +               return -EINVAL;
>  
>         platform_set_drvdata(pdev, pctrl);
>  
> 

One choice seems as bad as the other to me ;-)

Could we add a pinctrl_register_reason() variant that returns a meaningful
error code as ERR_PTR?

	Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Masahiro Yamada May 26, 2015, 8:20 a.m. UTC | #2
Hi Arnd,


2015-05-26 17:12 GMT+09:00 Arnd Bergmann <arnd@arndb.de>:
> On Tuesday 26 May 2015 13:18:29 Masahiro Yamada wrote:
>> diff --git a/drivers/pinctrl/pinctrl-zynq.c b/drivers/pinctrl/pinctrl-zynq.c
>> index 04748a4..0ff653c 100644
>> --- a/drivers/pinctrl/pinctrl-zynq.c
>> +++ b/drivers/pinctrl/pinctrl-zynq.c
>> @@ -1141,7 +1141,7 @@ static int zynq_pinctrl_probe(struct platform_device *pdev)
>>
>>         pctrl->pctrl = pinctrl_register(&zynq_desc, &pdev->dev, pctrl);
>>         if (!pctrl->pctrl)
>> -               return -ENOMEM;
>> +               return -EINVAL;
>>
>>         platform_set_drvdata(pdev, pctrl);
>>
>>
>
> One choice seems as bad as the other to me ;-)
>
> Could we add a pinctrl_register_reason() variant that returns a meaningful
> error code as ERR_PTR?


I also thought of it.
I was wondering why pinctrl_register() did not return ERR_PTR.

Can we migrate to ERR_PTR in the long run?

 [1] Add pinctrl_register_reason()
 [2] Replace pinctrl_register() in each driver with
pinctrl_register_reason() one by one
 [3] Eventually, pinctrl_register will disappear
 [4] Rename pinctrl_register_reason() into pinctrl_register()
Soren Brinkmann May 26, 2015, 6:37 p.m. UTC | #3
On Tue, 2015-05-26 at 10:12AM +0200, Arnd Bergmann wrote:
> On Tuesday 26 May 2015 13:18:29 Masahiro Yamada wrote:
> > diff --git a/drivers/pinctrl/pinctrl-zynq.c b/drivers/pinctrl/pinctrl-zynq.c
> > index 04748a4..0ff653c 100644
> > --- a/drivers/pinctrl/pinctrl-zynq.c
> > +++ b/drivers/pinctrl/pinctrl-zynq.c
> > @@ -1141,7 +1141,7 @@ static int zynq_pinctrl_probe(struct platform_device *pdev)
> >  
> >         pctrl->pctrl = pinctrl_register(&zynq_desc, &pdev->dev, pctrl);
> >         if (!pctrl->pctrl)
> > -               return -ENOMEM;
> > +               return -EINVAL;
> >  
> >         platform_set_drvdata(pdev, pctrl);
> >  
> > 
> 
> One choice seems as bad as the other to me ;-)
> 
> Could we add a pinctrl_register_reason() variant that returns a meaningful
> error code as ERR_PTR?

I agree with Arnd. As long as we don't get a precise error code we can
just keep the current one.

	Sören
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Masahiro Yamada May 27, 2015, 1:18 a.m. UTC | #4
Hi Sören,

2015-05-27 3:37 GMT+09:00 Sören Brinkmann <soren.brinkmann@xilinx.com>:
> On Tue, 2015-05-26 at 10:12AM +0200, Arnd Bergmann wrote:
>> On Tuesday 26 May 2015 13:18:29 Masahiro Yamada wrote:
>> > diff --git a/drivers/pinctrl/pinctrl-zynq.c b/drivers/pinctrl/pinctrl-zynq.c
>> > index 04748a4..0ff653c 100644
>> > --- a/drivers/pinctrl/pinctrl-zynq.c
>> > +++ b/drivers/pinctrl/pinctrl-zynq.c
>> > @@ -1141,7 +1141,7 @@ static int zynq_pinctrl_probe(struct platform_device *pdev)
>> >
>> >         pctrl->pctrl = pinctrl_register(&zynq_desc, &pdev->dev, pctrl);
>> >         if (!pctrl->pctrl)
>> > -               return -ENOMEM;
>> > +               return -EINVAL;
>> >
>> >         platform_set_drvdata(pdev, pctrl);
>> >
>> >
>>
>> One choice seems as bad as the other to me ;-)
>>
>> Could we add a pinctrl_register_reason() variant that returns a meaningful
>> error code as ERR_PTR?
>
> I agree with Arnd. As long as we don't get a precise error code we can
> just keep the current one.

OK. Let's not do this way.


I will try pinctrl_register_reason().
Linus Walleij June 1, 2015, 3 p.m. UTC | #5
On Tue, May 26, 2015 at 8:37 PM, Sören Brinkmann
<soren.brinkmann@xilinx.com> wrote:
> On Tue, 2015-05-26 at 10:12AM +0200, Arnd Bergmann wrote:

>> Could we add a pinctrl_register_reason() variant that returns a meaningful
>> error code as ERR_PTR?
>
> I agree with Arnd. As long as we don't get a precise error code we can
> just keep the current one.

pinctrl_register_cause() please.

Cause-and-effect, not "age of reason".

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pinctrl/pinctrl-zynq.c b/drivers/pinctrl/pinctrl-zynq.c
index 04748a4..0ff653c 100644
--- a/drivers/pinctrl/pinctrl-zynq.c
+++ b/drivers/pinctrl/pinctrl-zynq.c
@@ -1141,7 +1141,7 @@  static int zynq_pinctrl_probe(struct platform_device *pdev)
 
 	pctrl->pctrl = pinctrl_register(&zynq_desc, &pdev->dev, pctrl);
 	if (!pctrl->pctrl)
-		return -ENOMEM;
+		return -EINVAL;
 
 	platform_set_drvdata(pdev, pctrl);