Re: [PATCH v3 3/4] gpio: mpsse: add quirk support

From: Mary Strodl
Date: Fri Oct 03 2025 - 10:53:01 EST


Hey Dan,

On Thu, Oct 02, 2025 at 11:34:13PM +0300, Dan Carpenter wrote:
> On Thu, Oct 02, 2025 at 02:11:35PM -0400, Mary Strodl wrote:
> > * dir_in/out are bitmask of lines that can go in/out. 0 means
> > compatible, 1 means incompatible. This is convenient, because it means
> > if the struct is zeroed out, it supports all pins.
>
> What? No, please make 1 be supported and 0 be not supported. This
> really weirded me out when I read the code. If it were just 1 for
> true and 0 for false a lot of comments regarding dir_in/out could be
> removed because the code would be straight forward.
>
> You can easily set everything to 1 by assigning -1 or using memset().
Okay. I was thinking leaving out the fields altogether would be most convenient.

> > +static int mpsse_ensure_supported(struct gpio_chip *chip,
> > + unsigned long *mask, int direction)
>
> Just pass mask not a pointer to mask. It would be different if
> you were going to allow more than 32 bits to be set, then we would
> need to pass a pointer and use set_bit() etc...
The reason is because of set/get_multiple. I can deref in there instead though.

> > + dev_err(&priv->udev->dev,
> > + "mpsse: GPIO %d doesn't support %s\n",
> > + (int)find_first_bit(&unsupported, sizeof(unsupported) * 8),
>
> Use %lu instead of %d and get rid of the unnecessary cast.
Good catch. This was a fix for m68k builds that I forgot to remove:
https://lore.kernel.org/linux-gpio/CAMuHMdVpdk5JaqXf6LkSWQvZ7FnfyLdMWOJX+7n0=PZ-udH-WA@xxxxxxxxxxxxxx/

Thanks for taking a look!