[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZRPQPL97T2DXbAHv@sol>
Date: Wed, 27 Sep 2023 14:48:28 +0800
From: Kent Gibson <warthog618@...il.com>
To: Yury Norov <yury.norov@...il.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>,
linux-gpio@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
Shubhrajyoti Datta <shubhrajyoti.datta@....com>,
Srinivas Neeli <srinivas.neeli@....com>,
Michal Simek <michal.simek@....com>,
Bartosz Golaszewski <brgl@...ev.pl>,
Andy Shevchenko <andy@...nel.org>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Marek BehĂșn <kabel@...nel.org>
Subject: Re: [PATCH v1 5/5] gpiolib: cdev: Utilize more bitmap APIs
On Tue, Sep 26, 2023 at 05:46:07PM -0700, Yury Norov wrote:
> On Tue, Sep 26, 2023 at 08:20:07AM +0300, Andy Shevchenko wrote:
> > Currently we have a few bitmap calls that are open coded in the library
> > module. Let's convert them to use generic bitmap APIs instead.
> >
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> > + bitmap_from_arr64(mask, &lv->mask, GPIO_V2_LINES_MAX);
> > + bitmap_from_arr64(bits, &lv->bits, GPIO_V2_LINES_MAX);
> > +
> > + num_set = bitmap_gather(vals, bits, mask, lr->num_lines);
>
> It looks like GPIO_V2_LINES_MAX is always 64, and so I wonder: is
> my understanding correct that all bits in ->mask and ->bits beyond
> lr->num_lines are clear?
>
The lv fields come from userspace and so cannot be guaranteed to be
zeroed beyond lr->num_lines. Any set bits beyond that must be ignored,
one way or another.
> If so, you can seemingly pass the GPIO_V2_LINES_MAX instead of
> lr->num_lines, and that way it will be small_cons_nbits()-optimized.
>
But that would be decidedly non-optimal for the most common case where
lr->num_lines == 1.
Cheers,
Kent.
Powered by blists - more mailing lists