From: SF Markus Elfring <elfring@users.sourceforge.net>
To: alsa-devel@alsa-project.org,
Brian Austin <brian.austin@cirrus.com>,
Jaroslav Kysela <perex@perex.cz>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Paul Handrigan <Paul.Handrigan@cirrus.com>,
Takashi Iwai <tiwai@suse.com>
Cc: kernel-janitors@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] ASoC: cs4270: Use common error handling code in two functions
Date: Wed, 6 Sep 2017 19:34:50 +0200 [thread overview]
Message-ID: <e7525d1e-0a92-92c5-b779-e2f356b45e45@users.sourceforge.net> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 6 Sep 2017 19:09:31 +0200
Add jump targets so that a bit of exception handling can be better reused
at the end of these functions.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
sound/soc/codecs/cs4270.c | 32 ++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index 84f86745c30e..aa70d471cc57 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -362,10 +362,8 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
reg |= cs4270_mode_ratios[i].speed_mode;
ret = snd_soc_write(codec, CS4270_MODE, reg);
- if (ret < 0) {
- dev_err(codec->dev, "i2c write failed\n");
- return ret;
- }
+ if (ret < 0)
+ goto report_failure;
/* Set the DAI format */
@@ -385,11 +383,13 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
}
ret = snd_soc_write(codec, CS4270_FORMAT, reg);
- if (ret < 0) {
- dev_err(codec->dev, "i2c write failed\n");
- return ret;
- }
+ if (ret < 0)
+ goto report_failure;
+
+ return ret;
+report_failure:
+ dev_err(codec->dev, "i2c write failed\n");
return ret;
}
@@ -512,10 +512,8 @@ static int cs4270_probe(struct snd_soc_codec *codec)
* re-enabled it by using the controls.
*/
ret = snd_soc_update_bits(codec, CS4270_MUTE, CS4270_MUTE_AUTO, 0);
- if (ret < 0) {
- dev_err(codec->dev, "i2c write failed\n");
- return ret;
- }
+ if (ret < 0)
+ goto report_failure;
/* Disable automatic volume control. The hardware enables, and it
* causes volume change commands to be delayed, sometimes until after
@@ -524,15 +522,17 @@ static int cs4270_probe(struct snd_soc_codec *codec)
*/
ret = snd_soc_update_bits(codec, CS4270_TRANS,
CS4270_TRANS_SOFT | CS4270_TRANS_ZERO, 0);
- if (ret < 0) {
- dev_err(codec->dev, "i2c write failed\n");
- return ret;
- }
+ if (ret < 0)
+ goto report_failure;
ret = regulator_bulk_enable(ARRAY_SIZE(cs4270->supplies),
cs4270->supplies);
return ret;
+
+report_failure:
+ dev_err(codec->dev, "i2c write failed\n");
+ return ret;
}
/**
--
2.14.1
reply other threads:[~2017-09-06 17:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=e7525d1e-0a92-92c5-b779-e2f356b45e45@users.sourceforge.net \
--to=elfring@users.sourceforge.net \
--cc=Paul.Handrigan@cirrus.com \
--cc=alsa-devel@alsa-project.org \
--cc=brian.austin@cirrus.com \
--cc=broonie@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--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;
as well as URLs for NNTP newsgroup(s).