Skip to contentSkip to conversation

Motion Eye: Adjustments for meye_probe()

PATCH New SF Markus Elfring 1 participant 3 messages Sep 3, 2017

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

cover Motion Eye: Adjustments for meye_probe()

From: Markus Elfring <[email protected]>
Date: Sun, 3 Sep 2017 15:54:45 +0200

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

Markus Elfring (2):
Delete three error messages for a failed memory allocation Adjust two function calls together with a variable assignment

 drivers/media/pci/meye/meye.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/2 meye: Delete three error messages for a failed memory allocation in meye_probe()

From: Markus Elfring <[email protected]>
Date: Sun, 3 Sep 2017 15:30:04 +0200

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

This issue was detected by using the Coccinelle software.

---
 drivers/media/pci/meye/meye.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/media/pci/meye/meye.c +4 -9
index 9c4a024745de..db36040770a6 100644
@@ -1626,23 +1626,18 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
 	meye.mchip_dev = pcidev;
 
 	meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE);
-	if (!meye.grab_temp) {
-		v4l2_err(v4l2_dev, "grab buffer allocation failed\n");
+	if (!meye.grab_temp)
 		goto outvmalloc;
-	}
 
 	spin_lock_init(&meye.grabq_lock);
 	if (kfifo_alloc(&meye.grabq, sizeof(int) * MEYE_MAX_BUFNBRS,
-				GFP_KERNEL)) {
-		v4l2_err(v4l2_dev, "fifo allocation failed\n");
+			GFP_KERNEL))
 		goto outkfifoalloc1;
-	}
+
 	spin_lock_init(&meye.doneq_lock);
 	if (kfifo_alloc(&meye.doneq, sizeof(int) * MEYE_MAX_BUFNBRS,
-				GFP_KERNEL)) {
-		v4l2_err(v4l2_dev, "fifo allocation failed\n");
+			GFP_KERNEL))
 		goto outkfifoalloc2;
-	}
 
 	meye.vdev = meye_template;
 	meye.vdev.v4l2_dev = &meye.v4l2_dev;
Signature · 1 line
2.14.1
#2 lore raw

PATCH 2/2 meye: Adjust two function calls together with a variable assignment

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Sep 2017 15:41:53 +0200

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

ERROR: do not use assignment in if condition

Thus fix the affected source code places.

---
 drivers/media/pci/meye/meye.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/media/pci/meye/meye.c +4 -3
index db36040770a6..9b69a07c1d5b 100644
@@ -1642,14 +1642,15 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
 	meye.vdev = meye_template;
 	meye.vdev.v4l2_dev = &meye.v4l2_dev;
 
-	ret = -EIO;
-	if ((ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1))) {
+	ret = sony_pic_camera_command(SONY_PIC_COMMAND_SETCAMERA, 1);
+	if (ret) {
 		v4l2_err(v4l2_dev, "meye: unable to power on the camera\n");
 		v4l2_err(v4l2_dev, "meye: did you enable the camera in sonypi using the module options ?\n");
 		goto outsonypienable;
 	}
 
-	if ((ret = pci_enable_device(meye.mchip_dev))) {
+	ret = pci_enable_device(meye.mchip_dev);
+	if (ret) {
 		v4l2_err(v4l2_dev, "meye: pci_enable_device failed\n");
 		goto outenabledev;
 	}
Signature · 1 line
2.14.1