Skip to content

Commit 11cb461

Browse files
Cezar ChiruAndi Shyti
authored andcommitted
i2c: pcf8584: Move 'ret' variable inside for loop, goto out if ret < 0.
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
1 parent d342917 commit 11cb461

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

drivers/i2c/algos/i2c-algo-pcf.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ static int pcf_sendbytes(struct i2c_adapter *i2c_adap, const char *buf,
183183
struct i2c_algo_pcf_data *adap = i2c_adap->algo_data;
184184
int wrcount, status, timeout;
185185

186-
for (wrcount=0; wrcount<count; ++wrcount) {
186+
for (wrcount = 0; wrcount < count; ++wrcount) {
187187
i2c_outb(adap, buf[wrcount]);
188188
timeout = wait_for_pin(adap, &status);
189189
if (timeout) {
@@ -272,7 +272,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
272272
struct i2c_algo_pcf_data *adap = i2c_adap->algo_data;
273273
struct i2c_msg *pmsg;
274274
int i;
275-
int ret=0, timeout, status;
275+
int timeout, status;
276276

277277
if (adap->xfer_begin)
278278
adap->xfer_begin(adap->data);
@@ -284,9 +284,10 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
284284
goto out;
285285
}
286286

287-
for (i = 0;ret >= 0 && i < num; i++) {
288-
pmsg = &msgs[i];
287+
for (i = 0; i < num; i++) {
288+
int ret;
289289

290+
pmsg = &msgs[i];
290291
ret = pcf_doAddress(adap, pmsg);
291292

292293
/* Send START */
@@ -321,6 +322,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
321322
ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len,
322323
(i + 1 == num));
323324
}
325+
326+
if (ret < 0)
327+
goto out;
324328
}
325329

326330
out:

0 commit comments

Comments
 (0)