Re: [PATCH 3/9] gpio: mxc: cache compatible checks at probe time
From: Andy Shevchenko
Date: Sat Oct 03 2026 - 13:46:15 EST
On Sat, Oct 3, 2026 at 3:09 PM Peng Fan (OSS) <peng.fan@xxxxxxxxxxx> wrote:
> mxc_gpio_generic_config() and mxc_gpio_set_pad_wakeup() call
> of_device_is_compatible() on every invocation to determine pad wakeup
> capability and i.MX8QM-specific behavior. These properties are
> invariant for the lifetime of the device.
>
> Cache them as bool fields (has_pad_wakeup, is_imx8qm) in mxc_gpio_port
> during probe, eliminating repeated device tree string comparisons in
> the suspend/resume hot path.
...
> {
> - struct device_node *np = port->dev->of_node;
> -
> - if (of_device_is_compatible(np, "fsl,imx8dxl-gpio") ||
> - of_device_is_compatible(np, "fsl,imx8qxp-gpio") ||
> - of_device_is_compatible(np, "fsl,imx8qm-gpio"))
> - return (gpiochip_generic_config(&port->gen_gc.gc,
> - offset, conf) == 0);
> + if (!port->has_pad_wakeup)
> + return false;
>
> - return false;
> + return (gpiochip_generic_config(&port->gen_gc.gc, offset, conf) == 0);
Too many parentheses, also the semantic of 0 is not obvious. Better,
for example, this one
int ret;
...
ret = gpiochip_generic_config(...);
if (ret)
return false;
return true;
> }
--
With Best Regards,
Andy Shevchenko