[alsa-devel] [PATCH 0/4] ALSA SoC TWL4030: Adjustments for two function implementations
From: Markus Elfring elfring@users.sourceforge.net Date: Thu, 23 Nov 2017 22:02:44 +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 in twl4030_get_pdata() Use common error handling code in twl4030_get_pdata() Improve a size determination in two functions Delete an unnecessary variable initialisation in twl4030_get_pdata()
sound/soc/codecs/twl4030.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
From: Markus Elfring elfring@users.sourceforge.net Date: Thu, 23 Nov 2017 21:30:07 +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/twl4030.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index cfe72b9d4356..90691701b082 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -240,7 +240,6 @@ static struct twl4030_codec_data *twl4030_get_pdata(struct snd_soc_codec *codec) sizeof(struct twl4030_codec_data), GFP_KERNEL); if (!pdata) { - dev_err(codec->dev, "Can not allocate memory\n"); of_node_put(twl4030_codec_node); return NULL; }
The patch
ASoC: twl4030: Delete an error message for a failed memory allocation in twl4030_get_pdata()
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 2dbb29cd977fc281f71f8895abce7e382efe77e1 Mon Sep 17 00:00:00 2001
From: Markus Elfring elfring@users.sourceforge.net Date: Thu, 23 Nov 2017 21:30:07 +0100 Subject: [PATCH] ASoC: twl4030: Delete an error message for a failed memory allocation in twl4030_get_pdata()
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 Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/codecs/twl4030.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index cfe72b9d4356..90691701b082 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -240,7 +240,6 @@ static struct twl4030_codec_data *twl4030_get_pdata(struct snd_soc_codec *codec) sizeof(struct twl4030_codec_data), GFP_KERNEL); if (!pdata) { - dev_err(codec->dev, "Can not allocate memory\n"); of_node_put(twl4030_codec_node); return NULL; }
From: Markus Elfring elfring@users.sourceforge.net Date: Thu, 23 Nov 2017 21:35:28 +0100
Add a jump target so that a bit of exception handling can be better reused in an if branch of this function.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net --- sound/soc/codecs/twl4030.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 90691701b082..a1f0b45c83ca 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -239,11 +239,11 @@ static struct twl4030_codec_data *twl4030_get_pdata(struct snd_soc_codec *codec) pdata = devm_kzalloc(codec->dev, sizeof(struct twl4030_codec_data), GFP_KERNEL); - if (!pdata) { - of_node_put(twl4030_codec_node); - return NULL; - } + if (!pdata) + goto put_node; + twl4030_setup_pdata_of(pdata, twl4030_codec_node); +put_node: of_node_put(twl4030_codec_node); }
From: Markus Elfring elfring@users.sourceforge.net Date: Thu, 23 Nov 2017 21:45:55 +0100
Replace the specification of data structures by pointer dereferences 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/twl4030.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index a1f0b45c83ca..946818a0412c 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -236,9 +236,7 @@ static struct twl4030_codec_data *twl4030_get_pdata(struct snd_soc_codec *codec) "codec");
if (!pdata && twl4030_codec_node) { - pdata = devm_kzalloc(codec->dev, - sizeof(struct twl4030_codec_data), - GFP_KERNEL); + pdata = devm_kzalloc(codec->dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) goto put_node;
@@ -2168,8 +2166,7 @@ static int twl4030_soc_probe(struct snd_soc_codec *codec) { struct twl4030_priv *twl4030;
- twl4030 = devm_kzalloc(codec->dev, sizeof(struct twl4030_priv), - GFP_KERNEL); + twl4030 = devm_kzalloc(codec->dev, sizeof(*twl4030), GFP_KERNEL); if (!twl4030) return -ENOMEM; snd_soc_codec_set_drvdata(codec, twl4030);
From: Markus Elfring elfring@users.sourceforge.net Date: Thu, 23 Nov 2017 21:54:10 +0100
The variable "twl4030_codec_node" will be reassigned by a following statement. Thus omit the explicit initialisation at the beginning.
Signed-off-by: Markus Elfring elfring@users.sourceforge.net --- sound/soc/codecs/twl4030.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 946818a0412c..3ea6117beceb 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c @@ -230,7 +230,7 @@ static void twl4030_setup_pdata_of(struct twl4030_codec_data *pdata, static struct twl4030_codec_data *twl4030_get_pdata(struct snd_soc_codec *codec) { struct twl4030_codec_data *pdata = dev_get_platdata(codec->dev); - struct device_node *twl4030_codec_node = NULL; + struct device_node *twl4030_codec_node;
twl4030_codec_node = of_get_child_by_name(codec->dev->parent->of_node, "codec");
On 2017-11-23 23:07, SF Markus Elfring wrote:
From: Markus Elfring elfring@users.sourceforge.net Date: Thu, 23 Nov 2017 22:02:44 +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 in twl4030_get_pdata() Use common error handling code in twl4030_get_pdata() Improve a size determination in two functions Delete an unnecessary variable initialisation in twl4030_get_pdata()
All: Acked-by: Peter Ujfalusi peter.ujfalusi@ti.com
sound/soc/codecs/twl4030.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
- Péter
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
participants (3)
-
Mark Brown
-
Peter Ujfalusi
-
SF Markus Elfring