staging: vc04_services: bcm2835-camera: Simplify NULL comparisons
Subsystems (3)
PATCH 1/1 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 <[email protected]>
--- .../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 | 12 ++++++------ 4 files changed, 16 insertions(+), 18 deletions(-)
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +7 -7
@@ -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 ;
drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h +2 -2
@@ -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, \
drivers/staging/vc04_services/bcm2835-camera/controls.c +1 -3
@@ -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 ; }
drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c +6 -6
@@ -397,7 +397,7 @@ buffer_from_host(struct vchiq_mmal_instance *instance,/* get context */ msg_context =get_msg_context (instance); -if (msg_context ==NULL ) +if (!msg_context)return -ENOMEM ;/* store bulk message context for when data arrives */
@@ -654,7 +654,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 ;
@@ -1384,7 +1384,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++;
@@ -1544,7 +1544,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);
@@ -1567,7 +1567,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" );
@@ -1814,7 +1814,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))
Signature · 1 line
2.7.4