Skip to content

Commit 4bc58d1

Browse files
aishpantgregkh
authored andcommitted
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 <aishpant@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 69385ad commit 4bc58d1

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static int queue_setup(struct vb2_queue *vq,
250250
unsigned long size;
251251

252252
/* refuse queue setup if port is not configured */
253-
if (dev->capture.port == NULL) {
253+
if (!dev->capture.port) {
254254
v4l2_err(&dev->v4l2_dev,
255255
"%s: capture port not configured\n", __func__);
256256
return -EINVAL;
@@ -289,8 +289,8 @@ static int buffer_prepare(struct vb2_buffer *vb)
289289
v4l2_dbg(1, bcm2835_v4l2_debug, &dev->v4l2_dev, "%s: dev:%p\n",
290290
__func__, dev);
291291

292-
BUG_ON(dev->capture.port == NULL);
293-
BUG_ON(dev->capture.fmt == NULL);
292+
BUG_ON(!dev->capture.port);
293+
BUG_ON(!dev->capture.fmt);
294294

295295
size = dev->capture.stride * dev->capture.height;
296296
if (vb2_plane_size(vb, 0) < size) {
@@ -324,14 +324,14 @@ static void buffer_cb(struct vchiq_mmal_instance *instance,
324324

325325
if (status != 0) {
326326
/* error in transfer */
327-
if (buf != NULL) {
327+
if (buf) {
328328
/* there was a buffer with the error so return it */
329329
vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR);
330330
}
331331
return;
332332
} else if (length == 0) {
333333
/* stream ended */
334-
if (buf != NULL) {
334+
if (buf) {
335335
/* this should only ever happen if the port is
336336
* disabled and there are buffers still queued
337337
*/
@@ -513,7 +513,7 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
513513
__func__, dev);
514514

515515
/* ensure a format has actually been set */
516-
if (dev->capture.port == NULL)
516+
if (!dev->capture.port)
517517
return -EINVAL;
518518

519519
if (enable_camera(dev) < 0) {
@@ -604,7 +604,7 @@ static void stop_streaming(struct vb2_queue *vq)
604604
dev->capture.frame_count = 0;
605605

606606
/* ensure a format has actually been set */
607-
if (dev->capture.port == NULL) {
607+
if (!dev->capture.port) {
608608
v4l2_err(&dev->v4l2_dev,
609609
"no capture port - stream not started?\n");
610610
return;

drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ int set_framerate_params(struct bm2835_mmal_dev *dev);
125125
{ \
126126
v4l2_dbg(level, debug, dev, \
127127
"%s: w %u h %u field %u pfmt 0x%x bpl %u sz_img %u colorspace 0x%x priv %u\n", \
128-
desc == NULL ? "" : desc, \
128+
!desc ? "" : desc, \
129129
(pix_fmt)->width, (pix_fmt)->height, (pix_fmt)->field, \
130130
(pix_fmt)->pixelformat, (pix_fmt)->bytesperline, \
131131
(pix_fmt)->sizeimage, (pix_fmt)->colorspace, (pix_fmt)->priv); \
@@ -135,7 +135,7 @@ int set_framerate_params(struct bm2835_mmal_dev *dev);
135135
v4l2_dbg(level, debug, dev, \
136136
"%s: w %u h %u l %u t %u field %u chromakey %06X clip %p " \
137137
"clipcount %u bitmap %p\n", \
138-
desc == NULL ? "" : desc, \
138+
!desc ? "" : desc, \
139139
(win_fmt)->w.width, (win_fmt)->w.height, \
140140
(win_fmt)->w.left, (win_fmt)->w.top, \
141141
(win_fmt)->field, \

drivers/staging/vc04_services/bcm2835-camera/controls.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -909,9 +909,7 @@ static int bm2835_mmal_s_ctrl(struct v4l2_ctrl *ctrl)
909909
const struct bm2835_mmal_v4l2_ctrl *mmal_ctrl = ctrl->priv;
910910
int ret;
911911

912-
if ((mmal_ctrl == NULL) ||
913-
(mmal_ctrl->id != ctrl->id) ||
914-
(mmal_ctrl->setter == NULL)) {
912+
if (!mmal_ctrl || mmal_ctrl->id != ctrl->id || !mmal_ctrl->setter) {
915913
pr_warn("mmal_ctrl:%p ctrl id:%d\n", mmal_ctrl, ctrl->id);
916914
return -EINVAL;
917915
}

drivers/staging/vc04_services/bcm2835-camera/mmal-vchiq.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ static void service_callback(void *param,
657657
* should be verified the address lies in the kernel
658658
* address space.
659659
*/
660-
if (msg->h.context == NULL) {
660+
if (!msg->h.context) {
661661
pr_err("received message context was null!\n");
662662
vchi_held_msg_release(&msg_handle);
663663
break;
@@ -1387,7 +1387,7 @@ static int port_enable(struct vchiq_mmal_instance *instance,
13871387
return 0;
13881388

13891389
/* ensure there are enough buffers queued to cover the buffer headers */
1390-
if (port->buffer_cb != NULL) {
1390+
if (port->buffer_cb) {
13911391
hdr_count = 0;
13921392
list_for_each(buf_head, &port->buffers) {
13931393
hdr_count++;
@@ -1547,7 +1547,7 @@ int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
15471547
return -EINTR;
15481548

15491549
/* disconnect ports if connected */
1550-
if (src->connected != NULL) {
1550+
if (src->connected) {
15511551
ret = port_disable(instance, src);
15521552
if (ret) {
15531553
pr_err("failed disabling src port(%d)\n", ret);
@@ -1570,7 +1570,7 @@ int vchiq_mmal_port_connect_tunnel(struct vchiq_mmal_instance *instance,
15701570
src->connected = NULL;
15711571
}
15721572

1573-
if (dst == NULL) {
1573+
if (!dst) {
15741574
/* do not make new connection */
15751575
ret = 0;
15761576
pr_debug("not making new connection\n");
@@ -1817,7 +1817,7 @@ int vchiq_mmal_finalise(struct vchiq_mmal_instance *instance)
18171817
{
18181818
int status = 0;
18191819

1820-
if (instance == NULL)
1820+
if (!instance)
18211821
return -EINVAL;
18221822

18231823
if (mutex_lock_interruptible(&instance->vchiq_mutex))

0 commit comments

Comments
 (0)