[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aAE9CJebvNitZkph@smile.fi.intel.com>
Date: Thu, 17 Apr 2025 20:40:24 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Thomas Richard <thomas.richard@...tlin.com>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <brgl@...ev.pl>,
Geert Uytterhoeven <geert+renesas@...der.be>,
linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
thomas.petazzoni@...tlin.com, DanieleCleri@...on.eu,
GaryWang@...on.com.tw
Subject: Re: [PATCH v3 08/10] gpio: aggregator: handle runtime registration
of gpio_desc in gpiochip_fwd
On Thu, Apr 17, 2025 at 08:38:33PM +0300, Andy Shevchenko wrote:
> On Wed, Apr 16, 2025 at 04:08:16PM +0200, Thomas Richard wrote:
...
> > + unsigned int ndescs = 0, i;
>
> Slightly better (from maintenance perspective) to decouple assignment as it's
> not a standalone function that just counts them. So it means some code may
> appear in between and in long-term someone might screw up with the initial
> value for that.
>
> > int error;
>
> ndescs = 0;
>
> > + for (i = 0; i < chip->ngpio; i++)
> > + if (fwd->descs[i])
> > + ndescs++;
Btw, note with a mask for them you can just have a bitmap_weight() call instead of all this.
ndescs = bitmap_weight(valid_mask);
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists