Commit 355beeed authored by Dmitry Torokhov's avatar Dmitry Torokhov Committed by Mark Brown

ASoC: simple-card-utils: switch to using gpiod API

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: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/YxeaITtlJexygQo9@google.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent d2a411f8
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment