Re: [PATCH v3 2/2] gpio: loongson: add firmware offset parse support

From: Linus Walleij
Date: Thu Aug 10 2023 - 04:28:15 EST


Hi Yinbo,

thanks for your patch!

On Mon, Aug 7, 2023 at 9:41 AM Yinbo Zhu <zhuyinbo@xxxxxxxxxxx> wrote:

> Loongson GPIO controllers come in multiple variants that are compatible
> except for certain register offset values. Add support for device
> properties allowing to specify them in ACPI or DT.
>
> Signed-off-by: Yinbo Zhu <zhuyinbo@xxxxxxxxxxx>

(...)
> @@ -26,6 +26,7 @@ struct loongson_gpio_chip_data {
> unsigned int conf_offset;
> unsigned int out_offset;
> unsigned int in_offset;
> + unsigned int inten_offset;

Consider just changing all of these from unsigned int to u32.

(...)
> + if (device_property_read_u32(dev, "loongson,gpio-conf-offset", (u32 *)&d->conf_offset)
> + || device_property_read_u32(dev, "loongson,gpio-in-offset", (u32 *)&d->in_offset)
> + || device_property_read_u32(dev, "loongson,gpio-out-offset", (u32 *)&d->out_offset)
> + || device_property_read_u32(dev, "loongson,gpio-ctrl-mode", (u32 *)&d->mode))

Because then you can get rid of this annoying forest of cast.

I'm fine with doing this change in this patch without a need for a separate
refactoring, as it's just a contained driver and clearly just about typing.

Yours,
Linus Walleij