* [PATCH] ASoC: wm8804: Use common error handling code in wm8804_probe()
@ 2017-11-19 7:04 SF Markus Elfring
2017-11-20 6:03 ` Charles Keepax
0 siblings, 1 reply; 2+ messages in thread
From: SF Markus Elfring @ 2017-11-19 7:04 UTC (permalink / raw)
To: alsa-devel, patches, Fabio Estevam, Jaroslav Kysela,
Liam Girdwood, Mark Brown, Takashi Iwai
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 19 Nov 2017 07:55:49 +0100
* Add a jump target so that a specific error message is stored only once
at the end of this function implementation.
* Replace two calls of the function "dev_err" by goto statements.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/soc/codecs/wm8804.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c
index fc69b87443d8..a45812417909 100644
--- a/sound/soc/codecs/wm8804.c
+++ b/sound/soc/codecs/wm8804.c
@@ -626,16 +626,12 @@ int wm8804_probe(struct device *dev, struct regmap *regmap)
gpiod_set_value_cansleep(wm8804->reset, 1);
ret = regmap_read(regmap, WM8804_RST_DEVID1, &id1);
- if (ret < 0) {
- dev_err(dev, "Failed to read device ID: %d\n", ret);
- goto err_reg_enable;
- }
+ if (ret < 0)
+ goto report_read_failure;
ret = regmap_read(regmap, WM8804_DEVID2, &id2);
- if (ret < 0) {
- dev_err(dev, "Failed to read device ID: %d\n", ret);
- goto err_reg_enable;
- }
+ if (ret < 0)
+ goto report_read_failure;
id2 = (id2 << 8) | id1;
@@ -674,6 +670,8 @@ int wm8804_probe(struct device *dev, struct regmap *regmap)
return 0;
+report_read_failure:
+ dev_err(dev, "Failed to read device ID: %d\n", ret);
err_reg_enable:
regulator_bulk_disable(ARRAY_SIZE(wm8804->supplies), wm8804->supplies);
return ret;
--
2.15.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: wm8804: Use common error handling code in wm8804_probe()
2017-11-19 7:04 [PATCH] ASoC: wm8804: Use common error handling code in wm8804_probe() SF Markus Elfring
@ 2017-11-20 6:03 ` Charles Keepax
0 siblings, 0 replies; 2+ messages in thread
From: Charles Keepax @ 2017-11-20 6:03 UTC (permalink / raw)
To: SF Markus Elfring
Cc: alsa-devel, patches, Fabio Estevam, Jaroslav Kysela,
Liam Girdwood, Mark Brown, Takashi Iwai, LKML, kernel-janitors
On Sun, Nov 19, 2017 at 08:04:28AM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 19 Nov 2017 07:55:49 +0100
>
> * Add a jump target so that a specific error message is stored only once
> at the end of this function implementation.
>
> * Replace two calls of the function "dev_err" by goto statements.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Thanks,
Charles
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-20 6:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-19 7:04 [PATCH] ASoC: wm8804: Use common error handling code in wm8804_probe() SF Markus Elfring
2017-11-20 6:03 ` Charles Keepax
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox