From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>
Cc: Linus Walleij <linus.walleij@linaro.org>,
Bartosz Golaszewski <brgl@bgdev.pl>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: [PATCH] ASoC: simple-card-utils: switch to using gpiod API
Date: Tue, 6 Sep 2022 12:06:09 -0700 [thread overview]
Message-ID: <YxeaITtlJexygQo9@google.com> (raw)
This patch switches the driver away from legacy gpio/of_gpio API to
gpiod API, and removes use of of_get_named_gpio_flags() which I want to
make private to gpiolib.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
sound/soc/generic/simple-card-utils.c | 28 ++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c
index 1b201dd09259..bef16833c487 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -9,7 +9,6 @@
#include <linux/gpio/consumer.h>
#include <linux/module.h>
#include <linux/of.h>
-#include <linux/of_gpio.h>
#include <linux/of_graph.h>
#include <sound/jack.h>
#include <sound/pcm_params.h>
@@ -729,12 +728,12 @@ int asoc_simple_init_jack(struct snd_soc_card *card,
char *pin)
{
struct device *dev = card->dev;
- enum of_gpio_flags flags;
+ struct gpio_desc *desc;
char prop[128];
char *pin_name;
char *gpio_name;
int mask;
- int det;
+ int error;
if (!prefix)
prefix = "";
@@ -742,36 +741,39 @@ int asoc_simple_init_jack(struct snd_soc_card *card,
sjack->gpio.gpio = -ENOENT;
if (is_hp) {
- snprintf(prop, sizeof(prop), "%shp-det-gpio", prefix);
+ snprintf(prop, sizeof(prop), "%shp-det", prefix);
pin_name = pin ? pin : "Headphones";
gpio_name = "Headphone detection";
mask = SND_JACK_HEADPHONE;
} else {
- snprintf(prop, sizeof(prop), "%smic-det-gpio", prefix);
+ snprintf(prop, sizeof(prop), "%smic-det", prefix);
pin_name = pin ? pin : "Mic Jack";
gpio_name = "Mic detection";
mask = SND_JACK_MICROPHONE;
}
- det = of_get_named_gpio_flags(dev->of_node, prop, 0, &flags);
- if (det == -EPROBE_DEFER)
- return -EPROBE_DEFER;
+ desc = gpiod_get_optional(dev, prop, GPIOD_IN);
+ error = PTR_ERR_OR_ZERO(desc);
+ if (error)
+ return error;
+
+ if (desc) {
+ error = gpiod_set_consumer_name(desc, gpio_name);
+ if (error)
+ return error;
- if (gpio_is_valid(det)) {
sjack->pin.pin = pin_name;
sjack->pin.mask = mask;
sjack->gpio.name = gpio_name;
sjack->gpio.report = mask;
- sjack->gpio.gpio = det;
- sjack->gpio.invert = !!(flags & OF_GPIO_ACTIVE_LOW);
+ sjack->gpio.desc = desc;
sjack->gpio.debounce_time = 150;
snd_soc_card_jack_new_pins(card, pin_name, mask, &sjack->jack,
&sjack->pin, 1);
- snd_soc_jack_add_gpios(&sjack->jack, 1,
- &sjack->gpio);
+ snd_soc_jack_add_gpios(&sjack->jack, 1, &sjack->gpio);
}
return 0;
--
2.37.2.789.g6183377224-goog
--
Dmitry
next reply other threads:[~2022-09-06 19:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-06 19:06 Dmitry Torokhov [this message]
2022-09-06 19:17 ` [PATCH] ASoC: simple-card-utils: switch to using gpiod API Linus Walleij
2022-09-07 13:37 ` Mark Brown
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=YxeaITtlJexygQo9@google.com \
--to=dmitry.torokhov@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=brgl@bgdev.pl \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.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