public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Cezar Chiru <chiru.cezar.89@gmail.com>
To: andi.shyti@kernel.org, wsa+renesas@sang-engineering.com
Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
	Cezar Chiru <chiru.cezar.89@gmail.com>
Subject: [PATCH v7 3/3] i2c: pcf8584: Move 'ret' variable inside for loop, break if ret < 0.
Date: Sat, 18 Oct 2025 12:12:58 +0300	[thread overview]
Message-ID: <20251018091258.5266-4-chiru.cezar.89@gmail.com> (raw)
In-Reply-To: <20251018091258.5266-1-chiru.cezar.89@gmail.com>

Require spaces around '=', '>' and '<'. Add space(s) around binary
operators.
Move 'ret' variable inside for loop. Then check if (ret < 0) break.
This improves usage of ret variable.
Enforce errors fixing based on checkpatch.pl output on file.

Signed-off-by: Cezar Chiru <chiru.cezar.89@gmail.com>
---
 drivers/i2c/algos/i2c-algo-pcf.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 41a81d37e880..40c4d622e8c5 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -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 = 0;
 
+		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)
+			break;
 	}
 
 out:
-- 
2.43.0


  parent reply	other threads:[~2025-10-18  9:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-18  9:12 [PATCH v7 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Cezar Chiru
2025-10-18  9:12 ` [PATCH v7 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c Cezar Chiru
2025-10-18  9:12 ` [PATCH v7 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional Cezar Chiru
2025-10-18  9:12 ` Cezar Chiru [this message]
2025-10-18 18:00   ` [PATCH v7 3/3] i2c: pcf8584: Move 'ret' variable inside for loop, break if ret < 0 Markus Elfring
2025-10-19 22:03   ` Andi Shyti
2025-10-19 22:07 ` [PATCH v7 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Andi Shyti
2025-10-19 22:10   ` Andi Shyti

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251018091258.5266-4-chiru.cezar.89@gmail.com \
    --to=chiru.cezar.89@gmail.com \
    --cc=andi.shyti@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox