diff mbox series

ASoC: codec: wcd938x: Update CTIA/OMTP switch control

Message ID 1645017892-12522-1-git-send-email-quic_srivasam@quicinc.com (mailing list archive)
State Accepted
Commit db0b4aedfab396a6fe631f5c3bb34319770f0581
Headers show
Series ASoC: codec: wcd938x: Update CTIA/OMTP switch control | expand

Commit Message

Srinivasa Rao Mandadapu Feb. 16, 2022, 1:24 p.m. UTC
Convert gpio api's to gpio descriptor api's in CTIA/OMTP switch control.
Remove redundant NULL checks in swap_gnd_mic function.

Fixes: 013cc2aea0f6 ("ASoC: codec: wcd938x: Add switch control for selecting CTIA/OMTP Headset")

Signed-off-by: Srinivasa Rao Mandadapu <quic_srivasam@quicinc.com>
Co-developed-by: Venkata Prasad Potturu <quic_potturu@quicinc.com>
Signed-off-by: Venkata Prasad Potturu <quic_potturu@quicinc.com>
---
 sound/soc/codecs/wcd938x.c | 33 +++++++++++----------------------
 1 file changed, 11 insertions(+), 22 deletions(-)

Comments

Mark Brown Feb. 17, 2022, 4:22 p.m. UTC | #1
On Wed, 16 Feb 2022 18:54:52 +0530, Srinivasa Rao Mandadapu wrote:
> Convert gpio api's to gpio descriptor api's in CTIA/OMTP switch control.
> Remove redundant NULL checks in swap_gnd_mic function.
> 
> Fixes: 013cc2aea0f6 ("ASoC: codec: wcd938x: Add switch control for selecting CTIA/OMTP Headset")
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: codec: wcd938x: Update CTIA/OMTP switch control
      commit: db0b4aedfab396a6fe631f5c3bb34319770f0581

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c
index 08d16a9..88a39e1 100644
--- a/sound/soc/codecs/wcd938x.c
+++ b/sound/soc/codecs/wcd938x.c
@@ -6,6 +6,7 @@ 
 #include <linux/platform_device.h>
 #include <linux/device.h>
 #include <linux/delay.h>
+#include <linux/gpio/consumer.h>
 #include <linux/kernel.h>
 #include <linux/pm_runtime.h>
 #include <linux/component.h>
@@ -194,7 +195,7 @@  struct wcd938x_priv {
 	int ear_rx_path;
 	int variant;
 	int reset_gpio;
-	int us_euro_gpio;
+	struct gpio_desc *us_euro_gpio;
 	u32 micb1_mv;
 	u32 micb2_mv;
 	u32 micb3_mv;
@@ -4203,22 +4204,11 @@  static bool wcd938x_swap_gnd_mic(struct snd_soc_component *component, bool activ
 
 	struct wcd938x_priv *wcd938x;
 
-	if (!component) {
-		dev_err(component->dev, "%s component is NULL\n", __func__);
-		return false;
-	}
-
 	wcd938x = snd_soc_component_get_drvdata(component);
-	if (!wcd938x) {
-		dev_err(component->dev, "%s private data is NULL\n", __func__);
-		return false;
-	}
 
-	value = gpio_get_value(wcd938x->us_euro_gpio);
+	value = gpiod_get_value(wcd938x->us_euro_gpio);
 
-	gpio_set_value(wcd938x->us_euro_gpio, !value);
-	/* 20us sleep required after changing the gpio state*/
-	usleep_range(20, 30);
+	gpiod_set_value(wcd938x->us_euro_gpio, !value);
 
 	return true;
 }
@@ -4236,16 +4226,15 @@  static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device
 		return wcd938x->reset_gpio;
 	}
 
-	wcd938x->us_euro_gpio = of_get_named_gpio(dev->of_node, "us-euro-gpios", 0);
-	if (wcd938x->us_euro_gpio < 0) {
-		dev_err(dev, "Failed to get us-euro-gpios gpio: err = %d\n", wcd938x->us_euro_gpio);
-	} else {
-		cfg->swap_gnd_mic = wcd938x_swap_gnd_mic;
-		gpio_direction_output(wcd938x->us_euro_gpio, 0);
-		/* 20us sleep required after pulling the reset gpio to LOW */
-		usleep_range(20, 30);
+	wcd938x->us_euro_gpio = devm_gpiod_get_optional(dev, "us-euro",
+						GPIOD_OUT_LOW);
+	if (IS_ERR(wcd938x->us_euro_gpio)) {
+		dev_err(dev, "us-euro swap Control GPIO not found\n");
+		return PTR_ERR(wcd938x->us_euro_gpio);
 	}
 
+	cfg->swap_gnd_mic = wcd938x_swap_gnd_mic;
+
 	wcd938x->supplies[0].supply = "vdd-rxtx";
 	wcd938x->supplies[1].supply = "vdd-io";
 	wcd938x->supplies[2].supply = "vdd-buck";