From: Johan Hovold Date: Tue, 15 Apr 2025 07:41:44 +0000 (+0200) Subject: ASoC: codecs: wcd938x: fix mux error handling X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=d1407c934f523c8742ab006e7782f6eae780a7d1;p=users%2Fjedix%2Flinux-maple.git ASoC: codecs: wcd938x: fix mux error handling A recent change added support for looking up an optional mux control before falling back to gpio control for us-euro plug selection. The mux framework does however not yet support optional muxes and an error message is now incorrectly logged on machines like the Lenovo ThinkPad X13s which do not have one: wcd938x_codec audio-codec: /audio-codec: failed to get mux-control (0) Suppress the bogus error and add the missing mux error handling by making sure that the 'mux-controls' DT property is present before looking up the mux control. Fixes: eec611d26f84 ("ASoC: codecs: wcd938x: add mux control support for hp audio mux") Link: https://lore.kernel.org/lkml/Z-z_ZAyVBK5ui50k@hovoldconsulting.com/ Signed-off-by: Johan Hovold Link: https://patch.msgid.link/20250415074145.7202-2-johan+linaro@kernel.org Signed-off-by: Mark Brown --- diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c index b72dcd9d01720..ad6f3b4da8aa7 100644 --- a/sound/soc/codecs/wcd938x.c +++ b/sound/soc/codecs/wcd938x.c @@ -3270,18 +3270,13 @@ static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device return dev_err_probe(dev, PTR_ERR(wcd938x->reset_gpio), "Failed to get reset gpio\n"); - wcd938x->us_euro_mux = devm_mux_control_get(dev, NULL); - if (IS_ERR(wcd938x->us_euro_mux)) { - if (PTR_ERR(wcd938x->us_euro_mux) == -EPROBE_DEFER) - return -EPROBE_DEFER; + if (of_property_present(dev->of_node, "mux-controls")) { + wcd938x->us_euro_mux = devm_mux_control_get(dev, NULL); + if (IS_ERR(wcd938x->us_euro_mux)) { + ret = PTR_ERR(wcd938x->us_euro_mux); + return dev_err_probe(dev, ret, "failed to get mux control\n"); + } - /* mux is optional and now fallback to using gpio */ - wcd938x->us_euro_mux = NULL; - wcd938x->us_euro_gpio = devm_gpiod_get_optional(dev, "us-euro", GPIOD_OUT_LOW); - if (IS_ERR(wcd938x->us_euro_gpio)) - return dev_err_probe(dev, PTR_ERR(wcd938x->us_euro_gpio), - "us-euro swap Control GPIO not found\n"); - } else { ret = mux_control_try_select(wcd938x->us_euro_mux, wcd938x->mux_state); if (ret) { dev_err(dev, "Error (%d) Unable to select us/euro mux state\n", ret); @@ -3289,6 +3284,11 @@ static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device return ret; } wcd938x->mux_setup_done = true; + } else { + wcd938x->us_euro_gpio = devm_gpiod_get_optional(dev, "us-euro", GPIOD_OUT_LOW); + if (IS_ERR(wcd938x->us_euro_gpio)) + return dev_err_probe(dev, PTR_ERR(wcd938x->us_euro_gpio), + "us-euro swap Control GPIO not found\n"); } cfg->swap_gnd_mic = wcd938x_swap_gnd_mic;