[PATCH 02/19] media: i2c: imx290: Print error code when I2C transfer fails

Laurent Pinchart
2022-07-21T08:35:49Z

Knowing why I2C transfers fail is useful for debugging. Extend the error
message to print the error code.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
drivers/media/i2c/imx290.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
index d97a5fb1d501..64bd43813dbf 100644
--- a/drivers/media/i2c/imx290.c
+++ b/drivers/media/i2c/imx290.c
@@ -370,7 +370,8 @@ static inline int __always_unused imx290_read_reg(struct imx290 *imx290, u16 add

ret = regmap_read(imx290->regmap, addr, &regval);
if (ret) {
- dev_err(imx290->dev, "I2C read failed for addr: %x\n", addr);
+ dev_err(imx290->dev, "Failed to read register 0x%04x: %d\n",
+ addr, ret);
return ret;
}

@@ -385,7 +386,8 @@ static int imx290_write_reg(struct imx290 *imx290, u16 addr, u8 value)

ret = regmap_write(imx290->regmap, addr, value);
if (ret) {
- dev_err(imx290->dev, "I2C write failed for addr: %x\n", addr);
+ dev_err(imx290->dev, "Failed to write register 0x%04x: %d\n",
+ addr, ret);
return ret;
}

--
Regards,

Laurent Pinchart