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--;
}
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;
}
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;
}
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;
}
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++)
cam->state &= ~DEV_MISCONFIGURED;
}
- if ((err = sn9c102_start_transfer(cam)))
+ err = sn9c102_start_transfer(cam);
+ if (err)
goto out;
filp->private_data = cam;
}
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;
} 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;
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;
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() */
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);
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);
}
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;
{
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;
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:
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;
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;
}
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;
}
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: