Re: [PATCH v5 11/17] gpiolib: acpi: Take into account debounce settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Nov 09, 2020 at 10:53:26PM +0200, Andy Shevchenko wrote:
> We didn't take into account the debounce settings supplied by ACPI.
> This change is targeting the mentioned gap.
> 
> Reported-by: Coiby Xu <coiby.xu@xxxxxxxxx>
> Cc: Hans de Goede <hdegoede@xxxxxxxxxx>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
> Acked-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
> ---
>  drivers/gpio/gpiolib-acpi.c | 18 ++++++++++++++++++
>  drivers/gpio/gpiolib-acpi.h |  2 ++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
> index c127b410a7a2..6cbad96be866 100644
> --- a/drivers/gpio/gpiolib-acpi.c
> +++ b/drivers/gpio/gpiolib-acpi.c
> @@ -299,6 +299,10 @@ static acpi_status acpi_gpiochip_alloc_event(struct acpi_resource *ares,
>  		return AE_OK;
>  	}
>  
> +	ret = gpio_set_debounce_timeout(desc, agpio->debounce_timeout);
> +	if (ret)
> +		goto fail_free_desc;
> +
>  	ret = gpiochip_lock_as_irq(chip, pin);
>  	if (ret) {
>  		dev_err(chip->parent,
> @@ -664,6 +668,7 @@ static int acpi_populate_gpio_lookup(struct acpi_resource *ares, void *data)
>  		lookup->desc = acpi_get_gpiod(agpio->resource_source.string_ptr,
>  					      agpio->pin_table[pin_index]);
>  		lookup->info.pin_config = agpio->pin_config;
> +		lookup->info.debounce = agpio->debounce_timeout;
>  		lookup->info.gpioint = gpioint;
>  
>  		/*
> @@ -961,6 +966,10 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index)
>  			if (ret < 0)
>  				return ret;
>  
> +			ret = gpio_set_debounce_timeout(desc, info.debounce);
> +			if (ret)
> +				return ret;
> +
>  			irq_flags = acpi_dev_get_irq_type(info.triggering,
>  							  info.polarity);
>  
> @@ -1048,6 +1057,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
>  		if (!found) {
>  			enum gpiod_flags flags = acpi_gpio_to_gpiod_flags(agpio);
>  			const char *label = "ACPI:OpRegion";
> +			int ret;
>  
>  			desc = gpiochip_request_own_desc(chip, pin, label,
>  							 GPIO_ACTIVE_HIGH,
> @@ -1058,6 +1068,14 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
>  				goto out;
>  			}
>  
> +			ret = gpio_set_debounce_timeout(desc, agpio->debounce_timeout);
> +			if (ret) {
> +				status = AE_ERROR;
> +				gpiochip_free_own_desc(desc);
> +				mutex_unlock(&achip->conn_lock);

Nit: I think you can set status outside of the critical section.

Otherwise looks good,

Reviewed-by: Mika Westerberg <mika.westerberg@xxxxxxxxxxxxxxx>



[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux