From: Hans de Goede <hdego...@redhat.com>

media: ov08x40: Improve ov08x40_[read|write]_reg() error returns

upstream status: Accepted in media subsystem co-maintainer tree:
https://git.linuxtv.org/sailus/media_tree.git/log/drivers/media/i2c/ov08x40.c?h=devel
(this tree gets rebased before merging so no git hash)

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.odonog...@linaro.org>
Signed-off-by: Hans de Goede <hdego...@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ai...@linux.intel.com>

diff --git a/drivers/media/i2c/ov08x40.c b/drivers/media/i2c/ov08x40.c
index blahblah..blahblah 100644
--- a/drivers/media/i2c/ov08x40.c
+++ b/drivers/media/i2c/ov08x40.c
@@ -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;
 }

--
https://gitlab.com/cki-project/kernel-ark/-/merge_requests/3671

-- 
_______________________________________________
kernel mailing list -- kernel@lists.fedoraproject.org
To unsubscribe send an email to kernel-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/kernel@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to