mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
media: ov5647: Fix return codes from ov5647_write/ov5647_read functions.
Previously they were returning positive non-zero codes for success,
which were getting passed up the call stack. Since release 4.19,
do_dentry_open (fs/open.c) has been catching these and flagging an
error. (So this driver has been broken since that date.)
Fixes: 3c2472a [media] media: i2c: Add support for OV5647 sensor
Signed-off-by: David Plowman <david.plowman@raspberrypi.org>
Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
This commit is contained in:
committed by
Dom Cobley
parent
06acfc65a7
commit
99f4fe9df1
@@ -601,7 +601,13 @@ static int ov5647_write16(struct v4l2_subdev *sd, u16 reg, u16 val)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = i2c_master_send(client, data, 4);
|
ret = i2c_master_send(client, data, 4);
|
||||||
if (ret < 0) {
|
/*
|
||||||
|
* Writing the wrong number of bytes also needs to be flagged as an
|
||||||
|
* error. Success needs to produce a 0 return code.
|
||||||
|
*/
|
||||||
|
if (ret == 4) {
|
||||||
|
ret = 0;
|
||||||
|
} else {
|
||||||
dev_dbg(&client->dev, "%s: i2c write error, reg: %x\n",
|
dev_dbg(&client->dev, "%s: i2c write error, reg: %x\n",
|
||||||
__func__, reg);
|
__func__, reg);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -617,10 +623,17 @@ static int ov5647_write(struct v4l2_subdev *sd, u16 reg, u8 val)
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = i2c_master_send(client, data, 3);
|
ret = i2c_master_send(client, data, 3);
|
||||||
if (ret < 0) {
|
/*
|
||||||
|
* Writing the wrong number of bytes also needs to be flagged as an
|
||||||
|
* error. Success needs to produce a 0 return code.
|
||||||
|
*/
|
||||||
|
if (ret == 3) {
|
||||||
|
ret = 0;
|
||||||
|
} else {
|
||||||
dev_dbg(&client->dev, "%s: i2c write error, reg: %x\n",
|
dev_dbg(&client->dev, "%s: i2c write error, reg: %x\n",
|
||||||
__func__, reg);
|
__func__, reg);
|
||||||
return ret;
|
if (ret >= 0)
|
||||||
|
ret = -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user