Skip to contentSkip to conversation

HSI: omap_ssi: Fine-tuning for two function implementations

PATCH In review SF Markus Elfring 4 participants 7 messages Apr 25, 2017 – May 1, 2017

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

cover HSI: omap_ssi: Fine-tuning for two function implementations

From: Markus Elfring <[email protected]>
Date: Tue, 25 Apr 2017 12:52:10 +0200

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

Markus Elfring (3):
Use devm_kcalloc() in ssi_add_controller()
Fix a typo in a comment line
Delete an error message for a failed memory allocation in ssi_add_controller()

 drivers/hsi/controllers/omap_ssi_core.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
Signature · 1 line
2.12.2
#1 lore raw

PATCH 1/3 HSI: omap_ssi: Use devm_kcalloc() in ssi_add_controller()

From: Markus Elfring <[email protected]>
Date: Tue, 25 Apr 2017 11:20:41 +0200

* A multiplication for the size determination of a memory allocation indicated that an array data structure should be processed. Thus use the corresponding function "devm_kcalloc".

This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention.

---
 drivers/hsi/controllers/omap_ssi_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hsi/controllers/omap_ssi_core.c +2 -2
index 9a29b34ed2c8..464db6d33afb 100644
@@ -421,8 +421,8 @@ static int ssi_add_controller(struct hsi_controller *ssi,
 		goto out_err;
 	}
 
-	omap_ssi->port = devm_kzalloc(&ssi->device,
-		sizeof(struct omap_ssi_port *) * ssi->num_ports, GFP_KERNEL);
+	omap_ssi->port = devm_kcalloc(&ssi->device, ssi->num_ports,
+				      sizeof(*omap_ssi->port), GFP_KERNEL);
 	if (!omap_ssi->port) {
 		err = -ENOMEM;
 		goto out_err;
Signature · 1 line
2.12.2
#2 lore raw

PATCH 2/3 HSI: omap_ssi: Fix a typo in a comment line

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 25 Apr 2017 11:35:11 +0200

Add a missing character in this description for a function call.

---
 drivers/hsi/controllers/omap_ssi_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hsi/controllers/omap_ssi_core.c +1 -1
index 464db6d33afb..fb7ed8fce83a 100644
@@ -467,7 +467,7 @@ static int ssi_hw_init(struct hsi_controller *ssi)
 		dev_err(&ssi->device, "runtime PM failed %d\n", err);
 		return err;
 	}
-	/* Reseting GDD */
+	/* Resetting GDD */
 	writel_relaxed(SSI_SWRESET, omap_ssi->gdd + SSI_GDD_GRST_REG);
 	/* Get FCK rate in KHz */
 	omap_ssi->fck_rate = DIV_ROUND_CLOSEST(ssi_get_clk_rate(ssi), 1000);
Signature · 1 line
2.12.2
#3 lore raw

PATCH 3/3 HSI: omap_ssi: Delete an error message for a failed memory allocation in ssi_add_controller()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 25 Apr 2017 12:42:14 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: Possible unnecessary 'out of memory' message

Thus remove such a statement here.

---
 drivers/hsi/controllers/omap_ssi_core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/hsi/controllers/omap_ssi_core.c +1 -3
index fb7ed8fce83a..88e48b346916 100644
@@ -384,10 +384,8 @@ static int ssi_add_controller(struct hsi_controller *ssi,
 	int err;
 
 	omap_ssi = devm_kzalloc(&ssi->device, sizeof(*omap_ssi), GFP_KERNEL);
-	if (!omap_ssi) {
-		dev_err(&pd->dev, "not enough memory for omap ssi\n");
+	if (!omap_ssi)
 		return -ENOMEM;
-	}
 
 	err = ida_simple_get(&platform_omap_ssi_ida, 0, 0, GFP_KERNEL);
 	if (err < 0)
Signature · 1 line
2.12.2
#4 lore raw

Re: [PATCH 3/3] HSI: omap_ssi: Delete an error message for a failed memory allocation in ssi_add_controller()

Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 25 Apr 2017 12:42:14 +0200

The script "checkpatch.pl" pointed information out like the following.

WARNING: Possible unnecessary 'out of memory' message

Thus remove such a statement here.

Any reason to believe it is good idea besides program telling you it _might_ be?
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#5 lore raw

Re: [PATCH 3/3] HSI: omap_ssi: Delete an error message for a failed memory allocation in ssi_add_controller()

1) That allocation will never fail in real life so it's dead code.
2) kmalloc and friends already have much better builtin in error messages so it's useless.
3) There is a small memory savings from removing it.

I'm not saying you should apply the patch, I'm just saying that these messages are pointless and detrimental.

regards,
an carpenter

#6 lore raw
In reply to SF Markus Elfring

Hi,

Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 25 Apr 2017 12:52:10 +0200

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

Quoted 7 lines

Markus Elfring (3):
Use devm_kcalloc() in ssi_add_controller()
Fix a typo in a comment line
Delete an error message for a failed memory allocation in ssi_add_controller()

 drivers/hsi/controllers/omap_ssi_core.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

Thanks for your patchset. We are currently in the merge window and your patch will appear in linux-next once 4.12-rc1 has been tagged by Linus Torvalds.

Until then I queued it into this branch:

https://git.kernel.org/cgit/linux/kernel/git/sre/linux-hsi.git/log/?h=for-next-next

-- Sebastian