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
Hi Cezar,
On Sat, Oct 18, 2025 at 12:12:58PM +0300, Cezar Chiru wrote:
> 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.
Thanks for following up.
> @@ -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;
there is no need for initialization here.
>
> + pmsg = &msgs[i];
> ret = pcf_doAddress(adap, pmsg);
as a folloing patch you can make pcf_doAddress of the void type
and avoid this extra assignment.
Andi
>
> /* Send START */
> 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. … Is there a need to split desirable adjustments into two update steps? https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.18-rc1#n81 Regards, Markus
© 2016 - 2025 Red Hat, Inc.