* [PATCH v1] ASoC: codecs: Switch to use dev_err_probe()
@ 2024-08-30 1:47 Yang Ruibin
2024-08-30 17:14 ` Krzysztof Kozlowski
0 siblings, 1 reply; 2+ messages in thread
From: Yang Ruibin @ 2024-08-30 1:47 UTC (permalink / raw)
To: Lars-Peter Clausen, Nuno Sá, Liam Girdwood, Mark Brown,
Jaroslav Kysela, Takashi Iwai, alsa-devel, linux-sound,
linux-kernel
Cc: opensource.kernel, Yang Ruibin
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1] ASoC: codecs: Switch to use dev_err_probe()
2024-08-30 1:47 [PATCH v1] ASoC: codecs: Switch to use dev_err_probe() Yang Ruibin
@ 2024-08-30 17:14 ` Krzysztof Kozlowski
0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Kozlowski @ 2024-08-30 17:14 UTC (permalink / raw)
To: Yang Ruibin, Lars-Peter Clausen, Nuno Sá, Liam Girdwood,
Mark Brown, Jaroslav Kysela, Takashi Iwai, alsa-devel,
linux-sound, linux-kernel
Cc: opensource.kernel
On 30/08/2024 03:47, Yang Ruibin wrote:
> 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/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");
After quick look, I think this might not be a probe path, thus the code
might not be correct.
Best regards,
Krzysztof
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-30 17:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-30 1:47 [PATCH v1] ASoC: codecs: Switch to use dev_err_probe() Yang Ruibin
2024-08-30 17:14 ` Krzysztof Kozlowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox