mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <ahmad@a3f.at>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <ahmad@a3f.at>
Subject: [PATCH 2/5] sound: gpio-beeper: simplify using new gpiod_get helper
Date: Sat, 10 Apr 2021 12:35:08 +0200	[thread overview]
Message-ID: <20210410103511.2073504-2-ahmad@a3f.at> (raw)
In-Reply-To: <20210410103511.2073504-1-ahmad@a3f.at>

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@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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  reply	other threads:[~2021-04-10 10:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-10 10:35 [PATCH 1/5] gpiolib: add Linux-like gpiod_get() helper Ahmad Fatoum
2021-04-10 10:35 ` Ahmad Fatoum [this message]
2021-04-10 10:35 ` [PATCH 3/5] power: reset: add GPIO poweroff driver Ahmad Fatoum
2021-04-10 10:35 ` [PATCH 4/5] power: reset: add GPIO restart driver Ahmad Fatoum
2021-04-12 12:14   ` Lars Pedersen
2021-04-10 10:35 ` [PATCH 5/5] watchdog: add GPIO watchdog driver Ahmad Fatoum
2021-04-13  6:12 ` [PATCH 1/5] gpiolib: add Linux-like gpiod_get() helper Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210410103511.2073504-2-ahmad@a3f.at \
    --to=ahmad@a3f.at \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox