[4/8] gpiolib: remove gpio_set_debounce
Commit Message
From: Arnd Bergmann <arnd@arndb.de>
gpio_set_debounce() only has a single user, which is trivially
converted to gpiod_set_debounce().
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
Documentation/driver-api/gpio/legacy.rst | 2 --
drivers/input/touchscreen/ads7846.c | 24 +++++++++++++-----------
include/linux/gpio.h | 22 ----------------------
3 files changed, 13 insertions(+), 35 deletions(-)
Comments
On Thu, Jan 26, 2023 at 02:27:57PM +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> gpio_set_debounce() only has a single user, which is trivially
> converted to gpiod_set_debounce().
Also need to mention the gpio_cansleep() removal.
P.S. Fun fact that I was yesterday thinking about the pretty much
the same change, except intrusive conversion of the user.
...
> Documentation/driver-api/gpio/legacy.rst | 2 --
Documentation/translations/zh_CN/driver-api/gpio/legacy.rst:222: gpio_set_debounce()
Documentation/translations/zh_TW/gpio.txt:229: gpio_set_debounce()
> drivers/input/touchscreen/ads7846.c | 24 +++++++++++++-----------
> include/linux/gpio.h | 22 ----------------------
...
> #include <linux/of_gpio.h>
Do we need this?
> #include <linux/of_device.h>
> +#include <linux/gpio/consumer.h>
> #include <linux/gpio.h>
And this?
On Thu, Jan 26, 2023, at 14:50, Andy Shevchenko wrote:
> On Thu, Jan 26, 2023 at 02:27:57PM +0100, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@arndb.de>
>>
>> gpio_set_debounce() only has a single user, which is trivially
>> converted to gpiod_set_debounce().
>
> Also need to mention the gpio_cansleep() removal.
Indeed, I think that bit got lost in one of the rebases
after some of the other functions that I originally
removed here are already gone.
I've dropped the gpio_cansleep change for now, we can
revisit this later and possibly drop it at the same
time as gpio_{get,set}_value_cansleep that are still
used in a handful of places that could use gpiod
instead.
> P.S. Fun fact that I was yesterday thinking about the pretty much
> the same change, except intrusive conversion of the user.
>
> ...
>
>> Documentation/driver-api/gpio/legacy.rst | 2 --
>
> Documentation/translations/zh_CN/driver-api/gpio/legacy.rst:222:
> gpio_set_debounce()
> Documentation/translations/zh_TW/gpio.txt:229: gpio_set_debounce()
Fixed.
>> drivers/input/touchscreen/ads7846.c | 24 +++++++++++++-----------
>> include/linux/gpio.h | 22 ----------------------
>
> ...
>
>> #include <linux/of_gpio.h>
>
> Do we need this?
Dropped now.
>> #include <linux/of_device.h>
>> +#include <linux/gpio/consumer.h>
>
>> #include <linux/gpio.h>
>
> And this?
I think we still need both linux/gpio/consumer.h and linux/gpio.h
since there is still a call to devm_gpio_request_one() and
gpio_is_valid().
Arnd
On Thu, Jan 26, 2023 at 2:28 PM Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> gpio_set_debounce() only has a single user, which is trivially
> converted to gpiod_set_debounce().
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Thanks for shrinking the legacy API surface.
With the fixes pointed out by Andy:
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Yours,
Linus Walleij
@@ -238,8 +238,6 @@ setup or driver probe/teardown code, so this is an easy constraint.)::
## gpio_free_array()
gpio_free()
- gpio_set_debounce()
-
Claiming and Releasing GPIOs
@@ -27,6 +27,7 @@
#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/of_device.h>
+#include <linux/gpio/consumer.h>
#include <linux/gpio.h>
#include <linux/spi/spi.h>
#include <linux/spi/ads7846.h>
@@ -139,7 +140,7 @@ struct ads7846 {
int (*filter)(void *data, int data_idx, int *val);
void *filter_data;
int (*get_pendown_state)(void);
- int gpio_pendown;
+ struct gpio_desc *gpio_pendown;
void (*wait_for_sync)(void);
};
@@ -222,7 +223,7 @@ static int get_pendown_state(struct ads7846 *ts)
if (ts->get_pendown_state)
return ts->get_pendown_state();
- return !gpio_get_value(ts->gpio_pendown);
+ return !gpiod_get_value(ts->gpio_pendown);
}
static void ads7846_report_pen_up(struct ads7846 *ts)
@@ -1005,7 +1006,6 @@ static int ads7846_setup_pendown(struct spi_device *spi,
if (pdata->get_pendown_state) {
ts->get_pendown_state = pdata->get_pendown_state;
} else if (gpio_is_valid(pdata->gpio_pendown)) {
-
err = devm_gpio_request_one(&spi->dev, pdata->gpio_pendown,
GPIOF_IN, "ads7846_pendown");
if (err) {
@@ -1015,15 +1015,17 @@ static int ads7846_setup_pendown(struct spi_device *spi,
return err;
}
- ts->gpio_pendown = pdata->gpio_pendown;
-
- if (pdata->gpio_pendown_debounce)
- gpio_set_debounce(pdata->gpio_pendown,
- pdata->gpio_pendown_debounce);
+ ts->gpio_pendown = gpio_to_desc(pdata->gpio_pendown);
} else {
- dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
- return -EINVAL;
+ ts->gpio_pendown = gpiod_get(&spi->dev, "pendown-gpio", GPIOD_IN);
+ if (IS_ERR(ts->gpio_pendown)) {
+ dev_err(&spi->dev, "no get_pendown_state nor gpio_pendown?\n");
+ return PTR_ERR(ts->gpio_pendown);
+ }
}
+ if (pdata->gpio_pendown_debounce)
+ gpiod_set_debounce(ts->gpio_pendown,
+ pdata->gpio_pendown_debounce);
return 0;
}
@@ -1192,7 +1194,7 @@ static const struct ads7846_platform_data *ads7846_probe_dt(struct device *dev)
pdata->wakeup = of_property_read_bool(node, "wakeup-source") ||
of_property_read_bool(node, "linux,wakeup");
- pdata->gpio_pendown = of_get_named_gpio(dev->of_node, "pendown-gpio", 0);
+ pdata->gpio_pendown = -1;
return pdata;
}
@@ -100,11 +100,6 @@ static inline int gpio_direction_output(unsigned gpio, int value)
return gpiod_direction_output_raw(gpio_to_desc(gpio), value);
}
-static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
-{
- return gpiod_set_debounce(gpio_to_desc(gpio), debounce);
-}
-
static inline int gpio_get_value_cansleep(unsigned gpio)
{
return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio));
@@ -123,11 +118,6 @@ static inline void gpio_set_value(unsigned gpio, int value)
return gpiod_set_raw_value(gpio_to_desc(gpio), value);
}
-static inline int gpio_cansleep(unsigned gpio)
-{
- return gpiod_cansleep(gpio_to_desc(gpio));
-}
-
static inline int gpio_to_irq(unsigned gpio)
{
return gpiod_to_irq(gpio_to_desc(gpio));
@@ -215,11 +205,6 @@ static inline int gpio_direction_output(unsigned gpio, int value)
return -ENOSYS;
}
-static inline int gpio_set_debounce(unsigned gpio, unsigned debounce)
-{
- return -ENOSYS;
-}
-
static inline int gpio_get_value(unsigned gpio)
{
/* GPIO can never have been requested or set as {in,out}put */
@@ -233,13 +218,6 @@ static inline void gpio_set_value(unsigned gpio, int value)
WARN_ON(1);
}
-static inline int gpio_cansleep(unsigned gpio)
-{
- /* GPIO can never have been requested or set as {in,out}put */
- WARN_ON(1);
- return 0;
-}
-
static inline int gpio_get_value_cansleep(unsigned gpio)
{
/* GPIO can never have been requested or set as {in,out}put */