]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
i2c: pcf8584: Move 'ret' variable inside for loop, goto out if ret < 0.
authorCezar Chiru <chiru.cezar.89@gmail.com>
Thu, 23 Oct 2025 12:00:41 +0000 (15:00 +0300)
committerAndi Shyti <andi.shyti@kernel.org>
Tue, 28 Oct 2025 16:05:16 +0000 (17:05 +0100)
Require spaces around '=' and '<'. Add spaces around binary operators.
Enforce error fixing based on checkpatch.pl output on file.
Move 'ret' variable inside for loop. Then check if (ret < 0) goto out. This
improves usage of ret variable.

Signed-off-by: Cezar Chiru <chiru.cezar.89@gmail.com>
Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
Link: https://lore.kernel.org/r/20251023120043.8661-2-chiru.cezar.89@gmail.com
drivers/i2c/algos/i2c-algo-pcf.c

index 41a81d37e8800eace39646a4bc00e651b86a545b..06b9fd355bff34bac9ff4e89fffd3beda0716bb4 100644 (file)
@@ -183,7 +183,7 @@ static int pcf_sendbytes(struct i2c_adapter *i2c_adap, const char *buf,
        struct i2c_algo_pcf_data *adap = i2c_adap->algo_data;
        int wrcount, status, timeout;
 
-       for (wrcount=0; wrcount<count; ++wrcount) {
+       for (wrcount = 0; wrcount < count; ++wrcount) {
                i2c_outb(adap, buf[wrcount]);
                timeout = wait_for_pin(adap, &status);
                if (timeout) {
@@ -272,7 +272,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
        struct i2c_algo_pcf_data *adap = i2c_adap->algo_data;
        struct i2c_msg *pmsg;
        int i;
-       int ret=0, timeout, status;
+       int timeout, status;
 
        if (adap->xfer_begin)
                adap->xfer_begin(adap->data);
@@ -284,9 +284,10 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
                goto out;
        }
 
-       for (i = 0;ret >= 0 && i < num; i++) {
-               pmsg = &msgs[i];
+       for (i = 0; i < num; i++) {
+               int ret;
 
+               pmsg = &msgs[i];
                ret = pcf_doAddress(adap, pmsg);
 
                /* Send START */
@@ -321,6 +322,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
                        ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len,
                                            (i + 1 == num));
                }
+
+               if (ret < 0)
+                       goto out;
        }
 
 out: