Re: [PATCH 5/5] gpio: line-mux: fix unsigned truncation of property count error

From: shao.mingyin

Date: Mon Nov 09 2026 - 05:24:18 EST


On Mon, 2026-11-09 at 09:29 +0100, Jonas Jelonek wrote:
> Nit: Please adjust to keep reverse christmas tree. I think 'int ret' and
> 'int ngpio' can be merged too.

Right — shrinking "unsigned int ngpio" to "int ngpio" put that line
before "size_t size" and broke the reverse christmas tree ordering.
I'll merge the two ints and keep the longest-first order:

struct device *dev = &pdev->dev;
struct gpio_lmux *glm;
size_t size;
int ngpio, ret;

> Maybe return the error if < 0, instead of -EINVAL for all?

Agreed. device_property_count_u32() can also return -ENODATA, -EPROTO,
-EOVERFLOW or -ENXIO, and folding them all into -EINVAL would hide which
one failed. I'll propagate the errno and only map a zero count to
-EINVAL:

ngpio = device_property_count_u32(dev, "gpio-line-mux-states");
if (ngpio < 0)
return ngpio;
if (!ngpio)
return -EINVAL;

I'll repost as v2 with your Reviewed-by.

Best,
Shao Mingyin