]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: ov08x40: Improve ov08x40_[read|write]_reg() error returns
authorHans de Goede <hdegoede@redhat.com>
Fri, 20 Dec 2024 14:41:27 +0000 (15:41 +0100)
committerHans Verkuil <hverkuil@xs4all.nl>
Sat, 15 Feb 2025 14:22:39 +0000 (15:22 +0100)
Improve ov08x40_[read|write]_reg() error returns, if we got an errno value
from the I2C core use that instead of always returning -EIO.

Tested-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/i2c/ov08x40.c

index 10ec9896ca612f3ec265e706c4e60db756c3bfe2..39430528f54f9e208c8e3182f0a65d781d357abc 100644 (file)
@@ -1394,7 +1394,7 @@ static int ov08x40_read_reg(struct ov08x40 *ov08x,
 
        ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
        if (ret != ARRAY_SIZE(msgs))
-               return -EIO;
+               return ret < 0 ? ret : -EIO;
 
        *val = be32_to_cpu(data_be);
 
@@ -1463,7 +1463,7 @@ static int ov08x40_write_reg(struct ov08x40 *ov08x,
                             u16 reg, u32 len, u32 __val)
 {
        struct i2c_client *client = v4l2_get_subdevdata(&ov08x->sd);
-       int buf_i, val_i;
+       int buf_i, val_i, ret;
        u8 buf[6], *val_p;
        __be32 val;
 
@@ -1481,8 +1481,9 @@ static int ov08x40_write_reg(struct ov08x40 *ov08x,
        while (val_i < 4)
                buf[buf_i++] = val_p[val_i++];
 
-       if (i2c_master_send(client, buf, len + 2) != len + 2)
-               return -EIO;
+       ret = i2c_master_send(client, buf, len + 2);
+       if (ret != len + 2)
+               return ret < 0 ? ret : -EIO;
 
        return 0;
 }