]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
habanalabs: return error when failing to read/write i2c
authorOded Gabbay <oded.gabbay@gmail.com>
Tue, 26 Feb 2019 09:23:34 +0000 (11:23 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 26 Feb 2019 10:35:03 +0000 (11:35 +0100)
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 <dan.carpenter@oracle.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/habanalabs/debugfs.c

index a6d9d809385e91c254869a7a27153744548bbdcc..f472b572faea53bf7f2a968ae6f4a65be7738846 100644 (file)
@@ -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));