2012-06-18 11:47:23

by devendra.aaru

[permalink] [raw]
Subject: Q: return of pinctrl_register and handing at drivers that use this function

Hi,

since the pinctrl_register returns a pointer of structure type "struct
pinctrl_dev" or NULL if it was failed to register the pinctrl driver,
so IS_ERR checking is not required?

My understanding about IS_ERR is that its used when the pointer
addresses are kind of error codes rather actual addresses,
but are a kind of return codes of functions returning integer types.

Please correct me if my understanding is not correct.

Thanks,
Devendra.


2012-06-18 11:52:09

by Linus Walleij

[permalink] [raw]
Subject: Re: Q: return of pinctrl_register and handing at drivers that use this function

On Mon, Jun 18, 2012 at 1:47 PM, devendra.aaru <[email protected]> wrote:

> since the pinctrl_register returns a pointer of structure type "struct
> pinctrl_dev" or NULL if it was failed to register the pinctrl driver,
> so IS_ERR checking is not required?

Yes. (Unless I did something wrong.)

> My understanding about IS_ERR is that its used when the pointer
> addresses are kind of error codes rather actual addresses,
> but are a kind of return codes of functions returning integer types.

You are absolutely right.

Yours,
Linus Walleij

2012-06-18 12:04:54

by devendra.aaru

[permalink] [raw]
Subject: Re: Q: return of pinctrl_register and handing at drivers that use this function

Hi Linus,

On Mon, Jun 18, 2012 at 5:22 PM, Linus Walleij <[email protected]> wrote:
> On Mon, Jun 18, 2012 at 1:47 PM, devendra.aaru <[email protected]> wrote:
>
>> since the pinctrl_register returns a pointer of structure type "struct
>> pinctrl_dev" or NULL if it was failed to register the pinctrl driver,
>> so IS_ERR checking is not required?
>
> Yes. (Unless I did something wrong.)
>
So checking the return value of pinctrl_register with IS_ERR is not required.
There are drivers in pinctrl subsystem which uses the IS_ERR and may (not)
check whether its null or not.

you can expect a patchset of those fixes. :)
> Yours,
> Linus Walleij

Thanks,
Devendra.

2012-06-18 14:38:56

by Linus Walleij

[permalink] [raw]
Subject: Re: Q: return of pinctrl_register and handing at drivers that use this function

On Mon, Jun 18, 2012 at 2:04 PM, devendra.aaru <[email protected]> wrote:

> So checking the return value of pinctrl_register with IS_ERR is not required.

Nope.

> There are drivers in pinctrl subsystem which uses the IS_ERR and may (not)
> check whether its null or not.
>
> you can expect a patchset of those fixes. :)

Good :-)

Thanks,
Linus Walleij

2012-06-18 14:42:18

by devendra.aaru

[permalink] [raw]
Subject: Re: Q: return of pinctrl_register and handing at drivers that use this function

Hi Linus,

On Mon, Jun 18, 2012 at 8:08 PM, Linus Walleij <[email protected]> wrote:
> On Mon, Jun 18, 2012 at 2:04 PM, devendra.aaru <[email protected]> wrote:
>
>> So checking the return value of pinctrl_register with IS_ERR is not required.
>
> Nope.

You mean to say that the check "IS_ERR(ret_ptr)" is not required? or
the other way like
its also needed.

sorry for my poor understanding.

> Thanks,
> Linus Walleij

Thanks,
Devendra.

2012-06-20 07:52:09

by Linus Walleij

[permalink] [raw]
Subject: Re: Q: return of pinctrl_register and handing at drivers that use this function

On Mon, Jun 18, 2012 at 4:42 PM, devendra.aaru <[email protected]> wrote:
> On Mon, Jun 18, 2012 at 8:08 PM, Linus Walleij <[email protected]> wrote:
>> On Mon, Jun 18, 2012 at 2:04 PM, devendra.aaru <[email protected]> wrote:
>>
>>> So checking the return value of pinctrl_register with IS_ERR is not required.
>>
>> Nope.
>
> You mean to say that the check "IS_ERR(ret_ptr)" is not required? or
> the other way like its also needed.

I mean it shall be tested like this:

if (!pinmctrl_register(&foo)) {
/* error case */
}

No IS_ERR() business.

Linus

2012-06-20 17:08:53

by devendra.aaru

[permalink] [raw]
Subject: Re: Q: return of pinctrl_register and handing at drivers that use this function

Hi Linus,

On Wed, Jun 20, 2012 at 1:22 PM, Linus Walleij <[email protected]> wrote:
> I mean it shall be tested like this:
>
> if (!pinmctrl_register(&foo)) {
> ? ?/* error case */
> }
>
> No IS_ERR() business.
>
Yeah, and you already took the changes into your brach :-). Thanks!
> Linus

Devendra