Skip to contentSkip to conversation

ASoC: da7218: Adjustments for two function implementations

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

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

cover ASoC: da7218: Adjustments for two function implementations

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

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

Markus Elfring (3):
Delete two error messages for a failed memory allocation

    in da7218_of_to_pdata()

Use common error handling code in da7218_of_to_pdata() Improve a size determination in da7218_i2c_probe()

 sound/soc/codecs/da7218.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
Signature · 1 line
2.15.0
#1 lore raw

PATCH 1/3 ASoC: da7218: Delete two error messages for a failed memory allocation in da7218_of_to_pdata()

From: Markus Elfring <[email protected]>
Date: Thu, 23 Nov 2017 20:42:20 +0100

Omit extra messages for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 sound/soc/codecs/da7218.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
sound/soc/codecs/da7218.c +1 -5
index 56564ce90cb6..25ab7443d803 100644
@@ -2455,10 +2455,8 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec)
 	u32 of_val32;
 
 	pdata = devm_kzalloc(codec->dev, sizeof(*pdata), GFP_KERNEL);
-	if (!pdata) {
-		dev_warn(codec->dev, "Failed to allocate memory for pdata\n");
+	if (!pdata)
 		return NULL;
-	}
 
 	if (of_property_read_u32(np, "dlg,micbias1-lvl-millivolt", &of_val32) >= 0)
 		pdata->micbias1_lvl = da7218_of_micbias_lvl(codec, of_val32);
@@ -2527,8 +2525,6 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec)
 		hpldet_pdata = devm_kzalloc(codec->dev, sizeof(*hpldet_pdata),
 					    GFP_KERNEL);
 		if (!hpldet_pdata) {
-			dev_warn(codec->dev,
-				 "Failed to allocate memory for hpldet pdata\n");
 			of_node_put(hpldet_np);
 			return pdata;
 		}
Signature · 1 line
2.15.0
#4 lore raw

PATCH 2/3 ASoC: da7218: Use common error handling code in da7218_of_to_pdata()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 23 Nov 2017 20:48:05 +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/da7218.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
sound/soc/codecs/da7218.c +4 -4
index 25ab7443d803..93a0cb741751 100644
@@ -2524,10 +2524,9 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec)
 
 		hpldet_pdata = devm_kzalloc(codec->dev, sizeof(*hpldet_pdata),
 					    GFP_KERNEL);
-		if (!hpldet_pdata) {
-			of_node_put(hpldet_np);
-			return pdata;
-		}
+		if (!hpldet_pdata)
+			goto put_node;
+
 		pdata->hpldet_pdata = hpldet_pdata;
 
 		if (of_property_read_u32(hpldet_np, "dlg,jack-rate-us",
@@ -2561,6 +2560,7 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec)
 		if (of_property_read_bool(hpldet_np, "dlg,discharge"))
 			hpldet_pdata->discharge = true;
 
+put_node:
 		of_node_put(hpldet_np);
 	}
 
Signature · 1 line
2.15.0
#9 lore raw

PATCH 3/3 ASoC: da7218: Improve a size determination in da7218_i2c_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 23 Nov 2017 20:50:44 +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/da7218.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/codecs/da7218.c +1 -2
index 93a0cb741751..0c1933a98995 100644
@@ -3269,8 +3269,7 @@ static int da7218_i2c_probe(struct i2c_client *i2c,
 	struct da7218_priv *da7218;
 	int ret;
 
-	da7218 = devm_kzalloc(&i2c->dev, sizeof(struct da7218_priv),
-			      GFP_KERNEL);
+	da7218 = devm_kzalloc(&i2c->dev, sizeof(*da7218), GFP_KERNEL);
 	if (!da7218)
 		return -ENOMEM;
 
Signature · 1 line
2.15.0
Acked-by on v1 1/3
#2 lore raw

RE: [PATCH 1/3] ASoC: da7218: Delete two error messages for a failed memory allocation in da7218_of_to_pdata()

In reply to SF Markus Elfring

T24gMjMgTm92ZW1iZXIgMjAxNyAyMDowNSwgU0YgTWFya3VzIEVsZnJpbmcgd3JvdGU6DQoNCj4g RnJvbTogTWFya3VzIEVsZnJpbmcgPGVsZnJpbmdAdXNlcnMuc291cmNlZm9yZ2UubmV0Pg0KPiBE YXRlOiBUaHUsIDIzIE5vdiAyMDE3IDIwOjQyOjIwICswMTAwDQo+IA0KPiBPbWl0IGV4dHJhIG1l c3NhZ2VzIGZvciBhIG1lbW9yeSBhbGxvY2F0aW9uIGZhaWx1cmUgaW4gdGhpcyBmdW5jdGlvbi4N Cj4gDQo+IFRoaXMgaXNzdWUgd2FzIGRldGVjdGVkIGJ5IHVzaW5nIHRoZSBDb2NjaW5lbGxlIHNv ZnR3YXJlLg0KPiANCj4gU2lnbmVkLW9mZi1ieTogTWFya3VzIEVsZnJpbmcgPGVsZnJpbmdAdXNl cnMuc291cmNlZm9yZ2UubmV0Pg0KDQpBY2tlZC1ieTogQWRhbSBUaG9tc29uIDxBZGFtLlRob21z b24uT3BlbnNvdXJjZUBkaWFzZW1pLmNvbT4NCg0KPiAtLS0NCj4gIHNvdW5kL3NvYy9jb2RlY3Mv ZGE3MjE4LmMgfCA2ICstLS0tLQ0KPiAgMSBmaWxlIGNoYW5nZWQsIDEgaW5zZXJ0aW9uKCspLCA1 IGRlbGV0aW9ucygtKQ0KPiANCj4gZGlmZiAtLWdpdCBhL3NvdW5kL3NvYy9jb2RlY3MvZGE3MjE4 LmMgYi9zb3VuZC9zb2MvY29kZWNzL2RhNzIxOC5jDQo+IGluZGV4IDU2NTY0Y2U5MGNiNi4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bXNvbi5PcGVuc291cmNlQGRp YXNlbWkuY29tPg0KDQo+IC0tLQ0KPiAgc291bmQvc29jL2NvZGVjcy9kYTcyMTguYyB8IDMgKy0t DQo+ICAxIGZpbGUgY2hhbmdlZCwgMSBpbnNlcnRpb24oKyksIDIgZGVsZXRpb25zKC0pDQo+IA0K PiBkaWZmIC0tZ2l0IGEvc291bmQvc29jL2NvZGVjcy9kYTcyMTguYyBiL3NvdW5kL3NvYy9jb2Rl Y3MvZGE3MjE4LmMNCj4gaW5kZXggOTNhMGNiNzQxNzUxLi4wYzE5MzNhOTg5OTUgMTAwNjQ0DQo+ IC0tLSBhL3NvdW5kL3NvYy9jb2RlY3MvZGE3MjE4LmMNCj4gKysrIGIvc291bmQvc29jL2NvZGVj cy9kYTcyMTguYw0KPiBAQCAtMzI2OSw4ICszMjY5LDcgQEAgc3RhdGljIGludCBkYTcyMThfaTJj X3Byb2JlKHN0cnVjdCBpMmNfY2xpZW50ICppMmMsDQo+ICAJc3RydWN0IGRhNzIxOF9wcml2ICpk YTcyMTg7DQo+ICAJaW50IHJldDsNCj4gDQo+IC0JZGE3MjE4ID0gZGV2bV9remFsbG9jKCZpMmMt PmRldiwgc2l6ZW9mKHN0cnVjdCBkYTcyMThfcHJpdiksDQo+IC0JCQkgICAgICBHRlBfS0VSTkVM KTsNCj4gKwlkYTcyMTggPSBkZXZtX2t6YWxsb2MoJmkyYy0+ZGV2LCBzaXplb2YoKmRhNzIxOCks IEdGUF9LRVJORUwpOw0KPiAgCWlmICghZGE3MjE4KQ0KPiAgCQlyZXR1cm4gLUVOT01FTTsNCj4g DQo+IC0tDQo+IDIuMTUuMA0KDQo

#5 lore raw

RE: [PATCH 2/3] ASoC: da7218: Use common error handling code in da7218_of_to_pdata()

In reply to SF Markus Elfring

T24gMjMgTm92ZW1iZXIgMjAxNyAyMDowNiwgU0YgTWFya3VzIEVsZnJpbmcgd3JvdGU6DQoNCj4g RnJvbTogTWFya3VzIEVsZnJpbmcgPGVsZnJp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0K

#6 lore raw

Re: ASoC: da7218: Use common error handling code in da7218_of_to_pdata()

Quoted 2 lines
Quoted 2 lines

Add a jump target so that a bit of exception handling can be better reused in an if branch of this function.

…

Quoted 1 line

Hmm. Doesn't really gain an awful lot this.

I show just another small change possibility.

Quoted 2 lines

Would understand if there were multiple return paths, but in that case I'd have implemented something like this anyway.

Where?

Can the suggested software refactoring become useful also for this function implementation?

Quoted 1 line

Also your patch description isn't really correct.

Which wording would you find more appropriate?

Quoted 1 line

You're re-using code from the sunny day scenario to handle an exception.

Can this detail be better?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#7 lore raw

Re: [PATCH 2/3] ASoC: da7218: Use common error handling code in da7218_of_to_pdata()

In reply to Adam Thomson
Quoted 9 lines · Adam Thomson
Quoted 2 lines · SF Markus Elfring

Add a jump target so that a bit of exception handling can be better reused in an if branch of this function.

Hmm. Doesn't really gain an awful lot this. Would understand if there were multiple return paths, but in that case I'd have implemented something like this anyway. Also your patch description isn't really correct. You're re-using code from the sunny day scenario to handle an exception.

Other people have given him similar feedback on his other patches with this pattern. I'm not intending to apply any of them.

#8 lore raw

Re: ASoC: da7218: Use common error handling code in da7218_of_to_pdata()

Quoted 10 lines
Quoted 7 lines
Quoted 2 lines

Add a jump target so that a bit of exception handling can be better reused in an if branch of this function.

Hmm. Doesn't really gain an awful lot this. Would understand if there were multiple return paths, but in that case I'd have implemented something like this anyway. Also your patch description isn't really correct. You're re-using code from the sunny day scenario to handle an exception.

Other people have given him similar feedback on his other patches with this pattern. I'm not intending to apply any of them.

I can offer another bit of information for a software development discussion. 💭

The affected source file can be compiled for the processor architecture “x86_64� by a tool like “GCC 6.4.1+r251631-1.3� from the software distribution “openSUSE Tumbleweed� with the following command example.

my_cc=/usr/bin/gcc-6 \
&& my_module=sound/soc/codecs/da7218.o \
&& for XYZ in 0 s 3; do echo " _____ $XYZ _____" \
&& my_extra="-O$XYZ" \
&& git checkout ':/^ASoC: da7218: Delete two error messages for a failed memory allocation in da7218_of_to_pdata' \
&& make -j4 CC="${my_cc}" HOSTCC="${my_cc}" EXTRA_CFLAGS="${my_extra}" allmodconfig "${my_module}" \
&& size "${my_module}" \
&& git checkout ':/^ASoC: da7218: Use common error handling code in da7218_of_to_pdata' \
&& make -j4 CC="${my_cc}" HOSTCC="${my_cc}" EXTRA_CFLAGS="${my_extra}" allmodconfig "${my_module}" \
&& size "${my_module}"; done

🔮 Do you find the following differences worth for further clarification?

╔���������╤������╗ ║ setting │ text ║
╠���������╪������╣

║   O0    │ -25  ║
║   Os    │ -14  ║
║   O3    │ +11  ║

╚���������╧�������

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#11 lore raw

Applied "ASoC: da7218: Improve a size determination in da7218_i2c_probe()" to the asoc tree

In reply to SF Markus Elfring

The patch

ASoC: da7218: Improve a size determination in da7218_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 392b79e20b41cfdc174d31bd4b004bbd874de4d9 Mon Sep 17 00:00:00 2001

From: Markus Elfring <[email protected]>
Date: Thu, 23 Nov 2017 20:50:44 +0100
Subject: [PATCH] ASoC: da7218: Improve a size determination in
da7218_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/da7218.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/codecs/da7218.c +1 -2
index 25ab7443d803..96c644a15b11 100644
@@ -3269,8 +3269,7 @@ static int da7218_i2c_probe(struct i2c_client *i2c,
 	struct da7218_priv *da7218;
 	int ret;
 
-	da7218 = devm_kzalloc(&i2c->dev, sizeof(struct da7218_priv),
-			      GFP_KERNEL);
+	da7218 = devm_kzalloc(&i2c->dev, sizeof(*da7218), GFP_KERNEL);
 	if (!da7218)
 		return -ENOMEM;
 
Signature · 1 line
2.15.0
maintainer
#3 lore raw

Applied "ASoC: da7218: Delete two error messages for a failed memory allocation in da7218_of_to_pdata()" to the asoc tree

In reply to SF Markus Elfring

The patch

ASoC: da7218: Delete two error messages for a failed memory allocation in da7218_of_to_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 14a07f1d8c4c64af29566316df0415052e8bdfe4 Mon Sep 17 00:00:00 2001

From: Markus Elfring <[email protected]>
Date: Thu, 23 Nov 2017 20:42:20 +0100
Subject: [PATCH] ASoC: da7218: Delete two error messages for a failed memory
allocation in da7218_of_to_pdata()

Omit extra messages for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 sound/soc/codecs/da7218.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
sound/soc/codecs/da7218.c +1 -5
index 56564ce90cb6..25ab7443d803 100644
@@ -2455,10 +2455,8 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec)
 	u32 of_val32;
 
 	pdata = devm_kzalloc(codec->dev, sizeof(*pdata), GFP_KERNEL);
-	if (!pdata) {
-		dev_warn(codec->dev, "Failed to allocate memory for pdata\n");
+	if (!pdata)
 		return NULL;
-	}
 
 	if (of_property_read_u32(np, "dlg,micbias1-lvl-millivolt", &of_val32) >= 0)
 		pdata->micbias1_lvl = da7218_of_micbias_lvl(codec, of_val32);
@@ -2527,8 +2525,6 @@ static struct da7218_pdata *da7218_of_to_pdata(struct snd_soc_codec *codec)
 		hpldet_pdata = devm_kzalloc(codec->dev, sizeof(*hpldet_pdata),
 					    GFP_KERNEL);
 		if (!hpldet_pdata) {
-			dev_warn(codec->dev,
-				 "Failed to allocate memory for hpldet pdata\n");
 			of_node_put(hpldet_np);
 			return pdata;
 		}
Signature · 1 line
2.15.0