Skip to contentSkip to conversation

HSI: nokia-modem: Fine-tuning for two function implementations

PATCH In review SF Markus Elfring 2 participants 5 messages Apr 25, 2017 – May 1, 2017

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

cover HSI: nokia-modem: Fine-tuning for two function implementations

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

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

Markus Elfring (3):
Use devm_kcalloc() in nokia_modem_gpio_probe()
Delete error messages for a failed memory allocation in two functions Add a space character for better code readability in nokia_modem_probe()

 drivers/hsi/clients/nokia-modem.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)
Signature · 1 line
2.12.2
#1 lore raw

PATCH 1/3 HSI: nokia-modem: Use devm_kcalloc() in nokia_modem_gpio_probe()

From: Markus Elfring <[email protected]>
Date: Tue, 25 Apr 2017 09:49:22 +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 structure by a pointer dereference to make the corresponding size determination a bit safer according to the Linux coding style convention.

---
 drivers/hsi/clients/nokia-modem.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hsi/clients/nokia-modem.c +2 -2
index c000780d931f..f6c97a0e1fcd 100644
@@ -102,8 +102,8 @@ static int nokia_modem_gpio_probe(struct device *dev)
 		return -EINVAL;
 	}
 
-	modem->gpios = devm_kzalloc(dev, gpio_count *
-				sizeof(struct nokia_modem_gpio), GFP_KERNEL);
+	modem->gpios = devm_kcalloc(dev, gpio_count, sizeof(*modem->gpios),
+				    GFP_KERNEL);
 	if (!modem->gpios) {
 		dev_err(dev, "Could not allocate memory for gpios\n");
 		return -ENOMEM;
Signature · 1 line
2.12.2
#2 lore raw

PATCH 2/3 HSI: nokia-modem: Delete error messages for a failed memory allocation in two functions

In reply to SF Markus Elfring

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

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

WARNING: Possible unnecessary 'out of memory' message

Thus remove such statements here.

---
 drivers/hsi/clients/nokia-modem.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/hsi/clients/nokia-modem.c +3 -6
index f6c97a0e1fcd..a774ca7839e1 100644
@@ -104,10 +104,8 @@ static int nokia_modem_gpio_probe(struct device *dev)
 
 	modem->gpios = devm_kcalloc(dev, gpio_count, sizeof(*modem->gpios),
 				    GFP_KERNEL);
-	if (!modem->gpios) {
-		dev_err(dev, "Could not allocate memory for gpios\n");
+	if (!modem->gpios)
 		return -ENOMEM;
-	}
 
 	modem->gpio_amount = gpio_count;
 
@@ -156,10 +154,9 @@ static int nokia_modem_probe(struct device *dev)
 	}
 
 	modem = devm_kzalloc(dev, sizeof(*modem), GFP_KERNEL);
-	if (!modem) {
-		dev_err(dev, "Could not allocate memory for nokia_modem_device\n");
+	if (!modem)
 		return -ENOMEM;
-	}
+
 	dev_set_drvdata(dev, modem);
 	modem->device = dev;
 
Signature · 1 line
2.12.2
#3 lore raw

PATCH 3/3 HSI: nokia-modem: Add a space character for better code readability in nokia_modem_probe()

In reply to SF Markus Elfring

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

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

ERROR: space required before the open parenthesis '('

Thus fix the affected source code place.

---
 drivers/hsi/clients/nokia-modem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hsi/clients/nokia-modem.c +1 -1
index a774ca7839e1..f78cca98266f 100644
@@ -179,7 +179,7 @@ static int nokia_modem_probe(struct device *dev)
 	}
 	enable_irq_wake(irq);
 
-	if(pm) {
+	if (pm) {
 		err = nokia_modem_gpio_probe(dev);
 		if (err < 0) {
 			dev_err(dev, "Could not probe GPIOs\n");
Signature · 1 line
2.12.2
#4 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 10:36:54 +0200

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

Quoted 7 lines

Markus Elfring (3):
Use devm_kcalloc() in nokia_modem_gpio_probe()
Delete error messages for a failed memory allocation in two functions Add a space character for better code readability in nokia_modem_probe()

 drivers/hsi/clients/nokia-modem.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 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