alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: alsa-devel@alsa-project.org, patches@opensource.cirrus.com,
	Jaroslav Kysela <perex@perex.cz>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>, Takashi Iwai <tiwai@suse.com>
Cc: kernel-janitors@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 2/4] ASoC: wm2000: One function call less in wm2000_i2c_probe() after error detection
Date: Fri, 24 Nov 2017 08:37:41 +0100	[thread overview]
Message-ID: <e09f6361-8d58-c534-4aaa-cafb7f801726@users.sourceforge.net> (raw)
In-Reply-To: <cd76c876-81a5-3cf6-e7d9-52037729fb98@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 24 Nov 2017 07:45:59 +0100

The release_firmware() function was called in a few cases by the
wm2000_i2c_probe() function during error handling even if
the passed variable contained a null pointer.

* Adjust jump targets according to the Linux coding style convention.

* Delete the label "out" and an initialisation for the variable "fw"
  at the beginning which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/soc/codecs/wm2000.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c
index ce936deed7e3..0ed2a8992df4 100644
--- a/sound/soc/codecs/wm2000.c
+++ b/sound/soc/codecs/wm2000.c
@@ -821,7 +821,7 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
 	struct wm2000_priv *wm2000;
 	struct wm2000_platform_data *pdata;
 	const char *filename;
-	const struct firmware *fw = NULL;
+	const struct firmware *fw;
 	int ret, i;
 	int reg;
 	u16 id;
@@ -840,7 +840,7 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
 		ret = PTR_ERR(wm2000->regmap);
 		dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
 			ret);
-		goto out;
+		return ret;
 	}
 
 	for (i = 0; i < WM2000_NUM_SUPPLIES; i++)
@@ -868,7 +868,7 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
 	if (id != 0x2000) {
 		dev_err(&i2c->dev, "Device is not a WM2000 - ID %x\n", id);
 		ret = -ENODEV;
-		goto err_supplies;
+		goto disable_regulator;
 	}
 
 	reg = wm2000_read(i2c, WM2000_REG_REVISON);
@@ -878,7 +878,7 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
 	if (IS_ERR(wm2000->mclk)) {
 		ret = PTR_ERR(wm2000->mclk);
 		dev_err(&i2c->dev, "Failed to get MCLK: %d\n", ret);
-		goto err_supplies;
+		goto disable_regulator;
 	}
 
 	filename = "wm2000_anc.bin";
@@ -893,7 +893,7 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
 	ret = request_firmware(&fw, filename, &i2c->dev);
 	if (ret != 0) {
 		dev_err(&i2c->dev, "Failed to acquire ANC data: %d\n", ret);
-		goto err_supplies;
+		goto disable_regulator;
 	}
 
 	/* Pre-cook the concatenation of the register address onto the image */
@@ -901,9 +901,9 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
 	wm2000->anc_download = devm_kzalloc(&i2c->dev,
 					    wm2000->anc_download_size,
 					    GFP_KERNEL);
-	if (wm2000->anc_download == NULL) {
+	if (!wm2000->anc_download) {
 		ret = -ENOMEM;
-		goto err_supplies;
+		goto release_firmware;
 	}
 
 	wm2000->anc_download[0] = 0x80;
@@ -918,12 +918,10 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
 	wm2000_reset(wm2000);
 
 	ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_wm2000, NULL, 0);
-
-err_supplies:
-	regulator_bulk_disable(WM2000_NUM_SUPPLIES, wm2000->supplies);
-
-out:
+release_firmware:
 	release_firmware(fw);
+disable_regulator:
+	regulator_bulk_disable(WM2000_NUM_SUPPLIES, wm2000->supplies);
 	return ret;
 }
 
-- 
2.15.0

  parent reply	other threads:[~2017-11-24  7:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-24  7:34 [PATCH 0/4] ASoC: wm2000: Adjustments for wm2000_i2c_probe() SF Markus Elfring
2017-11-24  7:36 ` [PATCH 1/4] ASoC: wm2000: Delete an error message for a failed memory allocation in wm2000_i2c_probe() SF Markus Elfring
2017-11-24  8:11   ` Charles Keepax
2017-11-27 18:54   ` Applied "ASoC: wm2000: Delete an error message for a failed memory allocation in wm2000_i2c_probe()" to the asoc tree Mark Brown
2017-11-24  7:37 ` SF Markus Elfring [this message]
2017-11-24  8:34   ` [PATCH 2/4] ASoC: wm2000: One function call less in wm2000_i2c_probe() after error detection Charles Keepax
2017-11-24  7:39 ` [PATCH 3/4] ASoC: wm2000: Fix a typo in a comment line SF Markus Elfring
2017-11-24  8:34   ` Charles Keepax
2017-11-27 18:54   ` Applied "ASoC: wm2000: Fix a typo in a comment line" to the asoc tree Mark Brown
2017-11-24  7:40 ` [PATCH 4/4] ASoC: wm2000: Improve a size determination in wm2000_i2c_probe() SF Markus Elfring
2017-11-24  8:34   ` Charles Keepax
2017-11-27 18:54   ` Applied "ASoC: wm2000: Improve a size determination in wm2000_i2c_probe()" to the asoc tree Mark Brown

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=e09f6361-8d58-c534-4aaa-cafb7f801726@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).