]> git.karo-electronics.de Git - linux-beck.git/commitdiff
staging:media: Removed assignments from if statements.
authorChi Pham <fempsci@gmail.com>
Sun, 9 Mar 2014 13:55:14 +0000 (14:55 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 18 Mar 2014 18:03:50 +0000 (11:03 -0700)
The following coccinelle script found the match:

@simple@
expression E1, E2;
statement S1, S2;
@@

+ E1 = E2;
if (
- (E1 = E2)
+ E1
 )
S1 else S2

@left@
expression E0, E1, E2;
statement S0, S1;
@@
- if ((E1 = E2) < E0)
+ E1 = E2;
+ if (E1 < E0)
S1

Signed-off-by: Chi Pham <fempsci@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/media/sn9c102/sn9c102_core.c
drivers/staging/media/sn9c102/sn9c102_hv7131d.c
drivers/staging/media/sn9c102/sn9c102_hv7131r.c
drivers/staging/media/sn9c102/sn9c102_ov7630.c
drivers/staging/media/sn9c102/sn9c102_ov7660.c
drivers/staging/media/sn9c102/sn9c102_pas106b.c
drivers/staging/media/sn9c102/sn9c102_pas202bcb.c

index 7be25b0ffae611dd661bfb8f54f312cd725bc53a..71f594f5aa71b7e111e661f177f2452f75aad4d4 100644 (file)
@@ -158,8 +158,8 @@ sn9c102_request_buffers(struct sn9c102_device* cam, u32 count,
 
        cam->nbuffers = count;
        while (cam->nbuffers > 0) {
-               if ((buff = vmalloc_32_user(cam->nbuffers *
-                                           PAGE_ALIGN(imagesize))))
+               buff = vmalloc_32_user(cam->nbuffers * PAGE_ALIGN(imagesize));
+               if (buff)
                        break;
                cam->nbuffers--;
        }
@@ -1121,7 +1121,8 @@ static ssize_t sn9c102_show_val(struct device* cd,
                return -ENODEV;
        }
 
-       if ((val = sn9c102_read_reg(cam, cam->sysfs.reg)) < 0) {
+       val = sn9c102_read_reg(cam, cam->sysfs.reg);
+       if (val < 0) {
                mutex_unlock(&sn9c102_sysfs_lock);
                return -EIO;
        }
@@ -1256,7 +1257,8 @@ static ssize_t sn9c102_show_i2c_val(struct device* cd,
                return -ENOSYS;
        }
 
-       if ((val = sn9c102_i2c_read(cam, cam->sysfs.i2c_reg)) < 0) {
+       val = sn9c102_i2c_read(cam, cam->sysfs.i2c_reg);
+       if (val < 0) {
                mutex_unlock(&sn9c102_sysfs_lock);
                return -EIO;
        }
@@ -1440,27 +1442,35 @@ static int sn9c102_create_sysfs(struct sn9c102_device* cam)
        struct device *dev = &(cam->v4ldev->dev);
        int err = 0;
 
-       if ((err = device_create_file(dev, &dev_attr_reg)))
+       err = device_create_file(dev, &dev_attr_reg);
+       if (err)
                goto err_out;
-       if ((err = device_create_file(dev, &dev_attr_val)))
+       err = device_create_file(dev, &dev_attr_val);
+       if (err)
                goto err_reg;
-       if ((err = device_create_file(dev, &dev_attr_frame_header)))
+       err = device_create_file(dev, &dev_attr_frame_header);
+       if (err)
                goto err_val;
 
        if (cam->sensor.sysfs_ops) {
-               if ((err = device_create_file(dev, &dev_attr_i2c_reg)))
+               err = device_create_file(dev, &dev_attr_i2c_reg);
+               if (err)
                        goto err_frame_header;
-               if ((err = device_create_file(dev, &dev_attr_i2c_val)))
+               err = device_create_file(dev, &dev_attr_i2c_val);
+               if (err)
                        goto err_i2c_reg;
        }
 
        if (cam->bridge == BRIDGE_SN9C101 || cam->bridge == BRIDGE_SN9C102) {
-               if ((err = device_create_file(dev, &dev_attr_green)))
+               err = device_create_file(dev, &dev_attr_green);
+               if (err)
                        goto err_i2c_val;
        } else {
-               if ((err = device_create_file(dev, &dev_attr_blue)))
+               err = device_create_file(dev, &dev_attr_blue);
+               if (err)
                        goto err_i2c_val;
-               if ((err = device_create_file(dev, &dev_attr_red)))
+               err = device_create_file(dev, &dev_attr_red);
+               if (err)
                        goto err_blue;
        }
 
@@ -1684,11 +1694,13 @@ static int sn9c102_init(struct sn9c102_device* cam)
        else
                DBG(3, "Uncompressed video format is active");
 
-       if (s->set_crop)
-               if ((err = s->set_crop(cam, rect))) {
+       if (s->set_crop) {
+               err = s->set_crop(cam, rect);
+               if (err) {
                        DBG(3, "set_crop() failed");
                        return err;
                }
+       }
 
        if (s->set_ctrl) {
                for (i = 0; i < ARRAY_SIZE(s->qctrl); i++)
@@ -1835,7 +1847,8 @@ static int sn9c102_open(struct file *filp)
                cam->state &= ~DEV_MISCONFIGURED;
        }
 
-       if ((err = sn9c102_start_transfer(cam)))
+       err = sn9c102_start_transfer(cam);
+       if (err)
                goto out;
 
        filp->private_data = cam;
@@ -2308,7 +2321,8 @@ sn9c102_vidioc_s_ctrl(struct sn9c102_device* cam, void __user * arg)
        }
        if (i == ARRAY_SIZE(s->qctrl))
                return -EINVAL;
-       if ((err = s->set_ctrl(cam, &ctrl)))
+       err = s->set_ctrl(cam, &ctrl);
+       if (err)
                return err;
 
        s->_qctrl[i].default_value = ctrl.value;
@@ -2416,9 +2430,11 @@ sn9c102_vidioc_s_crop(struct sn9c102_device* cam, void __user * arg)
        } else
                scale = 1;
 
-       if (cam->stream == STREAM_ON)
-               if ((err = sn9c102_stream_interrupt(cam)))
+       if (cam->stream == STREAM_ON) {
+               err = sn9c102_stream_interrupt(cam);
+               if (err)
                        return err;
+       }
 
        if (copy_to_user(arg, &crop, sizeof(crop))) {
                cam->stream = stream;
@@ -2672,9 +2688,11 @@ sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd,
                                return -EBUSY;
                        }
 
-       if (cam->stream == STREAM_ON)
-               if ((err = sn9c102_stream_interrupt(cam)))
+       if (cam->stream == STREAM_ON) {
+               err = sn9c102_stream_interrupt(cam);
+               if (err)
                        return err;
+       }
 
        if (copy_to_user(arg, &format, sizeof(format))) {
                cam->stream = stream;
@@ -2746,9 +2764,11 @@ sn9c102_vidioc_s_jpegcomp(struct sn9c102_device* cam, void __user * arg)
        if (jc.quality != 0 && jc.quality != 1)
                return -EINVAL;
 
-       if (cam->stream == STREAM_ON)
-               if ((err = sn9c102_stream_interrupt(cam)))
+       if (cam->stream == STREAM_ON) {
+               err = sn9c102_stream_interrupt(cam);
+               if (err)
                        return err;
+       }
 
        err += sn9c102_set_compression(cam, &jc);
        if (err) { /* atomic, no rollback in ioctl() */
@@ -2794,9 +2814,11 @@ sn9c102_vidioc_reqbufs(struct sn9c102_device* cam, void __user * arg)
                        return -EBUSY;
                }
 
-       if (cam->stream == STREAM_ON)
-               if ((err = sn9c102_stream_interrupt(cam)))
+       if (cam->stream == STREAM_ON) {
+               err = sn9c102_stream_interrupt(cam);
+               if (err)
                        return err;
+       }
 
        sn9c102_empty_framequeues(cam);
 
@@ -2974,9 +2996,11 @@ sn9c102_vidioc_streamoff(struct sn9c102_device* cam, void __user * arg)
        if (type != V4L2_BUF_TYPE_VIDEO_CAPTURE || cam->io != IO_MMAP)
                return -EINVAL;
 
-       if (cam->stream == STREAM_ON)
-               if ((err = sn9c102_stream_interrupt(cam)))
+       if (cam->stream == STREAM_ON) {
+               err = sn9c102_stream_interrupt(cam);
+               if (err)
                        return err;
+       }
 
        sn9c102_empty_framequeues(cam);
 
index 2dce5c908c8e257191cc41b4669c18b00ea27055..468072176527d9ed013df01cf130faffd0679ea3 100644 (file)
@@ -53,27 +53,32 @@ static int hv7131d_get_ctrl(struct sn9c102_device* cam,
                }
                return 0;
        case V4L2_CID_RED_BALANCE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x31)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x31);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value = 0x3f - (ctrl->value & 0x3f);
                return 0;
        case V4L2_CID_BLUE_BALANCE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x33)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x33);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value = 0x3f - (ctrl->value & 0x3f);
                return 0;
        case SN9C102_V4L2_CID_GREEN_BALANCE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x32)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x32);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value = 0x3f - (ctrl->value & 0x3f);
                return 0;
        case SN9C102_V4L2_CID_RESET_LEVEL:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x30)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x30);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x3f;
                return 0;
        case SN9C102_V4L2_CID_PIXEL_BIAS_VOLTAGE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x34)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x34);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x07;
                return 0;
index 4295887ff6098b610a50acddfd46a8a3e2f023d4..26a91115b83171955a003ac79c5309d270a2cac6 100644 (file)
@@ -142,26 +142,31 @@ static int hv7131r_get_ctrl(struct sn9c102_device* cam,
 {
        switch (ctrl->id) {
        case V4L2_CID_GAIN:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x30)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x30);
+               if (ctrl->value < 0)
                        return -EIO;
                return 0;
        case V4L2_CID_RED_BALANCE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x31)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x31);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value = ctrl->value & 0x3f;
                return 0;
        case V4L2_CID_BLUE_BALANCE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x33)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x33);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value = ctrl->value & 0x3f;
                return 0;
        case SN9C102_V4L2_CID_GREEN_BALANCE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x32)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x32);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value = ctrl->value & 0x3f;
                return 0;
        case V4L2_CID_BLACK_LEVEL:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x01)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x01);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value = (ctrl->value & 0x08) ? 1 : 0;
                return 0;
index 803712c29f020edd0dc2bbbd00483a334e89d93b..d3a1bd8d56483d42e28e44ea74f9d55ab0efbf67 100644 (file)
@@ -260,7 +260,8 @@ static int ov7630_get_ctrl(struct sn9c102_device* cam,
 
        switch (ctrl->id) {
        case V4L2_CID_EXPOSURE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x10)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x10);
+               if (ctrl->value < 0)
                        return -EIO;
                break;
        case V4L2_CID_RED_BALANCE:
@@ -280,37 +281,44 @@ static int ov7630_get_ctrl(struct sn9c102_device* cam,
                break;
                break;
        case V4L2_CID_GAIN:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x00)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x00);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x3f;
                break;
        case V4L2_CID_DO_WHITE_BALANCE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x0c)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x0c);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x3f;
                break;
        case V4L2_CID_WHITENESS:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x0d)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x0d);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x3f;
                break;
        case V4L2_CID_AUTOGAIN:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x13)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x13);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x01;
                break;
        case V4L2_CID_VFLIP:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x75)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x75);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value = (ctrl->value & 0x80) ? 1 : 0;
                break;
        case SN9C102_V4L2_CID_GAMMA:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x14)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x14);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value = (ctrl->value & 0x02) ? 1 : 0;
                break;
        case SN9C102_V4L2_CID_BAND_FILTER:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x2d)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x2d);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value = (ctrl->value & 0x02) ? 1 : 0;
                break;
index 7977795d342b73b7d8d0f20773cf61e29ab0a934..530157a234e613ab6a83f14a93f84dcb0da8c34c 100644 (file)
@@ -278,41 +278,49 @@ static int ov7660_get_ctrl(struct sn9c102_device* cam,
 
        switch (ctrl->id) {
        case V4L2_CID_EXPOSURE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x10)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x10);
+               if (ctrl->value < 0)
                        return -EIO;
                break;
        case V4L2_CID_DO_WHITE_BALANCE:
-               if ((ctrl->value = sn9c102_read_reg(cam, 0x02)) < 0)
+               ctrl->value = sn9c102_read_reg(cam, 0x02);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value = (ctrl->value & 0x04) ? 1 : 0;
                break;
        case V4L2_CID_RED_BALANCE:
-               if ((ctrl->value = sn9c102_read_reg(cam, 0x05)) < 0)
+               ctrl->value = sn9c102_read_reg(cam, 0x05);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x7f;
                break;
        case V4L2_CID_BLUE_BALANCE:
-               if ((ctrl->value = sn9c102_read_reg(cam, 0x06)) < 0)
+               ctrl->value = sn9c102_read_reg(cam, 0x06);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x7f;
                break;
        case SN9C102_V4L2_CID_GREEN_BALANCE:
-               if ((ctrl->value = sn9c102_read_reg(cam, 0x07)) < 0)
+               ctrl->value = sn9c102_read_reg(cam, 0x07);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x7f;
                break;
        case SN9C102_V4L2_CID_BAND_FILTER:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x3b)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x3b);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x08;
                break;
        case V4L2_CID_GAIN:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x00)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x00);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x1f;
                break;
        case V4L2_CID_AUTOGAIN:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x13)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x13);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x01;
                break;
index 81cd969c1b7b19d7e1472071403d1427dfec8bb6..47bd82de80f9807446ca4e4f92f0815caa8b7a77 100644 (file)
@@ -62,32 +62,38 @@ static int pas106b_get_ctrl(struct sn9c102_device* cam,
                }
                return 0;
        case V4L2_CID_RED_BALANCE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x0c)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x0c);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x1f;
                return 0;
        case V4L2_CID_BLUE_BALANCE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x09)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x09);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x1f;
                return 0;
        case V4L2_CID_GAIN:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x0e)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x0e);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x1f;
                return 0;
        case V4L2_CID_CONTRAST:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x0f)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x0f);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x07;
                return 0;
        case SN9C102_V4L2_CID_GREEN_BALANCE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x0a)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x0a);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value = (ctrl->value & 0x1f) << 1;
                return 0;
        case SN9C102_V4L2_CID_DAC_MAGNITUDE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x08)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x08);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0xf8;
                return 0;
index 2e86fdc8698915b0d7ade1536072a437267b90a3..cbfacc2dad8453ed7dda4d736ee387b62ce10683 100644 (file)
@@ -92,27 +92,32 @@ static int pas202bcb_get_ctrl(struct sn9c102_device* cam,
                }
                return 0;
        case V4L2_CID_RED_BALANCE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x09)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x09);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x0f;
                return 0;
        case V4L2_CID_BLUE_BALANCE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x07)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x07);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x0f;
                return 0;
        case V4L2_CID_GAIN:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x10)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x10);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x1f;
                return 0;
        case SN9C102_V4L2_CID_GREEN_BALANCE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x08)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x08);
+               if (ctrl->value < 0)
                        return -EIO;
                ctrl->value &= 0x0f;
                return 0;
        case SN9C102_V4L2_CID_DAC_MAGNITUDE:
-               if ((ctrl->value = sn9c102_i2c_read(cam, 0x0c)) < 0)
+               ctrl->value = sn9c102_i2c_read(cam, 0x0c);
+               if (ctrl->value < 0)
                        return -EIO;
                return 0;
        default: