lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y2z7IJv2IQy+Mlsh@orome>
Date:   Thu, 10 Nov 2022 14:22:40 +0100
From:   Thierry Reding <thierry.reding@...il.com>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     Bartosz Golaszewski <brgl@...ev.pl>,
        Dmitry Torokhov <dmitry.torokhov@...il.com>,
        linux-gpio@...r.kernel.org, linux-kernel@...r.kernel.org,
        Linus Walleij <linus.walleij@...aro.org>
Subject: Re: [PATCH v2 1/2] gpiolib: of: Prepare of_gpiochip_add() /
 of_gpiochip_remove() for fwnode

On Tue, Nov 08, 2022 at 03:38:52PM +0200, Andy Shevchenko wrote:
> GPIO library is getting rid of of_node, fwnode should be utilized instead.
> Prepare of_gpiochip_add() / of_gpiochip_remove() for fwnode.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> Reviewed-by: Dmitry Torokhov <dmitry.torokhov@...il.com>
> ---
> v2: added tag (Dmitry)
>  drivers/gpio/gpiolib-of.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
> index be9c34cca322..000020eb78d8 100644
> --- a/drivers/gpio/gpiolib-of.c
> +++ b/drivers/gpio/gpiolib-of.c
> @@ -1104,9 +1104,11 @@ static int of_gpiochip_add_pin_range(struct gpio_chip *chip) { return 0; }
>  
>  int of_gpiochip_add(struct gpio_chip *chip)
>  {
> +	struct device_node *np;
>  	int ret;
>  
> -	if (!chip->of_node)
> +	np = to_of_node(chip->fwnode);
> +	if (!np)

This breaks a number of GPIO controllers on Tegra where chip->fwnode
ends up never getting set. I also see this break drivers like the MFD-
based gpio-max77620, so I don't think this is anything specific to the
Tegra drivers.

Looking at how fwnode handling works, it seems like we're checking the
wrong value here, since chip->fwnode is only for explicit overrides of
the fwnode value.

The below patch fixes the regression for me:

--- >8 ---
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 4be3c21aa718..760f018ae7de 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -1067,7 +1067,7 @@ int of_gpiochip_add(struct gpio_chip *chip)
        struct device_node *np;
        int ret;

-       np = to_of_node(chip->fwnode);
+       np = to_of_node(chip->gpiodev->dev.fwnode);
        if (!np)
                return 0;

--- >8 ---

That uses the GPIO device's fwnode, which can be chip->fwnode if
chip->fwnode was explicitly specified. Otherwise this defaults to 

See gpiochip_add_data_with_key() in drivers/gpio/gpiolib.c:

    677 |	/*
    678 |	 * Assign fwnode depending on the result of the previous calls,
    679 |	 * if none of them succeed, assign it to the parent's one.
    680 |	 */
    681 |	gdev->dev.fwnode = dev_fwnode(&gdev->dev) ?: fwnode;

Looks like this is only important to make sure gdev->dev.fwnode is valid
for OF, for ACPI this should be a no-op.

Thierry

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ