Commit 86a7dacc authored by Chi Pham's avatar Chi Pham Committed by Greg Kroah-Hartman

staging:media: Removed assignments from if statements.

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: default avatarChi Pham <fempsci@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f4d636dd
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment