From f171e08de69e55167fbab2fd3e15b5ee10024e80 Mon Sep 17 00:00:00 2001 From: Tobias Schramm Date: Thu, 28 May 2020 14:36:47 +0200 Subject: [PATCH 13/22] ASoC: soc-jack.c: supported inverted jack detect GPIOs Signed-off-by: Tobias Schramm --- sound/soc/soc-jack.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index 0f1820f36b4d..8d9d77814f33 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c @@ -216,8 +216,6 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio) int report; enable = gpiod_get_value_cansleep(gpio->desc); - if (gpio->invert) - enable = !enable; if (enable) report = gpio->report; @@ -346,6 +344,9 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, goto undo; } } else { + int flags = GPIOF_IN; + if (gpios[i].invert) + flags |= GPIOF_ACTIVE_LOW; /* legacy GPIO number */ if (!gpio_is_valid(gpios[i].gpio)) { dev_err(jack->card->dev, @@ -355,7 +356,7 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count, goto undo; } - ret = gpio_request_one(gpios[i].gpio, GPIOF_IN, + ret = gpio_request_one(gpios[i].gpio, flags, gpios[i].name); if (ret) goto undo; -- 2.30.0