Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Yang Ruibin <11162571@vivo.com>
To: "Lars-Peter Clausen" <lars@metafoo.de>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Takashi Iwai" <tiwai@suse.com>,
	alsa-devel@alsa-project.org, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: opensource.kernel@vivo.com, Yang Ruibin <11162571@vivo.com>
Subject: [PATCH v1] ASoC: codecs: Switch to use dev_err_probe()
Date: Fri, 30 Aug 2024 09:47:32 +0800	[thread overview]
Message-ID: <20240830014733.3467006-1-11162571@vivo.com> (raw)

Using dev_err_probe() instead of dev_err() in probe() simplifies
the error path and standardizes the format of the error code.

Signed-off-by: Yang Ruibin <11162571@vivo.com>
---
 sound/soc/codecs/ad1980.c   |  8 +++-----
 sound/soc/codecs/adau1701.c | 19 +++++++------------
 sound/soc/codecs/ssm2602.c  |  6 ++----
 3 files changed, 12 insertions(+), 21 deletions(-)

diff --git a/sound/soc/codecs/ad1980.c b/sound/soc/codecs/ad1980.c
index 3c1ae13c1..d2f679d9d 100644
--- a/sound/soc/codecs/ad1980.c
+++ b/sound/soc/codecs/ad1980.c
@@ -237,11 +237,9 @@ static int ad1980_soc_probe(struct snd_soc_component *component)
 	u16 ext_status;
 
 	ac97 = snd_soc_new_ac97_component(component, 0, 0);
-	if (IS_ERR(ac97)) {
-		ret = PTR_ERR(ac97);
-		dev_err(component->dev, "Failed to register AC97 component: %d\n", ret);
-		return ret;
-	}
+	if (IS_ERR(ac97))
+		return dev_err_probe(component->dev, PTR_ERR(ac97),
+			"Failed to register AC97 component\n");
 
 	regmap = regmap_init_ac97(ac97, &ad1980_regmap_config);
 	if (IS_ERR(regmap)) {
diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c
index 8bd6067df..f4c574447 100644
--- a/sound/soc/codecs/adau1701.c
+++ b/sound/soc/codecs/adau1701.c
@@ -677,10 +677,9 @@ static int adau1701_probe(struct snd_soc_component *component)
 
 	ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies),
 				    adau1701->supplies);
-	if (ret < 0) {
-		dev_err(component->dev, "Failed to enable regulators: %d\n", ret);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(component->dev, ret,
+					"Failed to enable regulators\n");
 
 	/*
 	 * Let the pll_clkdiv variable default to something that won't happen
@@ -798,17 +797,13 @@ static int adau1701_i2c_probe(struct i2c_client *client)
 
 	ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(adau1701->supplies),
 			adau1701->supplies);
-	if (ret < 0) {
-		dev_err(dev, "Failed to get regulators: %d\n", ret);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Failed to get regulators\n");
 
 	ret = regulator_bulk_enable(ARRAY_SIZE(adau1701->supplies),
 			adau1701->supplies);
-	if (ret < 0) {
-		dev_err(dev, "Failed to enable regulators: %d\n", ret);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(dev, ret, "Failed to enable regulators\n");
 
 	adau1701->client = client;
 	adau1701->regmap = devm_regmap_init(dev, NULL, client,
diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c
index c29324403..153eb55a3 100644
--- a/sound/soc/codecs/ssm2602.c
+++ b/sound/soc/codecs/ssm2602.c
@@ -605,10 +605,8 @@ static int ssm260x_component_probe(struct snd_soc_component *component)
 	int ret;
 
 	ret = regmap_write(ssm2602->regmap, SSM2602_RESET, 0);
-	if (ret < 0) {
-		dev_err(component->dev, "Failed to issue reset: %d\n", ret);
-		return ret;
-	}
+	if (ret < 0)
+		return dev_err_probe(component->dev, ret, "Failed to issue reset\n");
 
 	regmap_register_patch(ssm2602->regmap, ssm2602_patch,
 			      ARRAY_SIZE(ssm2602_patch));
-- 
2.34.1


             reply	other threads:[~2024-08-30  1:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-30  1:47 Yang Ruibin [this message]
2024-08-30 17:14 ` [PATCH v1] ASoC: codecs: Switch to use dev_err_probe() Krzysztof Kozlowski

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=20240830014733.3467006-1-11162571@vivo.com \
    --to=11162571@vivo.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=lars@metafoo.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=opensource.kernel@vivo.com \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    /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