Skip to content

Commit b009011

Browse files
committed
ASoC: codecs: wcd938x: fix mux error handling
Merge series from Johan Hovold <[email protected]>: 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. Included is also a related cleanup.
2 parents 0787a08 + e358e01 commit b009011

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

sound/soc/codecs/wcd938x.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3270,25 +3270,24 @@ static int wcd938x_populate_dt_data(struct wcd938x_priv *wcd938x, struct device
32703270
return dev_err_probe(dev, PTR_ERR(wcd938x->reset_gpio),
32713271
"Failed to get reset gpio\n");
32723272

3273-
wcd938x->us_euro_mux = devm_mux_control_get(dev, NULL);
3274-
if (IS_ERR(wcd938x->us_euro_mux)) {
3275-
if (PTR_ERR(wcd938x->us_euro_mux) == -EPROBE_DEFER)
3276-
return -EPROBE_DEFER;
3273+
if (of_property_present(dev->of_node, "mux-controls")) {
3274+
wcd938x->us_euro_mux = devm_mux_control_get(dev, NULL);
3275+
if (IS_ERR(wcd938x->us_euro_mux)) {
3276+
ret = PTR_ERR(wcd938x->us_euro_mux);
3277+
return dev_err_probe(dev, ret, "failed to get mux control\n");
3278+
}
32773279

3278-
/* mux is optional and now fallback to using gpio */
3279-
wcd938x->us_euro_mux = NULL;
3280-
wcd938x->us_euro_gpio = devm_gpiod_get_optional(dev, "us-euro", GPIOD_OUT_LOW);
3281-
if (IS_ERR(wcd938x->us_euro_gpio))
3282-
return dev_err_probe(dev, PTR_ERR(wcd938x->us_euro_gpio),
3283-
"us-euro swap Control GPIO not found\n");
3284-
} else {
32853280
ret = mux_control_try_select(wcd938x->us_euro_mux, wcd938x->mux_state);
32863281
if (ret) {
32873282
dev_err(dev, "Error (%d) Unable to select us/euro mux state\n", ret);
3288-
wcd938x->mux_setup_done = false;
32893283
return ret;
32903284
}
32913285
wcd938x->mux_setup_done = true;
3286+
} else {
3287+
wcd938x->us_euro_gpio = devm_gpiod_get_optional(dev, "us-euro", GPIOD_OUT_LOW);
3288+
if (IS_ERR(wcd938x->us_euro_gpio))
3289+
return dev_err_probe(dev, PTR_ERR(wcd938x->us_euro_gpio),
3290+
"us-euro swap Control GPIO not found\n");
32923291
}
32933292

32943293
cfg->swap_gnd_mic = wcd938x_swap_gnd_mic;

0 commit comments

Comments
 (0)