[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20200308031355.1149173-2-t.schramm@manjaro.org>
Date: Sun, 8 Mar 2020 04:13:55 +0100
From: Tobias Schramm <t.schramm@...jaro.org>
To: Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai <tiwai@...e.com>
Cc: Liam Girdwood <lgirdwood@...il.com>, alsa-devel@...a-project.org,
linux-kernel@...r.kernel.org,
Tobias Schramm <t.schramm@...jaro.org>
Subject: [RFC PATCH 1/1] ASoC: jack: use gpiolib inversion flag for inverted gpios
This commit changes the handling of jack gpios with ACTIVE_LOW logic.
The inversion flag is now passed down and transparently handled by the
legacy gpiolib.
Previously the level of a gpio was inverted manually inside
snd_soc_jack_gpio_detect and gpiolib ACTIVE_LOW flag was not set on the
gpio. This resulted in erroneous output in /dev/class/gpio/gpio*/active_low
and debug interfaces like /sys/kernel/debug/gpio where the gpio was
still listed as active high while jack status for that gpio actually
followed an active low logic.
Signed-off-by: Tobias Schramm <t.schramm@...jaro.org>
---
sound/soc/soc-jack.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c
index b5748dcd490f..8c17cfdbb883 100644
--- a/sound/soc/soc-jack.c
+++ b/sound/soc/soc-jack.c
@@ -254,8 +254,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;
@@ -385,6 +383,10 @@ int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
}
} else {
/* legacy GPIO number */
+ int flags = GPIOF_IN;
+
+ if (gpios[i].invert)
+ flags |= GPIOF_ACTIVE_LOW;
if (!gpio_is_valid(gpios[i].gpio)) {
dev_err(jack->card->dev,
"ASoC: Invalid gpio %d\n",
@@ -393,7 +395,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.24.1
Powered by blists - more mailing lists