mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
media: i2c: imx214: Rearrange control initialization
Smatch is confused by the control initialization logic. It assumes that there can be a case where imx214->link_freq can be NULL and ctrls_init returns 0. Re-arrange the function to make smatch happy. This patch fixes this smatch error: drivers/media/i2c/imx214.c:1109 imx214_ctrls_init() error: we previously assumed 'imx214->link_freq' could be null (see line 1017) Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
This commit is contained in:
committed by
Hans Verkuil
parent
e687f5cae5
commit
15ac3d54a8
@@ -1014,8 +1014,6 @@ static int imx214_ctrls_init(struct imx214 *imx214)
|
||||
V4L2_CID_LINK_FREQ,
|
||||
imx214->bus_cfg.nr_of_link_frequencies - 1,
|
||||
0, imx214->bus_cfg.link_frequencies);
|
||||
if (imx214->link_freq)
|
||||
imx214->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
|
||||
|
||||
/*
|
||||
* WARNING!
|
||||
@@ -1038,9 +1036,6 @@ static int imx214_ctrls_init(struct imx214 *imx214)
|
||||
imx214->hblank = v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_ops,
|
||||
V4L2_CID_HBLANK, hblank, hblank,
|
||||
1, hblank);
|
||||
if (imx214->hblank)
|
||||
imx214->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
|
||||
|
||||
exposure_max = mode->vts_def - IMX214_EXPOSURE_OFFSET;
|
||||
exposure_def = min(exposure_max, IMX214_EXPOSURE_DEFAULT);
|
||||
imx214->exposure = v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_ops,
|
||||
@@ -1060,13 +1055,9 @@ static int imx214_ctrls_init(struct imx214 *imx214)
|
||||
|
||||
imx214->hflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_ops,
|
||||
V4L2_CID_HFLIP, 0, 1, 1, 0);
|
||||
if (imx214->hflip)
|
||||
imx214->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
|
||||
|
||||
imx214->vflip = v4l2_ctrl_new_std(ctrl_hdlr, &imx214_ctrl_ops,
|
||||
V4L2_CID_VFLIP, 0, 1, 1, 0);
|
||||
if (imx214->vflip)
|
||||
imx214->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
|
||||
|
||||
v4l2_ctrl_cluster(2, &imx214->hflip);
|
||||
|
||||
@@ -1106,6 +1097,12 @@ static int imx214_ctrls_init(struct imx214 *imx214)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Now that the controls have been properly created, set their flags. */
|
||||
imx214->link_freq->flags |= V4L2_CTRL_FLAG_READ_ONLY;
|
||||
imx214->hblank->flags |= V4L2_CTRL_FLAG_READ_ONLY;
|
||||
imx214->hflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
|
||||
imx214->vflip->flags |= V4L2_CTRL_FLAG_MODIFY_LAYOUT;
|
||||
|
||||
ret = imx214_pll_update(imx214);
|
||||
if (ret < 0) {
|
||||
v4l2_ctrl_handler_free(ctrl_hdlr);
|
||||
|
||||
Reference in New Issue
Block a user