Re: [PATCH v2 6/7] gpiolib: avoid krealloc() in gpiod_get_array()

From: Andy Shevchenko

Date: Wed Nov 04 2026 - 19:12:28 EST


On Wed, Nov 04, 2026 at 10:14:49AM -0800, Dmitry Torokhov wrote:
> On Wed, Nov 04, 2026 at 02:20:53PM +0200, Andy Shevchenko wrote:
> > On Tue, Nov 03, 2026 at 07:40:34PM -0800, Dmitry Torokhov wrote:

...

> > > + bitmap_set(array_info->get_mask, 0, count);
> > > + bitmap_set(array_info->set_mask, 0, count);
> >
> > You don't need these, as memory is nullified.
> > Also note that we have bitmap_clear() IIRC.
>
> bitmap_set() sets bits 0 .. count - 1 to 1, not 0. Both get_mask and
> set_mask start with all count bits set (assuming all pins in the array
> are eligible for the fast path), and then gpio_descs_check_fastpath()
> clears individual bits for pins that do not qualify.

Ah, indeed, but we still have bitmap_fill().

...

> > > dev_dbg(dev,
> > > "GPIO array info: chip=%s, size=%d, get_mask=%lx, set_mask=%lx, invert_mask=%lx\n",
> > > - array_info->gdev->label, array_info->size,
> > > - *array_info->get_mask, *array_info->set_mask,
> > > - *array_info->invert_mask);
> > > + descs->info->gdev->label, descs->info->size,
> > > + *descs->info->get_mask, *descs->info->set_mask,
> > > + *descs->info->invert_mask);
> >
> > Why not using %*pb for masks?
>
> Switching the debug format string from %lx to %*pb is orthogonal to this
> change, so it is better done as a separate patch.

Sure.

--
With Best Regards,
Andy Shevchenko