The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Johan Hovold <johan+linaro@kernel.org>
To: Peter Rosin <peda@axentia.se>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>,
	Mark Brown <broonie@kernel.org>,
	linux-kernel@vger.kernel.org,
	Johan Hovold <johan+linaro@kernel.org>
Subject: [PATCH] mux: suppress lookup errors for mux controls
Date: Mon, 14 Apr 2025 14:42:20 +0200	[thread overview]
Message-ID: <20250414124220.30578-1-johan+linaro@kernel.org> (raw)

Since commit eec611d26f84 ("ASoC: codecs: wcd938x: add mux control
support for hp audio mux") we have drivers looking up mux controls that
are optional. This results in errors incorrectly being logged on
machines like the Lenovo ThinkPad X13s where the mux is missing:

    wcd938x_codec audio-codec: /audio-codec: failed to get mux-control (0)

Suppress the error message when lookup of mux controls fails and make
sure to return -ENOENT consistently also when looking up controls by
name so that consumer drivers can easily determine how to proceed.

Note that most current consumers already log mux lookup failures
themselves.

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 <johan+linaro@kernel.org>
---
 drivers/mux/core.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/mux/core.c b/drivers/mux/core.c
index 02be4ba37257..b95bc03e3d6b 100644
--- a/drivers/mux/core.c
+++ b/drivers/mux/core.c
@@ -544,8 +544,13 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name,
 			index = of_property_match_string(np, "mux-control-names",
 							 mux_name);
 		if (index < 0) {
-			dev_err(dev, "mux controller '%s' not found\n",
-				mux_name);
+			if (!state && index == -EINVAL)
+				index = -ENOENT;
+
+			if (index != -ENOENT) {
+				dev_err(dev, "mux controller '%s' not found\n",
+					mux_name);
+			}
 			return ERR_PTR(index);
 		}
 	}
@@ -559,8 +564,11 @@ static struct mux_control *mux_get(struct device *dev, const char *mux_name,
 						 "mux-controls", "#mux-control-cells",
 						 index, &args);
 	if (ret) {
-		dev_err(dev, "%pOF: failed to get mux-%s %s(%i)\n",
-			np, state ? "state" : "control", mux_name ?: "", index);
+		if (state || ret != -ENOENT) {
+			dev_err(dev, "%pOF: failed to get mux-%s %s(%i)\n",
+				np, state ? "state" : "control",
+				mux_name ?: "", index);
+		}
 		return ERR_PTR(ret);
 	}
 
-- 
2.49.0


             reply	other threads:[~2025-04-14 12:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-14 12:42 Johan Hovold [this message]
2025-04-14 13:18 ` [PATCH] mux: suppress lookup errors for mux controls Peter Rosin
2025-04-14 14:01   ` Johan Hovold
2025-04-14 14:35     ` Srinivas Kandagatla
2025-04-15  6:26       ` Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250414124220.30578-1-johan+linaro@kernel.org \
    --to=johan+linaro@kernel.org \
    --cc=broonie@kernel.org \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peda@axentia.se \
    --cc=srinivas.kandagatla@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox