mirror of
https://github.com/torvalds/linux.git
synced 2024-11-05 19:41:54 +00:00
V4L/DVB (8685): mt9m001, mt9v022: Simplify return code checking
i2c_smbus_write_word_data() returns 0 or a negative error, hence no need to check for "> 0". Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
77110abbfb
commit
112116410a
@ -119,16 +119,16 @@ static int mt9m001_init(struct soc_camera_device *icd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
/* Disable chip, synchronous option update */
|
||||
dev_dbg(icd->vdev->parent, "%s\n", __func__);
|
||||
|
||||
ret = reg_write(icd, MT9M001_RESET, 1);
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
ret = reg_write(icd, MT9M001_RESET, 0);
|
||||
if (ret >= 0)
|
||||
/* Disable chip, synchronous option update */
|
||||
if (!ret)
|
||||
ret = reg_write(icd, MT9M001_OUTPUT_CONTROL, 0);
|
||||
|
||||
return ret >= 0 ? 0 : -EIO;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mt9m001_release(struct soc_camera_device *icd)
|
||||
@ -267,24 +267,24 @@ static int mt9m001_set_fmt_cap(struct soc_camera_device *icd,
|
||||
|
||||
/* Blanking and start values - default... */
|
||||
ret = reg_write(icd, MT9M001_HORIZONTAL_BLANKING, hblank);
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
ret = reg_write(icd, MT9M001_VERTICAL_BLANKING, vblank);
|
||||
|
||||
/* The caller provides a supported format, as verified per
|
||||
* call to icd->try_fmt_cap() */
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
ret = reg_write(icd, MT9M001_COLUMN_START, rect->left);
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
ret = reg_write(icd, MT9M001_ROW_START, rect->top);
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
ret = reg_write(icd, MT9M001_WINDOW_WIDTH, rect->width - 1);
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
ret = reg_write(icd, MT9M001_WINDOW_HEIGHT,
|
||||
rect->height + icd->y_skip_top - 1);
|
||||
if (ret >= 0 && mt9m001->autoexposure) {
|
||||
if (!ret && mt9m001->autoexposure) {
|
||||
ret = reg_write(icd, MT9M001_SHUTTER_WIDTH,
|
||||
rect->height + icd->y_skip_top + vblank);
|
||||
if (ret >= 0) {
|
||||
if (!ret) {
|
||||
const struct v4l2_queryctrl *qctrl =
|
||||
soc_camera_find_qctrl(icd->ops,
|
||||
V4L2_CID_EXPOSURE);
|
||||
@ -295,7 +295,7 @@ static int mt9m001_set_fmt_cap(struct soc_camera_device *icd,
|
||||
}
|
||||
}
|
||||
|
||||
return ret < 0 ? ret : 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mt9m001_try_fmt_cap(struct soc_camera_device *icd,
|
||||
|
@ -141,22 +141,22 @@ static int mt9v022_init(struct soc_camera_device *icd)
|
||||
* plus snapshot mode to disable scan for now */
|
||||
mt9v022->chip_control |= 0x10;
|
||||
ret = reg_write(icd, MT9V022_CHIP_CONTROL, mt9v022->chip_control);
|
||||
if (ret >= 0)
|
||||
reg_write(icd, MT9V022_READ_MODE, 0x300);
|
||||
if (!ret)
|
||||
ret = reg_write(icd, MT9V022_READ_MODE, 0x300);
|
||||
|
||||
/* All defaults */
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
/* AEC, AGC on */
|
||||
ret = reg_set(icd, MT9V022_AEC_AGC_ENABLE, 0x3);
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
ret = reg_write(icd, MT9V022_MAX_TOTAL_SHUTTER_WIDTH, 480);
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
/* default - auto */
|
||||
ret = reg_clear(icd, MT9V022_BLACK_LEVEL_CALIB_CTRL, 1);
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
ret = reg_write(icd, MT9V022_DIGITAL_TEST_PATTERN, 0);
|
||||
|
||||
return ret >= 0 ? 0 : -EIO;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int mt9v022_release(struct soc_camera_device *icd)
|
||||
@ -352,21 +352,21 @@ static int mt9v022_set_fmt_cap(struct soc_camera_device *icd,
|
||||
rect->height + icd->y_skip_top + 43);
|
||||
}
|
||||
/* Setup frame format: defaults apart from width and height */
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
ret = reg_write(icd, MT9V022_COLUMN_START, rect->left);
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
ret = reg_write(icd, MT9V022_ROW_START, rect->top);
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
/* Default 94, Phytec driver says:
|
||||
* "width + horizontal blank >= 660" */
|
||||
ret = reg_write(icd, MT9V022_HORIZONTAL_BLANKING,
|
||||
rect->width > 660 - 43 ? 43 :
|
||||
660 - rect->width);
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
ret = reg_write(icd, MT9V022_VERTICAL_BLANKING, 45);
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
ret = reg_write(icd, MT9V022_WINDOW_WIDTH, rect->width);
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
ret = reg_write(icd, MT9V022_WINDOW_HEIGHT,
|
||||
rect->height + icd->y_skip_top);
|
||||
|
||||
@ -717,7 +717,7 @@ static int mt9v022_video_probe(struct soc_camera_device *icd)
|
||||
icd->num_formats = 1;
|
||||
}
|
||||
|
||||
if (ret >= 0)
|
||||
if (!ret)
|
||||
ret = soc_camera_video_start(icd);
|
||||
if (ret < 0)
|
||||
goto eisis;
|
||||
|
Loading…
Reference in New Issue
Block a user