Commit 30f3b17e authored by Akinobu Mita's avatar Akinobu Mita Committed by Mauro Carvalho Chehab

media: ov772x: add checks for register read errors

This change adds checks for register read errors and returns correct
error code.

Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Hans Verkuil <hans.verkuil@cisco.com>
Reviewed-by: default avatarJacopo Mondi <jacopo@jmondi.org>
Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 0b964d18
...@@ -1146,7 +1146,7 @@ static int ov772x_set_fmt(struct v4l2_subdev *sd, ...@@ -1146,7 +1146,7 @@ static int ov772x_set_fmt(struct v4l2_subdev *sd,
static int ov772x_video_probe(struct ov772x_priv *priv) static int ov772x_video_probe(struct ov772x_priv *priv)
{ {
struct i2c_client *client = v4l2_get_subdevdata(&priv->subdev); struct i2c_client *client = v4l2_get_subdevdata(&priv->subdev);
u8 pid, ver; int pid, ver, midh, midl;
const char *devname; const char *devname;
int ret; int ret;
...@@ -1156,7 +1156,11 @@ static int ov772x_video_probe(struct ov772x_priv *priv) ...@@ -1156,7 +1156,11 @@ static int ov772x_video_probe(struct ov772x_priv *priv)
/* Check and show product ID and manufacturer ID. */ /* Check and show product ID and manufacturer ID. */
pid = ov772x_read(client, PID); pid = ov772x_read(client, PID);
if (pid < 0)
return pid;
ver = ov772x_read(client, VER); ver = ov772x_read(client, VER);
if (ver < 0)
return ver;
switch (VERSION(pid, ver)) { switch (VERSION(pid, ver)) {
case OV7720: case OV7720:
...@@ -1172,13 +1176,17 @@ static int ov772x_video_probe(struct ov772x_priv *priv) ...@@ -1172,13 +1176,17 @@ static int ov772x_video_probe(struct ov772x_priv *priv)
goto done; goto done;
} }
midh = ov772x_read(client, MIDH);
if (midh < 0)
return midh;
midl = ov772x_read(client, MIDL);
if (midl < 0)
return midl;
dev_info(&client->dev, dev_info(&client->dev,
"%s Product ID %0x:%0x Manufacturer ID %x:%x\n", "%s Product ID %0x:%0x Manufacturer ID %x:%x\n",
devname, devname, pid, ver, midh, midl);
pid,
ver,
ov772x_read(client, MIDH),
ov772x_read(client, MIDL));
ret = v4l2_ctrl_handler_setup(&priv->hdl); ret = v4l2_ctrl_handler_setup(&priv->hdl);
done: done:
......
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