From: SF Markus Elfring <elfring@users.sourceforge.net>
To: alsa-devel@alsa-project.org, patches@opensource.cirrus.com,
Fabio Estevam <fabio.estevam@nxp.com>,
Jaroslav Kysela <perex@perex.cz>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>, Takashi Iwai <tiwai@suse.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] ASoC: wm8804: Use common error handling code in wm8804_probe()
Date: Sun, 19 Nov 2017 08:04:28 +0100 [thread overview]
Message-ID: <0027af2f-e560-556c-e5af-effe5179a227@users.sourceforge.net> (raw)
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
next reply other threads:[~2017-11-19 7:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-19 7:04 SF Markus Elfring [this message]
2017-11-20 6:03 ` [PATCH] ASoC: wm8804: Use common error handling code in wm8804_probe() Charles Keepax
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=0027af2f-e560-556c-e5af-effe5179a227@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=fabio.estevam@nxp.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=patches@opensource.cirrus.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