[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZPiJn5I4SI034bn6@smile.fi.intel.com>
Date: Wed, 6 Sep 2023 17:15:59 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Bartosz Golaszewski <brgl@...ev.pl>
Cc: Aaro Koskinen <aaro.koskinen@....fi>,
Janusz Krzysztofik <jmkrzyszt@...il.com>,
Tony Lindgren <tony@...mide.com>,
Russell King <linux@...linux.org.uk>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Linus Walleij <linus.walleij@...aro.org>,
Dipen Patel <dipenp@...dia.com>,
Thierry Reding <thierry.reding@...il.com>,
Jonathan Hunter <jonathanh@...dia.com>,
Hans de Goede <hdegoede@...hat.com>,
Mark Gross <markgross@...nel.org>,
linux-arm-kernel@...ts.infradead.org, linux-omap@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-gpio@...r.kernel.org,
linux-acpi@...r.kernel.org, timestamp@...ts.linux.dev,
linux-tegra@...r.kernel.org, platform-driver-x86@...r.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
Subject: Re: [PATCH 04/21] gpiolib: provide gpio_device_get_desc()
On Tue, Sep 05, 2023 at 08:52:52PM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
>
> Getting the GPIO descriptor directly from the gpio_chip struct is
> dangerous as we don't take the reference to the underlying GPIO device.
> In order to start working towards removing gpiochip_get_desc(), let's
> provide a safer variant that works with an existing reference to struct
> gpio_device.
...
> +/**
> + * gpio_device_get_desc() - get the GPIO descriptor corresponding to the given
> + * hardware number for this GPIO device
> + * @gdev: GPIO device to get the descriptor from
> + * @hwnum: hardware number of the GPIO for this chip
> + *
> + * Returns:
> + * A pointer to the GPIO descriptor or ``ERR_PTR(-EINVAL)`` if no GPIO exists
The known constants can be referenced as %EINVAL.
> + * in the given chip for the specified hardware number or ``ERR_PTR(-ENODEV)``
Ditto.
> + * if the underlying chip already vanished.
> + *
> + * The reference count of struct gpio_device is *NOT* increased like when the
> + * GPIO is being requested for exclusive usage. It's up to the caller to make
> + * sure the GPIO device will stay alive together with the descriptor returned
> + * by this function.
> + */
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists