lkml.org 
[lkml]   [2018]   [Mar]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] pinctrl: imx: fix unsigned check if nfuncs with less than or equal zero
On Mon, Feb 26, 2018 at 2:14 PM, A.s. Dong <aisheng.dong@nxp.com> wrote:

>> - u32 nfuncs = 0;
>> - u32 i = 0;
>> + int nfuncs = 0;
>> + int i = 0;
>> bool flat_funcs;
>>
>
> I saw 'i', later used, is converted to u32 unconditionally. (GCC did not complain)
> e.g.
> radix_tree_insert
> imx_pinctrl_parse_functions
>
> And of_get_child_count seems can't return a minor value.
>
> So does something like below look better?
>
> diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
> index c976ffe..4259209 100644
> --- a/drivers/pinctrl/freescale/pinctrl-imx.c
> +++ b/drivers/pinctrl/freescale/pinctrl-imx.c
> @@ -612,7 +612,7 @@ static int imx_pinctrl_probe_dt(struct platform_device *pdev,
> nfuncs = 1;
> } else {
> nfuncs = of_get_child_count(np);
> - if (nfuncs <= 0) {
> + if (nfuncs == 0) {

This makes more sense to me.

You can have zero functions but not negative number of functions.

Aisheng, can you send a patch like this? (Or is it already somewhere in
my inbox?)

Yours,
Linus Walleij

\
 
 \ /
  Last update: 2018-03-21 09:49    [W:0.051 / U:1.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site