diff options
author | Simon Glass | 2021-02-04 21:22:04 -0700 |
---|---|---|
committer | Tom Rini | 2021-03-03 15:40:11 -0500 |
commit | ca1e1f57beb29fbaf48f9488ada1b008dace8314 (patch) | |
tree | de13345480cbd7411c78cdf97856a3fbc88adb3b /drivers/gpio | |
parent | 7e0a96d559da493812220731535f5ba6351bcea1 (diff) |
gpio: Replace direction_input() and direction_output()
The new update_flags() method is more flexible since it allows the
driver to see the full flags all at once. Use that in preference to these
two functions. Add comments to that effect.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Diffstat (limited to 'drivers/gpio')
-rw-r--r-- | drivers/gpio/gpio-uclass.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c index eb8850dfe5c..f90962a0075 100644 --- a/drivers/gpio/gpio-uclass.c +++ b/drivers/gpio/gpio-uclass.c @@ -515,11 +515,8 @@ int gpio_direction_input(unsigned gpio) ret = gpio_to_device(gpio, &desc); if (ret) return ret; - ret = check_reserved(&desc, "dir_input"); - if (ret) - return ret; - return gpio_get_ops(desc.dev)->direction_input(desc.dev, desc.offset); + return dm_gpio_clrset_flags(&desc, GPIOD_MASK_DIR, GPIOD_IS_IN); } /** @@ -534,17 +531,17 @@ int gpio_direction_input(unsigned gpio) int gpio_direction_output(unsigned gpio, int value) { struct gpio_desc desc; + ulong flags; int ret; ret = gpio_to_device(gpio, &desc); if (ret) return ret; - ret = check_reserved(&desc, "dir_output"); - if (ret) - return ret; - return gpio_get_ops(desc.dev)->direction_output(desc.dev, - desc.offset, value); + flags = GPIOD_IS_OUT; + if (value) + flags |= GPIOD_IS_OUT_ACTIVE; + return dm_gpio_clrset_flags(&desc, GPIOD_MASK_DIR, flags); } static int _gpio_get_value(const struct gpio_desc *desc) |