Skip to contentSkip to conversation

ASoC: wm2000: Adjustments for wm2000_i2c_probe()

PATCH In review SF Markus Elfring 3 participants 12 messages Nov 24, 2017 – Nov 27, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover ASoC: wm2000: Adjustments for wm2000_i2c_probe()

From: Markus Elfring <[email protected]>
Date: Fri, 24 Nov 2017 08:26:56 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (4):
Delete an error message for a failed memory allocation One function call less in wm2000_i2c_probe() after error detection Fix a typo in a comment line
Improve a size determination

 sound/soc/codecs/wm2000.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)
Signature · 1 line
2.15.0
#1 lore raw

PATCH 1/4 ASoC: wm2000: Delete an error message for a failed memory allocation in wm2000_i2c_probe()

From: Markus Elfring <[email protected]>
Date: Thu, 23 Nov 2017 22:28:00 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 sound/soc/codecs/wm2000.c | 1 -
 1 file changed, 1 deletion(-)
sound/soc/codecs/wm2000.c +0 -1
index 23cde3a0dc11..ce936deed7e3 100644
@@ -902,7 +902,6 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
 					    wm2000->anc_download_size,
 					    GFP_KERNEL);
 	if (wm2000->anc_download = NULL) {
-		dev_err(&i2c->dev, "Out of memory\n");
 		ret = -ENOMEM;
 		goto err_supplies;
 	}
Signature · 1 line
2.15.0
Acked-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] ASoC: wm2000: Delete an error message for a failed memory allocation in wm2000_i2c_probe()

Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 23 Nov 2017 22:28:00 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---

Thanks,
Charles

maintainer
#3 lore raw

Applied "ASoC: wm2000: Delete an error message for a failed memory allocation in wm2000_i2c_probe()" to the asoc tree

In reply to SF Markus Elfring

The patch

ASoC: wm2000: Delete an error message for a failed memory allocation in wm2000_i2c_probe()

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From e866d87a7de38672f52c6e7567e88c3f82f937dc Mon Sep 17 00:00:00 2001

From: Markus Elfring <[email protected]>
Date: Thu, 23 Nov 2017 22:28:00 +0100
Subject: [PATCH] ASoC: wm2000: Delete an error message for a failed memory
allocation in wm2000_i2c_probe()

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 sound/soc/codecs/wm2000.c | 1 -
 1 file changed, 1 deletion(-)
sound/soc/codecs/wm2000.c +0 -1
index 23cde3a0dc11..ce936deed7e3 100644
@@ -902,7 +902,6 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
 					    wm2000->anc_download_size,
 					    GFP_KERNEL);
 	if (wm2000->anc_download == NULL) {
-		dev_err(&i2c->dev, "Out of memory\n");
 		ret = -ENOMEM;
 		goto err_supplies;
 	}
Signature · 1 line
2.15.0
#4 lore raw

PATCH 2/4 ASoC: wm2000: One function call less in wm2000_i2c_probe() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
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.

---
 sound/soc/codecs/wm2000.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
sound/soc/codecs/wm2000.c +10 -12
index ce936deed7e3..0ed2a8992df4 100644
@@ -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;
 }
 
Signature · 1 line
2.15.0
Acked-by on v1 2/4
#5 lore raw

Re: [PATCH 2/4] ASoC: wm2000: One function call less in wm2000_i2c_probe() after error detection

Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
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.

Quoted 7 lines

* 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.

---

Thanks,
Charles

#6 lore raw

PATCH 3/4 ASoC: wm2000: Fix a typo in a comment line

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 24 Nov 2017 08:02:57 +0100

Delete a duplicate character in a word of this description.

---
 sound/soc/codecs/wm2000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm2000.c +1 -1
index 0ed2a8992df4..2151e75ee5c6 100644
@@ -13,7 +13,7 @@
  * 'wm2000_anc.bin' by default (overridable via platform data) at
  * runtime and is expected to be in flat binary format.  This is
  * generated by Wolfson configuration tools and includes
- * system-specific callibration information.  If supplied as a
+ * system-specific calibration information.  If supplied as a
  * sequence of ASCII-encoded hexidecimal bytes this can be converted
  * into a flat binary with a command such as this on the command line:
  *
Signature · 1 line
2.15.0
maintainer
#8 lore raw

Applied "ASoC: wm2000: Fix a typo in a comment line" to the asoc tree

In reply to SF Markus Elfring

The patch

ASoC: wm2000: Fix a typo in a comment line

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From cdbd9b0c7211485e08d5128eccf9d0a24d38facd Mon Sep 17 00:00:00 2001

From: Markus Elfring <[email protected]>
Date: Fri, 24 Nov 2017 08:02:57 +0100
Subject: [PATCH] ASoC: wm2000: Fix a typo in a comment line

Delete a duplicate character in a word of this description.

---
 sound/soc/codecs/wm2000.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/wm2000.c +1 -1
index ce936deed7e3..480ceb07c3ed 100644
@@ -13,7 +13,7 @@
  * 'wm2000_anc.bin' by default (overridable via platform data) at
  * runtime and is expected to be in flat binary format.  This is
  * generated by Wolfson configuration tools and includes
- * system-specific callibration information.  If supplied as a
+ * system-specific calibration information.  If supplied as a
  * sequence of ASCII-encoded hexidecimal bytes this can be converted
  * into a flat binary with a command such as this on the command line:
  *
Signature · 1 line
2.15.0
#9 lore raw

PATCH 4/4 ASoC: wm2000: Improve a size determination in wm2000_i2c_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 24 Nov 2017 08:18:14 +0100

Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

---
 sound/soc/codecs/wm2000.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/codecs/wm2000.c +1 -2
index 2151e75ee5c6..86e7f9ebab44 100644
@@ -826,8 +826,7 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
 	int reg;
 	u16 id;
 
-	wm2000 = devm_kzalloc(&i2c->dev, sizeof(struct wm2000_priv),
-			      GFP_KERNEL);
+	wm2000 = devm_kzalloc(&i2c->dev, sizeof(*wm2000), GFP_KERNEL);
 	if (!wm2000)
 		return -ENOMEM;
 
Signature · 1 line
2.15.0
Acked-by on v1 4/4
#10 lore raw

Re: [PATCH 4/4] ASoC: wm2000: Improve a size determination in wm2000_i2c_probe()

Quoted 11 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 24 Nov 2017 08:18:14 +0100

Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

---

Thanks,
Charles

maintainer
#11 lore raw

Applied "ASoC: wm2000: Improve a size determination in wm2000_i2c_probe()" to the asoc tree

In reply to SF Markus Elfring

The patch

ASoC: wm2000: Improve a size determination in wm2000_i2c_probe()

has been applied to the asoc tree at

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark

Quoted 1 line

From bf0842ba3afa85d37b35e65dedec9a994988e346 Mon Sep 17 00:00:00 2001

From: Markus Elfring <[email protected]>
Date: Fri, 24 Nov 2017 08:18:14 +0100
Subject: [PATCH] ASoC: wm2000: Improve a size determination in
wm2000_i2c_probe()

Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

---
 sound/soc/codecs/wm2000.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/codecs/wm2000.c +1 -2
index 480ceb07c3ed..abfa052c07d8 100644
@@ -826,8 +826,7 @@ static int wm2000_i2c_probe(struct i2c_client *i2c,
 	int reg;
 	u16 id;
 
-	wm2000 = devm_kzalloc(&i2c->dev, sizeof(struct wm2000_priv),
-			      GFP_KERNEL);
+	wm2000 = devm_kzalloc(&i2c->dev, sizeof(*wm2000), GFP_KERNEL);
 	if (!wm2000)
 		return -ENOMEM;
 
Signature · 1 line
2.15.0