Re: [PATCH] gpiolib: fix hogs with multiple lines

From: Andy Shevchenko

Date: Wed Mar 25 2026 - 08:27:03 EST


On Wed, Mar 25, 2026 at 11:18:32AM +0100, Bartosz Golaszewski wrote:
> After moving GPIO hog handling into GPIOLIB core, we accidentally stopped
> supporting devicetree hog definitions with multiple lines like so:
>
> hog {
> gpio-hog;
> gpios = <3 0>, <4 GPIO_ACTIVE_LOW>;
> output-high;
> line-name = "foo";
> };
>
> Restore this functionality to fix reported regressions.

...

> + ret = fwnode_property_read_u32(gc_node, "#gpio-cells", &cells);
> + if ((ret && is_of_node(fwnode)) || (!ret && (argc % cells)))
> return -EINVAL;

Hmm... Shouldn't we return the proper error code in the first case?

if (ret && is_of_node(fwnode))
return ret;
if (!ret && (argc % cells))
return -EINVAL;

...

> + u32 *gpios __free(kfree) = kcalloc(argc, sizeof(u32), GFP_KERNEL);

sizeof(*gpios)

> + if (!gpios)
> + return -ENOMEM;

--
With Best Regards,
Andy Shevchenko