Skip to contentSkip to conversation

blackfin-capture: Fine-tuning for two function implementations

PATCH New SF Markus Elfring 1 participant 3 messages Oct 9, 2016

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

cover blackfin-capture: Fine-tuning for two function implementations

From: Markus Elfring <[email protected]>
Date: Sun, 9 Oct 2016 21:44:33 +0200

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

Markus Elfring (2):
Use kcalloc() in bcap_init_sensor_formats()
Delete an error message for a failed memory allocation in bcap_probe()

 drivers/media/platform/blackfin/bfin_capture.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
Signature · 1 line
2.10.1
#1 lore raw

PATCH 1/2 blackfin-capture: Use kcalloc() in bcap_init_sensor_formats()

From: Markus Elfring <[email protected]>
Date: Sun, 9 Oct 2016 21:12:13 +0200

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

This issue was detected by using the Coccinelle software.

---
 drivers/media/platform/blackfin/bfin_capture.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/platform/blackfin/bfin_capture.c +1 -1
index 8eb0339..c5e1043 100644
@@ -169,7 +169,7 @@ static int bcap_init_sensor_formats(struct bcap_device *bcap_dev)
 	if (!num_formats)
 		return -ENXIO;
 
-	sf = kzalloc(num_formats * sizeof(*sf), GFP_KERNEL);
+	sf = kcalloc(num_formats, sizeof(*sf), GFP_KERNEL);
 	if (!sf)
 		return -ENOMEM;
 
Signature · 1 line
2.10.1
#2 lore raw

PATCH 2/2 blackfin-capture: Delete an error message for a failed memory allocation

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 9 Oct 2016 21:30:18 +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/media/platform/blackfin/bfin_capture.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/platform/blackfin/bfin_capture.c +1 -3
index c5e1043..2e6edc0 100644
@@ -802,10 +802,8 @@ static int bcap_probe(struct platform_device *pdev)
 	}
 
 	bcap_dev = kzalloc(sizeof(*bcap_dev), GFP_KERNEL);
-	if (!bcap_dev) {
-		v4l2_err(pdev->dev.driver, "Unable to alloc bcap_dev\n");
+	if (!bcap_dev)
 		return -ENOMEM;
-	}
 
 	bcap_dev->cfg = config;
 
Signature · 1 line
2.10.1