From 4bc58d16753b99e45d84388d7e63b93d7f913a98 Mon Sep 17 00:00:00 2001 From: Aishwarya Pant Date: Tue, 28 Feb 2017 16:52:50 +0530 Subject: staging: vc04_services: bcm2835-camera: Simplify NULL comparisons Remove instances of explicit NULL comparisons in bcm2835-camera driver for code compaction. Signed-off-by: Aishwarya Pant Signed-off-by: Greg Kroah-Hartman --- .../staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 14 +++++++------- .../staging/vc04_services/bcm2835-camera/bcm2835-camera.h | 4 ++-- drivers/staging/vc04_services/bcm2835-camera/controls.c | 4 +--- drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c | 10 +++++----- 4 files changed, 15 insertions(+), 17 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index c4dad30..1baeef4 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -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; diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h index e6aeb7e..e5bbc6c 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h @@ -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, \ diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c index 4d7e2a2..9c0667e 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/controls.c +++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c @@ -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; } diff --git a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c index fdfb6a6..ca6e9eb 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +++ b/drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c @@ -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)) -- cgit v1.1