[PATCH v6 3/3] i2c: pcf8584: Fix space(s) required before or after different operators

Cezar Chiru posted 3 patches 4 months, 2 weeks ago
There is a newer version of this series
[PATCH v6 3/3] i2c: pcf8584: Fix space(s) required before or after different operators
Posted by Cezar Chiru 4 months, 2 weeks ago
Require spaces around '=', '>' and '<'. Add space(s) around binary
operators.
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 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 41a81d37e880..d675d484fe66 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 ret = 0, timeout, status;
 
 	if (adap->xfer_begin)
 		adap->xfer_begin(adap->data);
@@ -284,7 +284,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 		goto out;
 	}
 
-	for (i = 0;ret >= 0 && i < num; i++) {
+	for (i = 0; ret >= 0 && i < num; i++) {
 		pmsg = &msgs[i];
 
 		ret = pcf_doAddress(adap, pmsg);
-- 
2.43.0
Re: [PATCH v6 3/3] i2c: pcf8584: Fix space(s) required before or after different operators
Posted by Andi Shyti 3 months, 3 weeks ago
Hi Cezar,

...

> @@ -284,7 +284,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
>  		goto out;
>  	}
>  
> -	for (i = 0;ret >= 0 && i < num; i++) {
> +	for (i = 0; ret >= 0 && i < num; i++) {

I think the variable ret can be used a bit better, the way it's
used is a bit confusing. I would remove the initialization above
and the check here.

You can declare "ret" inside the for loop...

>  		pmsg = &msgs[i];
>  
>  		ret = pcf_doAddress(adap, pmsg);

here ret does not have any effect, it will always be '0' and we
don't even check it. We don't need to save the value pf
"pcf_doAddress()" (another patch can be to make it void).

Later in the code you can assign ret depending on 
"if (pmsg->flags ..." and simply check "if (ret < 0) break;"

Andi

> -- 
> 2.43.0
>