]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
tpm: tis_infineon: Cannot test unsigned for being negative
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Wed, 13 Aug 2025 10:40:05 +0000 (11:40 +0100)
committerIlias Apalodimas <ilias.apalodimas@linaro.org>
Mon, 25 Aug 2025 10:04:21 +0000 (13:04 +0300)
tpm_tis_i2c_get_burstcount returns a size_t but also returns -EBUSY if
the TPM is surrently busy. As size_t is an unsigned type simply testing
for < 0 will not work so change the test for being equal to -EBUSY which
will work. Also remove the trivial comments.

This issue was found by Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
drivers/tpm/tpm_tis_infineon.c

index de6566fdb9e501e3530d1f36e8e7dd7ddd599dae..30f23f8610a33e7cc3c584511c6c1ba76c2be8ea 100644 (file)
@@ -353,8 +353,7 @@ static int tpm_tis_i2c_recv_data(struct udevice *dev, u8 *buf, size_t count)
        while (size < count) {
                burstcnt = tpm_tis_i2c_get_burstcount(dev);
 
-               /* burstcount < 0 -> tpm is busy */
-               if (burstcnt < 0)
+               if (burstcnt == -EBUSY)
                        return burstcnt;
 
                /* Limit received data to max left */
@@ -449,8 +448,7 @@ static int tpm_tis_i2c_send(struct udevice *dev, const u8 *buf, size_t len)
 
        burstcnt = tpm_tis_i2c_get_burstcount(dev);
 
-       /* burstcount < 0 -> tpm is busy */
-       if (burstcnt < 0)
+       if (burstcnt == -EBUSY)
                return burstcnt;
 
        while (count < len) {