[PATCH 2/5] sound: gpio-beeper: simplify using new gpiod_get helper
Ahmad Fatoum
ahmad at a3f.at
Sat Apr 10 11:35:08 BST 2021
the new gpid_get helper allows us to remove the manual
active state setting. Make use of this.
This also fixes an issue where the initial state of the beeper
was on, not off.
Signed-off-by: Ahmad Fatoum <ahmad at a3f.at>
---
drivers/sound/gpio-beeper.c | 20 +++++---------------
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/drivers/sound/gpio-beeper.c b/drivers/sound/gpio-beeper.c
index 86fd4a4ee67c..300998d6079b 100644
--- a/drivers/sound/gpio-beeper.c
+++ b/drivers/sound/gpio-beeper.c
@@ -7,8 +7,7 @@
#include <regulator.h>
#include <sound.h>
#include <of.h>
-#include <gpio.h>
-#include <of_gpio.h>
+#include <gpiod.h>
struct gpio_beeper {
int gpio;
@@ -28,21 +27,12 @@ static int gpio_beeper_probe(struct device_d *dev)
struct device_node *np = dev->device_node;
struct gpio_beeper *beeper;
struct sound_card *card;
- enum of_gpio_flags of_flags;
- unsigned long gpio_flags = GPIOF_OUT_INIT_ACTIVE;
- int ret, gpio;
+ int gpio;
- gpio = of_get_named_gpio_flags(np, "gpios", 0, &of_flags);
- if (!gpio_is_valid(gpio))
+ gpio = gpiod_get(dev, NULL, GPIOD_OUT_LOW);
+ if (gpio < 0) {
+ dev_err(dev, "failed to request gpio: %pe\n", ERR_PTR(gpio));
return gpio;
-
- if (of_flags & OF_GPIO_ACTIVE_LOW)
- gpio_flags |= GPIOF_ACTIVE_LOW;
-
- ret = gpio_request_one(gpio, gpio_flags, "gpio-beeper");
- if (ret) {
- dev_err(dev, "failed to request gpio %d: %d\n", gpio, ret);
- return ret;
}
beeper = xzalloc(sizeof(*beeper));
--
2.30.0
More information about the barebox
mailing list