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]
Date:   Fri, 4 Jun 2021 15:59:54 +0300
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Daniel Scally <djrscally@...il.com>
Cc:     "Rafael J . Wysocki" <rafael.j.wysocki@...el.com>,
        Lee Jones <lee.jones@...aro.org>,
        Hans de Goede <hdegoede@...hat.com>,
        Maximilian Luz <luzmaximilian@...il.com>,
        linux-kernel@...r.kernel.org, linux-acpi@...r.kernel.org,
        linux-gpio@...r.kernel.org, linux-i2c@...r.kernel.org,
        platform-driver-x86@...r.kernel.org, devel@...ica.org,
        Len Brown <lenb@...nel.org>,
        Mika Westerberg <mika.westerberg@...ux.intel.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        Bartosz Golaszewski <bgolaszewski@...libre.com>,
        Wolfram Sang <wsa@...nel.org>,
        Mark Gross <mgross@...ux.intel.com>,
        Robert Moore <robert.moore@...el.com>,
        Erik Kaneda <erik.kaneda@...el.com>,
        laurent.pinchart@...asonboard.com, kieran.bingham@...asonboard.com
Subject: Re: [PATCH v5 3/6] gpiolib: acpi: Export acpi_get_gpiod()

On Thu, Jun 03, 2021 at 11:40:04PM +0100, Daniel Scally wrote:
> We need to be able to translate GPIO resources in an ACPI device's _CRS
> into GPIO descriptor array. Those are represented in _CRS as a pathname
> to a GPIO device plus the pin's index number: the acpi_get_gpiod()
> function is perfect for that purpose.
> 
> As it's currently only used internally within the GPIO layer, provide and
> export a wrapper function that additionally holds a reference to the GPIO
> device.

The subject is wrong, it should be "Introduce acpi_get_and_request_gpiod()
helper" or so. I can fix when applying.

Btw, do I understand correctly that I may push GPIO ACPI patches independently
(of the ACPI changes)?

> Reviewed-by: Andy Shevchenko <andy.shevchenko@...il.com>
> Signed-off-by: Daniel Scally <djrscally@...il.com>
> ---
> Changes since v4:
> 	- None
> 
>  drivers/gpio/gpiolib-acpi.c   | 28 ++++++++++++++++++++++++++++
>  include/linux/gpio/consumer.h |  2 ++
>  2 files changed, 30 insertions(+)
> 
> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> index 5b4111e4be3f..684ddb35d83b 100644
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -128,6 +128,34 @@ static struct gpio_desc *acpi_get_gpiod(char *path, int pin)
>  	return gpiochip_get_desc(chip, pin);
>  }
>  
> +/**
> + * acpi_get_and_request_gpiod() - Translate ACPI GPIO pin to GPIO descriptor
> + *                               and hold a refcount to the GPIO device.
> + * @path:      ACPI GPIO controller full path name, (e.g. "\\_SB.GPO1")
> + * @pin:       ACPI GPIO pin number (0-based, controller-relative)
> + * @label:     Label to pass to gpiod_request()
> + *
> + * This function is a simple pass-through to acpi_get_gpiod(), except that
> + * as it is intended for use outside of the GPIO layer (in a similar fashion to
> + * gpiod_get_index() for example) it also holds a reference to the GPIO device.
> + */
> +struct gpio_desc *acpi_get_and_request_gpiod(char *path, int pin, char *label)
> +{
> +	struct gpio_desc *gpio;
> +	int ret;
> +
> +	gpio = acpi_get_gpiod(path, pin);
> +	if (IS_ERR(gpio))
> +		return gpio;
> +
> +	ret = gpiod_request(gpio, label);
> +	if (ret)
> +		return ERR_PTR(ret);
> +
> +	return gpio;
> +}
> +EXPORT_SYMBOL_GPL(acpi_get_and_request_gpiod);
> +
>  static irqreturn_t acpi_gpio_irq_handler(int irq, void *data)
>  {
>  	struct acpi_gpio_event *event = data;
> diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
> index c73b25bc9213..566feb56601f 100644
> --- a/include/linux/gpio/consumer.h
> +++ b/include/linux/gpio/consumer.h
> @@ -692,6 +692,8 @@ int devm_acpi_dev_add_driver_gpios(struct device *dev,
>  				   const struct acpi_gpio_mapping *gpios);
>  void devm_acpi_dev_remove_driver_gpios(struct device *dev);
>  
> +struct gpio_desc *acpi_get_and_request_gpiod(char *path, int pin, char *label);
> +
>  #else  /* CONFIG_GPIOLIB && CONFIG_ACPI */
>  
>  struct acpi_device;
> -- 
> 2.25.1
> 

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ