staging: vc04_services: bcm2835-camera: Simplify NULL comparisons
authorAishwarya Pant <aishpant@gmail.com>
Tue, 28 Feb 2017 11:22:50 +0000 (16:52 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Mar 2017 08:39:53 +0000 (09:39 +0100)
Remove instances of explicit NULL comparisons in bcm2835-camera driver
for code compaction.

Signed-off-by: Aishwarya Pant <aishpant@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h
drivers/staging/vc04_services/bcm2835-camera/controls.c
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c

index c4dad30dd133904f600ecb31d4a1444d099cd803..1baeef43d80c460872767736901b2c846c8344fa 100644 (file)
@@ -250,7 +250,7 @@ static int queue_setup(struct vb2_queue *vq,
        unsigned long size;
 
        /* refuse queue setup if port is not configured */
-       if (dev->capture.port == NULL) {
+       if (!dev->capture.port) {
                v4l2_err(&dev->v4l2_dev,
                         "%s: capture port not configured\n", __func__);
                return -EINVAL;
@@ -289,8 +289,8 @@ static int buffer_prepare(struct vb2_buffer *vb)
        v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p\n",
                 __func__, dev);
 
-       BUG_ON(dev->capture.port == NULL);
-       BUG_ON(dev->capture.fmt == NULL);
+       BUG_ON(!dev->capture.port);
+       BUG_ON(!dev->capture.fmt);
 
        size = dev->capture.stride * dev->capture.height;
        if (vb2_plane_size(vb, 0) < size) {
@@ -324,14 +324,14 @@ static void buffer_cb(struct vchiq_mmal_instance *instance,
 
        if (status != 0) {
                /* error in transfer */
-               if (buf != NULL) {
+               if (buf) {
                        /* there was a buffer with the error so return it */
                        vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
                }
                return;
        } else if (length == 0) {
                /* stream ended */
-               if (buf != NULL) {
+               if (buf) {
                        /* this should only ever happen if the port is
                         * disabled and there are buffers still queued
                         */
@@ -513,7 +513,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
                 __func__, dev);
 
        /* ensure a format has actually been set */
-       if (dev->capture.port == NULL)
+       if (!dev->capture.port)
                return -EINVAL;
 
        if (enable_camera(dev) < 0) {
@@ -604,7 +604,7 @@ static void stop_streaming(struct vb2_queue *vq)
        dev->capture.frame_count = 0;
 
        /* ensure a format has actually been set */
-       if (dev->capture.port == NULL) {
+       if (!dev->capture.port) {
                v4l2_err(&dev->v4l2_dev,
                         "no capture port - stream not started?\n");
                return;
index e6aeb7e7e381de65d6c6586205069a4c5cd33274..e5bbc6c47ed1b9d6151264fa93486764c0170201 100644 (file)
@@ -125,7 +125,7 @@ int set_framerate_params(struct bm2835_mmal_dev *dev);
 {      \
        v4l2_dbg(level, debug, dev,     \
 "%s: w %u h %u field %u pfmt 0x%x bpl %u sz_img %u colorspace 0x%x priv %u\n", \
-               desc == NULL ? "" : desc,       \
+               !desc ? "" : desc,      \
                (pix_fmt)->width, (pix_fmt)->height, (pix_fmt)->field,  \
                (pix_fmt)->pixelformat, (pix_fmt)->bytesperline,        \
                (pix_fmt)->sizeimage, (pix_fmt)->colorspace, (pix_fmt)->priv); \
@@ -135,7 +135,7 @@ int set_framerate_params(struct bm2835_mmal_dev *dev);
        v4l2_dbg(level, debug, dev,     \
 "%s: w %u h %u l %u t %u  field %u chromakey %06X clip %p " \
 "clipcount %u bitmap %p\n", \
-               desc == NULL ? "" : desc,       \
+               !desc ? "" : desc,      \
                (win_fmt)->w.width, (win_fmt)->w.height, \
                (win_fmt)->w.left, (win_fmt)->w.top, \
                (win_fmt)->field,       \
index 4d7e2a2976c29a86942d0c51c195ea46d325b155..9c0667edd912db3ed3c90cdfe34fbf033277ff03 100644 (file)
@@ -909,9 +909,7 @@ static int bm2835_mmal_s_ctrl(struct v4l2_ctrl *ctrl)
        const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl = ctrl->priv;
        int ret;
 
-       if ((mmal_ctrl == NULL) ||
-           (mmal_ctrl->id != ctrl->id) ||
-           (mmal_ctrl->setter == NULL)) {
+       if (!mmal_ctrl || mmal_ctrl->id != ctrl->id || !mmal_ctrl->setter) {
                pr_warn("mmal_ctrl:%p ctrl id:%d\n", mmal_ctrl, ctrl->id);
                return -EINVAL;
        }
index fdfb6a620a4314ad201ba0f3b09a1de09259d4eb..ca6e9ebc0e812a7fc86e5f85b3fc8479585cfee8 100644 (file)
@@ -657,7 +657,7 @@ static void service_callback(void *param,
                         * should be verified the address lies in the kernel
                         * address space.
                         */
-                       if (msg->h.context == NULL) {
+                       if (!msg->h.context) {
                                pr_err("received message context was null!\n");
                                vchi_held_msg_release(&msg_handle);
                                break;
@@ -1387,7 +1387,7 @@ static int port_enable(struct vchiq_mmal_instance *instance,
                return 0;
 
        /* ensure there are enough buffers queued to cover the buffer headers */
-       if (port->buffer_cb != NULL) {
+       if (port->buffer_cb) {
                hdr_count = 0;
                list_for_each(buf_head, &port->buffers) {
                        hdr_count++;
@@ -1547,7 +1547,7 @@ int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
                return -EINTR;
 
        /* disconnect ports if connected */
-       if (src->connected != NULL) {
+       if (src->connected) {
                ret = port_disable(instance, src);
                if (ret) {
                        pr_err("failed disabling src port(%d)\n", ret);
@@ -1570,7 +1570,7 @@ int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
                src->connected = NULL;
        }
 
-       if (dst == NULL) {
+       if (!dst) {
                /* do not make new connection */
                ret = 0;
                pr_debug("not making new connection\n");
@@ -1817,7 +1817,7 @@ int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance)
 {
        int status = 0;
 
-       if (instance == NULL)
+       if (!instance)
                return -EINVAL;
 
        if (mutex_lock_interruptible(&instance->vchiq_mutex))