[alsa-devel] [PATCH 0/4] ASoC: wm2000: Adjustments for wm2000_i2c_probe()
From: Markus Elfring elfring@users.sourceforge.net 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(-)
From: Markus Elfring elfring@users.sourceforge.net 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.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net --- sound/soc/codecs/wm2000.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index 23cde3a0dc11..ce936deed7e3 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c @@ -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; }
On Fri, Nov 24, 2017 at 08:36:17AM +0100, SF Markus Elfring wrote:
From: Markus Elfring elfring@users.sourceforge.net 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.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net
Acked-by: Charles Keepax ckeepax@opensource.cirrus.com
Thanks, Charles
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
From e866d87a7de38672f52c6e7567e88c3f82f937dc Mon Sep 17 00:00:00 2001
From: Markus Elfring elfring@users.sourceforge.net 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.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net Acked-by: Charles Keepax ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/codecs/wm2000.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index 23cde3a0dc11..ce936deed7e3 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c @@ -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; }
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; }
On Fri, Nov 24, 2017 at 08:37:41AM +0100, SF Markus Elfring wrote:
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
Acked-by: Charles Keepax ckeepax@opensource.cirrus.com
Thanks, Charles
From: Markus Elfring elfring@users.sourceforge.net Date: Fri, 24 Nov 2017 08:02:57 +0100
Delete a duplicate character in a word of this description.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net --- sound/soc/codecs/wm2000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index 0ed2a8992df4..2151e75ee5c6 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c @@ -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: *
On Fri, Nov 24, 2017 at 08:39:02AM +0100, SF Markus Elfring wrote:
From: Markus Elfring elfring@users.sourceforge.net Date: Fri, 24 Nov 2017 08:02:57 +0100
Delete a duplicate character in a word of this description.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net
Acked-by: Charles Keepax ckeepax@opensource.cirrus.com
Thanks, Charles
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
From cdbd9b0c7211485e08d5128eccf9d0a24d38facd Mon Sep 17 00:00:00 2001
From: Markus Elfring elfring@users.sourceforge.net 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.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net Acked-by: Charles Keepax ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/codecs/wm2000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index ce936deed7e3..480ceb07c3ed 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c @@ -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: *
From: Markus Elfring elfring@users.sourceforge.net 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.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net --- sound/soc/codecs/wm2000.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index 2151e75ee5c6..86e7f9ebab44 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c @@ -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;
On Fri, Nov 24, 2017 at 08:40:22AM +0100, SF Markus Elfring wrote:
From: Markus Elfring elfring@users.sourceforge.net 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.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net
Acked-by: Charles Keepax ckeepax@opensource.cirrus.com
Thanks, Charles
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
From bf0842ba3afa85d37b35e65dedec9a994988e346 Mon Sep 17 00:00:00 2001
From: Markus Elfring elfring@users.sourceforge.net 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.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net Acked-by: Charles Keepax ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/codecs/wm2000.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index 480ceb07c3ed..abfa052c07d8 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c @@ -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;
participants (3)
-
Charles Keepax
-
Mark Brown
-
SF Markus Elfring