habanalabs: return error when failing to read/write i2c
PATCH 1/1 habanalabs: return error when failing to read/write i2c
The driver can't read/write from i2c if the device is in reset or disabled. Therefore, return -EBUSY in those cases instead of 0.
This change also fixes a smatch warning about uninitialized variable.
Reported-by Dan Carpenter <[email protected]>
Signed-off-by Oded Gabbay <[email protected]>
--- drivers/misc/habanalabs/debugfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/misc/habanalabs/debugfs.c +2 -2
@@ -25,7 +25,7 @@ static int hl_debugfs_i2c_read(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,int rc;if (hl_device_disabled_or_in_reset (hdev)) -return 0 ; +return -EBUSY ;memset (&pkt,0 ,sizeof (pkt));
@@ -50,7 +50,7 @@ static int hl_debugfs_i2c_write(struct hl_device *hdev, u8 i2c_bus, u8 i2c_addr,int rc;if (hl_device_disabled_or_in_reset (hdev)) -return 0 ; +return -EBUSY ;memset (&pkt,0 ,sizeof (pkt));
Signature · 1 line
2.17.1