Skip to contentSkip to conversation

ALSA SoC TWL4030: Adjustments for two function implementations

PATCH In review SF Markus Elfring 3 participants 7 messages Nov 23, 2017 – Dec 4, 2017

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

cover ALSA SoC TWL4030: Adjustments for two function implementations

From: Markus Elfring <[email protected]>
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(-)
Signature · 1 line
2.15.0
#1 lore raw

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

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

---
 sound/soc/codecs/twl4030.c | 1 -
 1 file changed, 1 deletion(-)
sound/soc/codecs/twl4030.c +0 -1
index cfe72b9d4356..90691701b082 100644
@@ -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;
 		}
Signature · 1 line
2.15.0
maintainer
#2 lore raw

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

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

Quoted 1 line

From 2dbb29cd977fc281f71f8895abce7e382efe77e1 Mon Sep 17 00:00:00 2001

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

---
 sound/soc/codecs/twl4030.c | 1 -
 1 file changed, 1 deletion(-)
sound/soc/codecs/twl4030.c +0 -1
index cfe72b9d4356..90691701b082 100644
@@ -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;
 		}
Signature · 1 line
2.15.0
#3 lore raw

PATCH 2/4 ASoC: twl4030: Use common error handling code in twl4030_get_pdata()

In reply to SF Markus Elfring

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

---
 sound/soc/codecs/twl4030.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/twl4030.c +4 -4
index 90691701b082..a1f0b45c83ca 100644
@@ -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);
 	}
 
Signature · 1 line
2.15.0
#4 lore raw

PATCH 3/4 ASoC: twl4030: Improve a size determination in two functions

In reply to SF Markus Elfring

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

---
 sound/soc/codecs/twl4030.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
sound/soc/codecs/twl4030.c +2 -5
index a1f0b45c83ca..946818a0412c 100644
@@ -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);
Signature · 1 line
2.15.0
#5 lore raw

PATCH 4/4 ASoC: twl4030: Delete an unnecessary variable initialisation in twl4030_get_pdata()

In reply to SF Markus Elfring

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

---
 sound/soc/codecs/twl4030.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/codecs/twl4030.c +1 -1
index 946818a0412c..3ea6117beceb 100644
@@ -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");
Signature · 1 line
2.15.0
Acked-by on the v1 series
#6 lore raw
In reply to SF Markus Elfring
Quoted 11 lines · SF Markus Elfring

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

Quoted 4 lines
 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
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel