diff mbox series

[v1,2/6] Input: gpio_keys_polled - avoid using GPIOF_ACTIVE_LOW

Message ID 20241104093609.156059-3-andriy.shevchenko@linux.intel.com (mailing list archive)
State Accepted
Commit 081aaf2dfcfa10fa5cb5444b77b154cce4355708
Headers show
Series gpio: Get rid of deprecated GPIOF_ACTIVE_LOW | expand

Commit Message

Andy Shevchenko Nov. 4, 2024, 9:34 a.m. UTC
Avoid using GPIOF_ACTIVE_LOW as it's deprecated and subject to remove.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/input/keyboard/gpio_keys_polled.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Comments

Dmitry Torokhov Nov. 5, 2024, 5:45 a.m. UTC | #1
On Mon, Nov 04, 2024 at 11:34:20AM +0200, Andy Shevchenko wrote:
> Avoid using GPIOF_ACTIVE_LOW as it's deprecated and subject to remove.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

> ---
>  drivers/input/keyboard/gpio_keys_polled.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
> index 41ca0d3c9098..e6707d72210e 100644
> --- a/drivers/input/keyboard/gpio_keys_polled.c
> +++ b/drivers/input/keyboard/gpio_keys_polled.c
> @@ -306,13 +306,8 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
>  			 * Legacy GPIO number so request the GPIO here and
>  			 * convert it to descriptor.
>  			 */
> -			unsigned flags = GPIOF_IN;
> -
> -			if (button->active_low)
> -				flags |= GPIOF_ACTIVE_LOW;
> -
> -			error = devm_gpio_request_one(dev, button->gpio,
> -					flags, button->desc ? : DRV_NAME);
> +			error = devm_gpio_request_one(dev, button->gpio, GPIOF_IN,
> +						      button->desc ? : DRV_NAME);
>  			if (error)
>  				return dev_err_probe(dev, error,
>  						     "unable to claim gpio %u\n",
> @@ -325,6 +320,9 @@ static int gpio_keys_polled_probe(struct platform_device *pdev)
>  					button->gpio);
>  				return -EINVAL;
>  			}
> +
> +			if (button->active_low ^ gpiod_is_active_low(bdata->gpiod))
> +				gpiod_toggle_active_low(bdata->gpiod);
>  		}
>  
>  		bdata->last_state = -1;
> -- 
> 2.43.0.rc1.1336.g36b5255a03ac
>
Linus Walleij Nov. 8, 2024, 8:33 a.m. UTC | #2
On Mon, Nov 4, 2024 at 10:36 AM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:

> Avoid using GPIOF_ACTIVE_LOW as it's deprecated and subject to remove.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/input/keyboard/gpio_keys_polled.c b/drivers/input/keyboard/gpio_keys_polled.c
index 41ca0d3c9098..e6707d72210e 100644
--- a/drivers/input/keyboard/gpio_keys_polled.c
+++ b/drivers/input/keyboard/gpio_keys_polled.c
@@ -306,13 +306,8 @@  static int gpio_keys_polled_probe(struct platform_device *pdev)
 			 * Legacy GPIO number so request the GPIO here and
 			 * convert it to descriptor.
 			 */
-			unsigned flags = GPIOF_IN;
-
-			if (button->active_low)
-				flags |= GPIOF_ACTIVE_LOW;
-
-			error = devm_gpio_request_one(dev, button->gpio,
-					flags, button->desc ? : DRV_NAME);
+			error = devm_gpio_request_one(dev, button->gpio, GPIOF_IN,
+						      button->desc ? : DRV_NAME);
 			if (error)
 				return dev_err_probe(dev, error,
 						     "unable to claim gpio %u\n",
@@ -325,6 +320,9 @@  static int gpio_keys_polled_probe(struct platform_device *pdev)
 					button->gpio);
 				return -EINVAL;
 			}
+
+			if (button->active_low ^ gpiod_is_active_low(bdata->gpiod))
+				gpiod_toggle_active_low(bdata->gpiod);
 		}
 
 		bdata->last_state = -1;