Skip to contentSkip to conversation

Freescale VIU: Adjustments for five function implementations

PATCH New SF Markus Elfring 1 participant 4 messages Sep 8, 2017

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

cover Freescale VIU: Adjustments for five function implementations

From: Markus Elfring <[email protected]>
Date: Fri, 8 Sep 2017 21:28:12 +0200

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

Markus Elfring (3):
Delete an error message for a failed memory allocation in viu_of_probe() Improve two size determinations in viu_of_probe()
Adjust six checks for null pointers

 drivers/media/platform/fsl-viu.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/3 fsl-viu: Delete an error message for a failed memory allocation in viu_of_probe()

From: Markus Elfring <[email protected]>
Date: Fri, 8 Sep 2017 21:03:22 +0200

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

---
 drivers/media/platform/fsl-viu.c | 1 -
 1 file changed, 1 deletion(-)
drivers/media/platform/fsl-viu.c +0 -1
index fb43025df573..526f80649864 100644
@@ -1433,5 +1433,4 @@ static int viu_of_probe(struct platform_device *op)
 	if (!viu_dev) {
-		dev_err(&op->dev, "Can't allocate private structure\n");
 		ret = -ENOMEM;
 		goto err;
 	}
Signature · 1 line
2.14.1
#2 lore raw

PATCH 2/3 fsl-viu: Improve two size determinations in viu_of_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 8 Sep 2017 21:12:52 +0200

Replace the specification of data structures by pointer dereferences 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.

---
 drivers/media/platform/fsl-viu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/media/platform/fsl-viu.c +2 -2
index 526f80649864..1fe2a295db93 100644
@@ -1421,5 +1421,5 @@ static int viu_of_probe(struct platform_device *op)
 	}
 
 	/* remap registers */
-	viu_regs = devm_ioremap(&op->dev, r.start, sizeof(struct viu_reg));
+	viu_regs = devm_ioremap(&op->dev, r.start, sizeof(*viu_regs));
 	if (!viu_regs) {
@@ -1429,5 +1429,5 @@ static int viu_of_probe(struct platform_device *op)
 	}
 
 	/* Prepare our private structure */
-	viu_dev = devm_kzalloc(&op->dev, sizeof(struct viu_dev), GFP_ATOMIC);
+	viu_dev = devm_kzalloc(&op->dev, sizeof(*viu_dev), GFP_ATOMIC);
 	if (!viu_dev) {
Signature · 1 line
2.14.1
#3 lore raw

PATCH 3/3 fsl-viu: Adjust six checks for null pointers

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 8 Sep 2017 21:16:50 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

---
 drivers/media/platform/fsl-viu.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/media/platform/fsl-viu.c +6 -6
index 1fe2a295db93..a133dfdd869a 100644
@@ -313,7 +313,7 @@ static int restart_video_queue(struct viu_dmaqueue *vidq)
 		if (list_empty(&vidq->queued))
 			return 0;
 		buf = list_entry(vidq->queued.next, struct viu_buf, vb.queue);
-		if (prev = NULL) {
+		if (!prev) {
 			list_move_tail(&buf->vb.queue, &vidq->active);
 
 			dprintk(1, "Restarting video dma\n");
@@ -450,7 +450,7 @@ static int buffer_prepare(struct videobuf_queue *vq,
 	struct viu_buf *buf = container_of(vb, struct viu_buf, vb);
 	int rc;
 
-	BUG_ON(fh->fmt = NULL);
+	BUG_ON(!fh->fmt);
 
 	if (fh->width  < 48 || fh->width  > norm_maxw() ||
 	    fh->height < 32 || fh->height > norm_maxh())
@@ -668,9 +668,9 @@ static int verify_preview(struct viu_dev *dev, struct v4l2_window *win)
 	enum v4l2_field field;
 	int maxw, maxh;
 
-	if (dev->ovbuf.base = NULL)
+	if (!dev->ovbuf.base)
 		return -EINVAL;
-	if (dev->ovfmt = NULL)
+	if (!dev->ovfmt)
 		return -EINVAL;
 	if (win->w.width < 48 || win->w.height < 32)
 		return -EINVAL;
@@ -825,7 +825,7 @@ int vidioc_s_fbuf(struct file *file, void *priv, const struct v4l2_framebuffer *
 
 	/* check args */
 	fmt = format_by_fourcc(fb->fmt.pixelformat);
-	if (fmt = NULL)
+	if (!fmt)
 		return -EINVAL;
 
 	/* ok, accept it */
@@ -1472,7 +1472,7 @@ static int viu_of_probe(struct platform_device *op)
 
 	/* Allocate memory for video device */
 	vdev = video_device_alloc();
-	if (vdev = NULL) {
+	if (!vdev) {
 		ret = -ENOMEM;
 		goto err_vdev;
 	}
Signature · 1 line
2.14.1