linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c : algos : i2c-algo-pcf.c : fixed errors shown by checkpatch
@ 2025-09-07 11:45 Cezar Chiru
  2025-09-07 12:07 ` [PATCH v2] " Cezar Chiru
  2025-09-17 13:35 ` [PATCH v4 0/3] i2c: pcf8584: Fix errors reported by checkpatch.pl Cezar Chiru
  0 siblings, 2 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-07 11:45 UTC (permalink / raw)
  To: andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Fixed all 18 errors revealed using checkpatch.pl on i2c-algo-pcf.c
file. Errors fixed were: macros starting with 'if' should be
enclosed by do - while loop to avoid possible if/else logic defects,
do not use assignment in if condition, spaces required around '=' ,
';', '<' and ','.
Motivation is to fix all errors and warnings i2c-algo-pcf kerenel
module.

Testing:
    * built kernel with my changes and I2C_ALGOPCF=m enabled
    and it built successfully.
    * installed kernel and external modules generated by build
    * rebooted and loaded using modprobe i2c-algo-pcf kernel module
    with param i2c_debug=3 and no message was found related to
    module in dmesg. But also no error was generated.

Errors on patch: on running checkpatch.pl on this patch 4 warnings
were raised. Will be fixed on following warnings fixes patch.

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

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index fd563e845d4b..18ba21ff8992 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -23,9 +23,18 @@
 #include "i2c-algo-pcf.h"
 
 
-#define DEB2(x) if (i2c_debug >= 2) x
-#define DEB3(x) if (i2c_debug >= 3) x /* print several statistical values */
-#define DEBPROTO(x) if (i2c_debug >= 9) x;
+#define DEB2(x) do { \
+			if (i2c_debug >= 2)	\
+				x;	\
+		} while (0)
+#define DEB3(x) do { \
+			if (i2c_debug >= 3)	\
+				x;	\ /* print several statistical values */
+		} while (0)
+#define DEBPROTO(x) do { \
+			if (i2c_debug >= 9)	\
+				x;	\
+		} while (0)
 	/* debug the protocol by showing transferred bits */
 #define DEF_TIMEOUT 16
 
@@ -160,7 +169,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	 * check to see S1 now used as R/W ctrl -
 	 * PCF8584 does that when ESO is zero
 	 */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != (0)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp));
 		return -ENXIO; /* definitely not PCF8584 */
 	}
@@ -168,7 +178,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load own address in S0, effective address is (own << 1) */
 	i2c_outb(adap, get_own(adap));
 	/* check it's really written */
-	if ((temp = i2c_inb(adap)) != get_own(adap)) {
+	temp = i2c_inb(adap);
+	if (temp  != get_own(adap)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -176,7 +187,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* S1=0xA0, next byte in S2 */
 	set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
 	/* check to see S2 now selected */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != I2C_PCF_ES1) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -184,7 +196,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load clock register S2 */
 	i2c_outb(adap, get_clock(adap));
 	/* check it's really written, the only 5 lowest bits does matter */
-	if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
+	temp = i2c_inb(adap);
+	if ((temp & 0x1f) != get_clock(adap)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -193,7 +206,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	set_pcf(adap, 1, I2C_PCF_IDLE);
 
 	/* check to see PCF is really idled and we can access status register */
-	if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
+	temp = get_pcf(adap, 1);
+	if (temp != (I2C_PCF_PIN | I2C_PCF_BB)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -209,7 +223,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) {
 		DEB2(dev_dbg(&i2c_adap->dev, "i2c_write: writing %2.2X\n",
 				buf[wrcount] & 0xff));
 		i2c_outb(adap, buf[wrcount]);
@@ -246,7 +260,8 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
 	/* increment number of bytes to read by one -- read dummy byte */
 	for (i = 0; i <= count; i++) {
 
-		if ((wfp = wait_for_pin(adap, &status))) {
+		wfp = wait_for_pin(adap, &status);
+		if (wfp) {
 			if (wfp == -EINTR)
 				return -EINTR; /* arbitration lost */
 
@@ -299,7 +314,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);
@@ -313,7 +328,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];
 
 		DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
@@ -358,9 +373,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only read %d bytes.\n",ret));
+					    "only read %d bytes.\n", ret));
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n",ret));
+				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n", ret));
 			}
 		} else {
 			ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len,
@@ -368,9 +383,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only wrote %d bytes.\n",ret));
+					    "only wrote %d bytes.\n", ret));
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n",ret));
+				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n", ret));
 			}
 		}
 	}
@@ -406,7 +421,8 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
 	/* register new adapter to i2c module... */
 	adap->algo = &pcf_algo;
 
-	if ((rval = pcf_init_8584(pcf_adap)))
+	rval = pcf_init_8584(pcf_adap);
+	if (rval)
 		return rval;
 
 	rval = i2c_add_adapter(adap);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH v2] i2c : algos : i2c-algo-pcf.c : fixed errors shown by checkpatch
  2025-09-07 11:45 [PATCH] i2c : algos : i2c-algo-pcf.c : fixed errors shown by checkpatch Cezar Chiru
@ 2025-09-07 12:07 ` Cezar Chiru
  2025-09-07 13:19   ` Markus Elfring
  2025-09-17 13:35 ` [PATCH v4 0/3] i2c: pcf8584: Fix errors reported by checkpatch.pl Cezar Chiru
  1 sibling, 1 reply; 49+ messages in thread
From: Cezar Chiru @ 2025-09-07 12:07 UTC (permalink / raw)
  To: andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Fixed all 18 errors revealed using checkpatch.pl on i2c-algo-pcf.c
file. Errors fixed were: macros starting with 'if' should be
enclosed by do - while loop to avoid possible if/else logic defects,
do not use assignment in if condition, spaces required around '=' ,
';', '<' and ','.
Motivation is to fix all errors and warnings i2c-algo-pcf kerenel
module.

Testing:
    * built kernel with my changes and I2C_ALGOPCF=m enabled
    and it built successfully.
    * installed kernel and external modules generated by build
    * rebooted and loaded using modprobe i2c-algo-pcf kernel module
    with param i2c_debug=3 and no message was found related to
    module in dmesg. But also no error was generated.

Checkpatch.pl warnings  on patch: on running checkpatch.pl on this
patch 7 warnings were raised. Will be fixed on following warnings
fixes patch.

v2:
    Fixed build errors generated by missing ; after do - while.
    Missed to git add latest changes to patch. Build is ok.

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

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index fd563e845d4b..f5174f38d777 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -23,9 +23,10 @@
 #include "i2c-algo-pcf.h"
 
 
-#define DEB2(x) if (i2c_debug >= 2) x
-#define DEB3(x) if (i2c_debug >= 3) x /* print several statistical values */
-#define DEBPROTO(x) if (i2c_debug >= 9) x;
+#define DEB2(x) do { if (i2c_debug >= 2) x; } while (0);
+#define DEB3(x) do { if (i2c_debug >= 3) x; } while (0);
+	/* print several statistical values */
+#define DEBPROTO(x) do { if (i2c_debug >= 9) x; } while (0);
 	/* debug the protocol by showing transferred bits */
 #define DEF_TIMEOUT 16
 
@@ -160,7 +161,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	 * check to see S1 now used as R/W ctrl -
 	 * PCF8584 does that when ESO is zero
 	 */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != (0)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp));
 		return -ENXIO; /* definitely not PCF8584 */
 	}
@@ -168,7 +170,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load own address in S0, effective address is (own << 1) */
 	i2c_outb(adap, get_own(adap));
 	/* check it's really written */
-	if ((temp = i2c_inb(adap)) != get_own(adap)) {
+	temp = i2c_inb(adap);
+	if (temp  != get_own(adap)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -176,7 +179,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* S1=0xA0, next byte in S2 */
 	set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
 	/* check to see S2 now selected */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != I2C_PCF_ES1) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -184,7 +188,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load clock register S2 */
 	i2c_outb(adap, get_clock(adap));
 	/* check it's really written, the only 5 lowest bits does matter */
-	if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
+	temp = i2c_inb(adap);
+	if ((temp & 0x1f) != get_clock(adap)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -193,7 +198,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	set_pcf(adap, 1, I2C_PCF_IDLE);
 
 	/* check to see PCF is really idled and we can access status register */
-	if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
+	temp = get_pcf(adap, 1);
+	if (temp != (I2C_PCF_PIN | I2C_PCF_BB)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -209,7 +215,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) {
 		DEB2(dev_dbg(&i2c_adap->dev, "i2c_write: writing %2.2X\n",
 				buf[wrcount] & 0xff));
 		i2c_outb(adap, buf[wrcount]);
@@ -246,7 +252,8 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
 	/* increment number of bytes to read by one -- read dummy byte */
 	for (i = 0; i <= count; i++) {
 
-		if ((wfp = wait_for_pin(adap, &status))) {
+		wfp = wait_for_pin(adap, &status);
+		if (wfp) {
 			if (wfp == -EINTR)
 				return -EINTR; /* arbitration lost */
 
@@ -299,7 +306,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);
@@ -313,7 +320,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];
 
 		DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
@@ -358,9 +365,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only read %d bytes.\n",ret));
+					    "only read %d bytes.\n", ret));
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n",ret));
+				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n", ret));
 			}
 		} else {
 			ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len,
@@ -368,9 +375,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only wrote %d bytes.\n",ret));
+					    "only wrote %d bytes.\n", ret));
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n",ret));
+				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n", ret));
 			}
 		}
 	}
@@ -406,7 +413,8 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
 	/* register new adapter to i2c module... */
 	adap->algo = &pcf_algo;
 
-	if ((rval = pcf_init_8584(pcf_adap)))
+	rval = pcf_init_8584(pcf_adap);
+	if (rval)
 		return rval;
 
 	rval = i2c_add_adapter(adap);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH v2] i2c : algos : i2c-algo-pcf.c : fixed errors shown by checkpatch
  2025-09-07 12:07 ` [PATCH v2] " Cezar Chiru
@ 2025-09-07 13:19   ` Markus Elfring
  2025-09-07 15:38     ` Cezar Chiru
  0 siblings, 1 reply; 49+ messages in thread
From: Markus Elfring @ 2025-09-07 13:19 UTC (permalink / raw)
  To: Cezar Chiru, linux-i2c; +Cc: LKML, Andi Shyti

> Fixed all 18 errors revealed using checkpatch.pl on i2c-algo-pcf.c
…

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc4#n81> Motivation is to fix all errors and warnings i2c-algo-pcf kerenel
…
                                                            kernel?

…
> v2:
>     Fixed build errors generated by missing ; after do - while.
>     Missed to git add latest changes to patch. Build is ok.
> 
> Signed-off-by: Cezar Chiru <chiru.cezar.89@gmail.com>
> ---
>  drivers/i2c/algos/i2c-algo-pcf.c | 42 +++++++++++++++++++-------------
…

* Please move your patch version descriptions behind the marker line.
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc4#n784

* Will enumerations become more helpful?


Regards,
Markus

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v2] i2c : algos : i2c-algo-pcf.c : fixed errors shown by checkpatch
  2025-09-07 13:19   ` Markus Elfring
@ 2025-09-07 15:38     ` Cezar Chiru
  2025-09-07 17:45       ` [PATCH v3] " Markus Elfring
  0 siblings, 1 reply; 49+ messages in thread
From: Cezar Chiru @ 2025-09-07 15:38 UTC (permalink / raw)
  To: Markus.Elfring, andi.shyti; +Cc: linux-i2c, linux-kernel, chiru.cezar.89

[-- Attachment #1: Type: text/plain, Size: 1502 bytes --]

On Sun, Sep 07, 2025 at 03:19:20PM +0200, Markus Elfring wrote:

Hello Markus,

> > Fixed all 18 errors revealed using checkpatch.pl on i2c-algo-pcf.c
> …
> 
> See also:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc4#n81

Refactored the commit message to be more compact

> …
> > Motivation is to fix all errors and warnings i2c-algo-pcf kerenel
> …
>                                                             kernel?

Yes, "kernel" was intended. Fixed.

> > v2:
> >     Fixed build errors generated by missing ; after do - while.
> >     Missed to git add latest changes to patch. Build is ok.
> > 
> > Signed-off-by: Cezar Chiru <chiru.cezar.89@gmail.com>
> > ---
> >  drivers/i2c/algos/i2c-algo-pcf.c | 42 +++++++++++++++++++-------------
> …

I moved the version info and information from commit message that didn't
needed to reach the commit message after the --- marker line of the patch.
 
> 
> * Please move your patch version descriptions behind the marker line.
>   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc4#n784
> 
> * Will enumerations become more helpful?

If you were talking about enumerating the type of errors fixed in the commit 
message then I done that. If something else, could you please explain it to me?

Markus, Andi, new [PATCH v3] attached to this email.

Thank you,
Best regards,
Cezar Chiru


[-- Attachment #2: 0001-i2c-algos-i2c-algo-pcf.c-fixed-errors-shown-by-check.patch --]
[-- Type: text/x-diff, Size: 6982 bytes --]

From a94b19cb2c689989dbe72c04864bd718f2c05307 Mon Sep 17 00:00:00 2001
From: Cezar Chiru <chiru.cezar.89@gmail.com>
Date: Sun, 7 Sep 2025 13:41:05 +0300
Subject: [PATCH v3] i2c : algos : i2c-algo-pcf.c : fixed errors shown by
 checkpatch

Fixed errors revealed by checkpatch.pl on i2c-algo-pcf.c file.
Errors fixed were:
    1)macros starting with 'if' should be enclosed by do - while
    loop to avoid possible if/else logic defects
    2)do not use assignment in if condition
    3)spaces required around '=', ';', '<' and before ','.
Motivation is to fix all errors and warnings in i2c-algo-pcf
kernel module.

Signed-off-by: Cezar Chiru <chiru.cezar.89@gmail.com>
---
Testing:
  * built kernel with my changes and I2C_ALGOPCF=m enabled
  and it built successfully.
  * installed kernel and external modules generated by build
  * rebooted and loaded using modprobe i2c-algo-pcf kernel
  module with param i2c_debug=3 and no message was found
  related to module in dmesg. But also no error was generated.

Checkpatch.pl warnings  on patch: on running checkpatch.pl on this
  patch 7 warnings were raised. Will be fixed on following warnings
  fixes patch.

V1->V2:
  Fixed build errors generated by missing ; after do - while.
  Missed to git add latest changes to patch. Build is ok.
V2->V3:
  Fixed commit message spelling as pointed by Markus Elfring and
  by moving non-essential parts of commit message under the marker
  line.

 drivers/i2c/algos/i2c-algo-pcf.c | 42 +++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index fd563e845d4b..f5174f38d777 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -23,9 +23,10 @@
 #include "i2c-algo-pcf.h"
 
 
-#define DEB2(x) if (i2c_debug >= 2) x
-#define DEB3(x) if (i2c_debug >= 3) x /* print several statistical values */
-#define DEBPROTO(x) if (i2c_debug >= 9) x;
+#define DEB2(x) do { if (i2c_debug >= 2) x; } while (0);
+#define DEB3(x) do { if (i2c_debug >= 3) x; } while (0);
+	/* print several statistical values */
+#define DEBPROTO(x) do { if (i2c_debug >= 9) x; } while (0);
 	/* debug the protocol by showing transferred bits */
 #define DEF_TIMEOUT 16
 
@@ -160,7 +161,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	 * check to see S1 now used as R/W ctrl -
 	 * PCF8584 does that when ESO is zero
 	 */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != (0)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp));
 		return -ENXIO; /* definitely not PCF8584 */
 	}
@@ -168,7 +170,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load own address in S0, effective address is (own << 1) */
 	i2c_outb(adap, get_own(adap));
 	/* check it's really written */
-	if ((temp = i2c_inb(adap)) != get_own(adap)) {
+	temp = i2c_inb(adap);
+	if (temp  != get_own(adap)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -176,7 +179,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* S1=0xA0, next byte in S2 */
 	set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
 	/* check to see S2 now selected */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != I2C_PCF_ES1) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -184,7 +188,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load clock register S2 */
 	i2c_outb(adap, get_clock(adap));
 	/* check it's really written, the only 5 lowest bits does matter */
-	if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
+	temp = i2c_inb(adap);
+	if ((temp & 0x1f) != get_clock(adap)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -193,7 +198,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	set_pcf(adap, 1, I2C_PCF_IDLE);
 
 	/* check to see PCF is really idled and we can access status register */
-	if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
+	temp = get_pcf(adap, 1);
+	if (temp != (I2C_PCF_PIN | I2C_PCF_BB)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -209,7 +215,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) {
 		DEB2(dev_dbg(&i2c_adap->dev, "i2c_write: writing %2.2X\n",
 				buf[wrcount] & 0xff));
 		i2c_outb(adap, buf[wrcount]);
@@ -246,7 +252,8 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
 	/* increment number of bytes to read by one -- read dummy byte */
 	for (i = 0; i <= count; i++) {
 
-		if ((wfp = wait_for_pin(adap, &status))) {
+		wfp = wait_for_pin(adap, &status);
+		if (wfp) {
 			if (wfp == -EINTR)
 				return -EINTR; /* arbitration lost */
 
@@ -299,7 +306,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);
@@ -313,7 +320,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];
 
 		DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
@@ -358,9 +365,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only read %d bytes.\n",ret));
+					    "only read %d bytes.\n", ret));
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n",ret));
+				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n", ret));
 			}
 		} else {
 			ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len,
@@ -368,9 +375,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only wrote %d bytes.\n",ret));
+					    "only wrote %d bytes.\n", ret));
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n",ret));
+				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n", ret));
 			}
 		}
 	}
@@ -406,7 +413,8 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
 	/* register new adapter to i2c module... */
 	adap->algo = &pcf_algo;
 
-	if ((rval = pcf_init_8584(pcf_adap)))
+	rval = pcf_init_8584(pcf_adap);
+	if (rval)
 		return rval;
 
 	rval = i2c_add_adapter(adap);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH v3] i2c : algos : i2c-algo-pcf.c : fixed errors shown by checkpatch
  2025-09-07 15:38     ` Cezar Chiru
@ 2025-09-07 17:45       ` Markus Elfring
  2025-09-08 11:13         ` [PATCH 0/3] i2c : PCF8584 : Cover Letter Cezar Chiru
  0 siblings, 1 reply; 49+ messages in thread
From: Markus Elfring @ 2025-09-07 17:45 UTC (permalink / raw)
  To: Cezar Chiru, linux-i2c; +Cc: LKML, Andi Shyti

>> See also:
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc4#n81
> Refactored the commit message to be more compact

Would you get into the mood to contribute another improved patch series?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc4#n168


> Markus, Andi, new [PATCH v3] attached to this email.

Please take another look at the usual development message requirements.

Regards,
Markus

^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH 0/3] i2c : PCF8584 : Cover Letter
  2025-09-07 17:45       ` [PATCH v3] " Markus Elfring
@ 2025-09-08 11:13         ` Cezar Chiru
  2025-09-08 11:13           ` [PATCH 1/3] i2c : pcf8584 : Fix debug macros defines of if statements Cezar Chiru
                             ` (2 more replies)
  0 siblings, 3 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-08 11:13 UTC (permalink / raw)
  To: andi.shyti, Markus.Elfring; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Testing:
    *built kernel and modules with I2C_ALGOPCF=m and my 3 patches applied on top.
    *installed kernel and external modules generated by build on my laptop
    *rebooted and loaded i2c-algo-pcf.ko with param i2c_debug=2/3/9.
    *No success message related to i2c_algo_pcf was seen in dmesg but also no errors.
    *Module loading and unloading successfull.
    *No PCF8584 Hardware was available.

Patches 1 and 3 report 4 and 6 warnings when running checkpatch on them. But the warnings will be fixed in a new patchset that addresses fixing warnings.

Cezar Chiru (3):
  i2c : pcf8584 : Fix debug macros defines of if statements
  i2c : PCF8584 : Fix do not use assignment in 'if' conditional
  i2c : PCF8584 : Fixed space required after different operators

 drivers/i2c/algos/i2c-algo-pcf.c | 62 ++++++++++++++++++++------------
 1 file changed, 39 insertions(+), 23 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH 1/3] i2c : pcf8584 : Fix debug macros defines of if statements
  2025-09-08 11:13         ` [PATCH 0/3] i2c : PCF8584 : Cover Letter Cezar Chiru
@ 2025-09-08 11:13           ` Cezar Chiru
  2025-09-08 12:44             ` Markus Elfring
  2025-09-08 11:13           ` [PATCH 2/3] i2c : PCF8584 : Fix do not use assignment in 'if' conditional Cezar Chiru
  2025-09-08 11:13           ` [PATCH 3/3] i2c : PCF8584 : Fixed space required after different operators Cezar Chiru
  2 siblings, 1 reply; 49+ messages in thread
From: Cezar Chiru @ 2025-09-08 11:13 UTC (permalink / raw)
  To: andi.shyti, Markus.Elfring; +Cc: linux-i2c, linux-kernel, Cezar Chiru

The issue was that macros starting with 'if' should be enclosed by
do - while loop. Revealed by checkpatch.pl.
The patch fixes this and is necessary because by enclosure possible
if/else logic defects are avoided . Also fixed inconsistent macro
usage ending ';', which caused build error with the macro defines
enclosure in some cases.

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

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index fd563e845d4b..3fc4b5080a32 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -23,10 +23,19 @@
 #include "i2c-algo-pcf.h"
 
 
-#define DEB2(x) if (i2c_debug >= 2) x
-#define DEB3(x) if (i2c_debug >= 3) x /* print several statistical values */
-#define DEBPROTO(x) if (i2c_debug >= 9) x;
-	/* debug the protocol by showing transferred bits */
+#define DEB2(x) do { \
+			if (i2c_debug >= 2)	\
+				x;	\
+		} while (0)
+#define DEB3(x) do { \
+			if (i2c_debug >= 3)	\
+				x; /* print several statistical values */ \
+		} while (0)
+#define DEBPROTO(x)	do { \
+				if (i2c_debug >= 9)	\
+					x;	\
+				/* debug the protocol by showing transferred bits */	\
+			} while (0)
 #define DEF_TIMEOUT 16
 
 /*
@@ -308,7 +317,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 	timeout = wait_for_bb(adap);
 	if (timeout) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: "
-			    "Timeout waiting for BB in pcf_xfer\n");)
+			    "Timeout waiting for BB in pcf_xfer\n"));
 		i = -EIO;
 		goto out;
 	}
@@ -318,7 +327,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 		DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
 		     str_read_write(pmsg->flags & I2C_M_RD),
-		     pmsg->len, pmsg->addr, i + 1, num);)
+		     pmsg->len, pmsg->addr, i + 1, num));
 
 		ret = pcf_doAddress(adap, pmsg);
 
@@ -336,7 +345,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 			}
 			i2c_stop(adap);
 			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: Timeout waiting "
-				    "for PIN(1) in pcf_xfer\n");)
+				    "for PIN(1) in pcf_xfer\n"));
 			i = -EREMOTEIO;
 			goto out;
 		}
@@ -344,13 +353,13 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 		/* Check LRB (last rcvd bit - slave ack) */
 		if (status & I2C_PCF_LRB) {
 			i2c_stop(adap);
-			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");)
+			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n"));
 			i = -EREMOTEIO;
 			goto out;
 		}
 
 		DEB3(printk(KERN_DEBUG "i2c-algo-pcf.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n",
-			    i, msgs[i].addr, msgs[i].flags, msgs[i].len);)
+			    i, msgs[i].addr, msgs[i].flags, msgs[i].len));
 
 		if (pmsg->flags & I2C_M_RD) {
 			ret = pcf_readbytes(i2c_adap, pmsg->buf, pmsg->len,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 2/3] i2c : PCF8584 : Fix do not use assignment in 'if' conditional
  2025-09-08 11:13         ` [PATCH 0/3] i2c : PCF8584 : Cover Letter Cezar Chiru
  2025-09-08 11:13           ` [PATCH 1/3] i2c : pcf8584 : Fix debug macros defines of if statements Cezar Chiru
@ 2025-09-08 11:13           ` Cezar Chiru
  2025-09-08 11:13           ` [PATCH 3/3] i2c : PCF8584 : Fixed space required after different operators Cezar Chiru
  2 siblings, 0 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-08 11:13 UTC (permalink / raw)
  To: andi.shyti, Markus.Elfring; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Fixed errors usage of assignment inside of 'if' conditional
statements. Revealed by checkpatch.pl.
Fixed by moving assignment from inside 'if' to 1 line before each
if conditional statement that caused errors.

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

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 3fc4b5080a32..598bf000bf4a 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -169,7 +169,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	 * check to see S1 now used as R/W ctrl -
 	 * PCF8584 does that when ESO is zero
 	 */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != (0)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp));
 		return -ENXIO; /* definitely not PCF8584 */
 	}
@@ -177,7 +178,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load own address in S0, effective address is (own << 1) */
 	i2c_outb(adap, get_own(adap));
 	/* check it's really written */
-	if ((temp = i2c_inb(adap)) != get_own(adap)) {
+	temp = i2c_inb(adap);
+	if (temp != get_own(adap)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -185,7 +187,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* S1=0xA0, next byte in S2 */
 	set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
 	/* check to see S2 now selected */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != I2C_PCF_ES1) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -193,7 +196,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load clock register S2 */
 	i2c_outb(adap, get_clock(adap));
 	/* check it's really written, the only 5 lowest bits does matter */
-	if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
+	temp = i2c_inb(adap);
+	if ((temp & 0x1f) != get_clock(adap)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -202,7 +206,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	set_pcf(adap, 1, I2C_PCF_IDLE);
 
 	/* check to see PCF is really idled and we can access status register */
-	if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
+	temp = get_pcf(adap, 1);
+	if (temp != (I2C_PCF_PIN | I2C_PCF_BB)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -255,7 +260,8 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
 	/* increment number of bytes to read by one -- read dummy byte */
 	for (i = 0; i <= count; i++) {
 
-		if ((wfp = wait_for_pin(adap, &status))) {
+		wfp = wait_for_pin(adap, &status);
+		if (wfp) {
 			if (wfp == -EINTR)
 				return -EINTR; /* arbitration lost */
 
@@ -415,7 +421,8 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
 	/* register new adapter to i2c module... */
 	adap->algo = &pcf_algo;
 
-	if ((rval = pcf_init_8584(pcf_adap)))
+	rval = pcf_init_8584(pcf_adap);
+	if (rval)
 		return rval;
 
 	rval = i2c_add_adapter(adap);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH 3/3] i2c : PCF8584 : Fixed space required after different operators
  2025-09-08 11:13         ` [PATCH 0/3] i2c : PCF8584 : Cover Letter Cezar Chiru
  2025-09-08 11:13           ` [PATCH 1/3] i2c : pcf8584 : Fix debug macros defines of if statements Cezar Chiru
  2025-09-08 11:13           ` [PATCH 2/3] i2c : PCF8584 : Fix do not use assignment in 'if' conditional Cezar Chiru
@ 2025-09-08 11:13           ` Cezar Chiru
  2 siblings, 0 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-08 11:13 UTC (permalink / raw)
  To: andi.shyti, Markus.Elfring; +Cc: linux-i2c, linux-kernel, Cezar Chiru

The error was: spaces required around or before or after  '=',
';', '<' and ',' operators.
Fixed by adding space(s) around or before or after different
operators.

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

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 598bf000bf4a..3439b7387a54 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -223,7 +223,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) {
 		DEB2(dev_dbg(&i2c_adap->dev, "i2c_write: writing %2.2X\n",
 				buf[wrcount] & 0xff));
 		i2c_outb(adap, buf[wrcount]);
@@ -314,7 +314,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);
@@ -328,7 +328,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];
 
 		DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
@@ -373,9 +373,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only read %d bytes.\n",ret));
+					    "only read %d bytes.\n", ret));
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n",ret));
+				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n", ret));
 			}
 		} else {
 			ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len,
@@ -383,9 +383,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only wrote %d bytes.\n",ret));
+					    "only wrote %d bytes.\n", ret));
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n",ret));
+				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n", ret));
 			}
 		}
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH 1/3] i2c : pcf8584 : Fix debug macros defines of if statements
  2025-09-08 11:13           ` [PATCH 1/3] i2c : pcf8584 : Fix debug macros defines of if statements Cezar Chiru
@ 2025-09-08 12:44             ` Markus Elfring
  2025-09-08 13:36               ` [PATCH v2 0/3] i2c: PCF8584: Cover letter Cezar Chiru
  0 siblings, 1 reply; 49+ messages in thread
From: Markus Elfring @ 2025-09-08 12:44 UTC (permalink / raw)
  To: Cezar Chiru, linux-i2c; +Cc: LKML, Andi Shyti

…> The patch fixes this and …

Would you care for the usage of imperative mood in your change descriptions?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc5#n94

How do you think about to omit space characters before colons in patch prefixes?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc5#n649

Regards,
Markus

^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v2 0/3] i2c: PCF8584: Cover letter
  2025-09-08 12:44             ` Markus Elfring
@ 2025-09-08 13:36               ` Cezar Chiru
  2025-09-08 13:36                 ` [PATCH v2 1/3] i2c: PCF8584: Fix debug macros defines of if statements Cezar Chiru
                                   ` (2 more replies)
  0 siblings, 3 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-08 13:36 UTC (permalink / raw)
  To: andi.shyti, Markus.Elfring; +Cc: linux-i2c, linux-kernel, Cezar Chiru

---

Order of patches to be applied:
1st: * i2c: PCF8584: Fix debug macros defines of if statements
2nd: * i2c: PCF8584: Fix do not use assignment in 'if' conditional
3rd: * i2c: PCF8584: Fixed space(s) required after different operators

Testing:
  *built kernel and modules with I2C_ALGOPCF=m and my 3 patches applied on top.
  *installed kernel and external modules generated by build on my laptop
  *rebooted and loaded i2c-algo-pcf.ko with param i2c_debug=2/3/9.
  *No success message related to i2c_algo_pcf was seen in dmesg but also no errors.
  *Module loading and unloading successfull.
  *No PCF8584 Hardware was available.

Patches 1 and 3 report 4 and 6 warnings when running checkpatch on them.
But the warnings will be fixed in a new patchset that addresses fixing warnings.

Cezar Chiru (3):
  i2c: PCF8584: Fix debug macros defines of if statements
  i2c: PCF8584: Fix do not use assignment in 'if' conditional
  i2c: PCF8584: Fixed space(s) required after different operators

 drivers/i2c/algos/i2c-algo-pcf.c | 62 ++++++++++++++++++++------------
 1 file changed, 39 insertions(+), 23 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v2 1/3] i2c: PCF8584: Fix debug macros defines of if statements
  2025-09-08 13:36               ` [PATCH v2 0/3] i2c: PCF8584: Cover letter Cezar Chiru
@ 2025-09-08 13:36                 ` Cezar Chiru
  2025-09-08 14:46                   ` Markus Elfring
  2025-09-08 13:36                 ` [PATCH v2 2/3] i2c: PCF8584: Fix do not use assignment in 'if' conditional Cezar Chiru
  2025-09-08 13:36                 ` [PATCH v2 3/3] i2c: PCF8584: Fixed space(s) required after different operators Cezar Chiru
  2 siblings, 1 reply; 49+ messages in thread
From: Cezar Chiru @ 2025-09-08 13:36 UTC (permalink / raw)
  To: andi.shyti, Markus.Elfring; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Macros starting with 'if' should be enclosed by do - while loop.
Revealed by checkpatch.pl.
Change is necessary because by enclosure possible if/else logic
defects are avoided . Also fixed inconsistent macro usage ending
';', which caused build error with the macro defines
enclosure in some cases.

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

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index fd563e845d4b..3fc4b5080a32 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -23,10 +23,19 @@
 #include "i2c-algo-pcf.h"
 
 
-#define DEB2(x) if (i2c_debug >= 2) x
-#define DEB3(x) if (i2c_debug >= 3) x /* print several statistical values */
-#define DEBPROTO(x) if (i2c_debug >= 9) x;
-	/* debug the protocol by showing transferred bits */
+#define DEB2(x) do { \
+			if (i2c_debug >= 2)	\
+				x;	\
+		} while (0)
+#define DEB3(x) do { \
+			if (i2c_debug >= 3)	\
+				x; /* print several statistical values */ \
+		} while (0)
+#define DEBPROTO(x)	do { \
+				if (i2c_debug >= 9)	\
+					x;	\
+				/* debug the protocol by showing transferred bits */	\
+			} while (0)
 #define DEF_TIMEOUT 16
 
 /*
@@ -308,7 +317,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 	timeout = wait_for_bb(adap);
 	if (timeout) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: "
-			    "Timeout waiting for BB in pcf_xfer\n");)
+			    "Timeout waiting for BB in pcf_xfer\n"));
 		i = -EIO;
 		goto out;
 	}
@@ -318,7 +327,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 		DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
 		     str_read_write(pmsg->flags & I2C_M_RD),
-		     pmsg->len, pmsg->addr, i + 1, num);)
+		     pmsg->len, pmsg->addr, i + 1, num));
 
 		ret = pcf_doAddress(adap, pmsg);
 
@@ -336,7 +345,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 			}
 			i2c_stop(adap);
 			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: Timeout waiting "
-				    "for PIN(1) in pcf_xfer\n");)
+				    "for PIN(1) in pcf_xfer\n"));
 			i = -EREMOTEIO;
 			goto out;
 		}
@@ -344,13 +353,13 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 		/* Check LRB (last rcvd bit - slave ack) */
 		if (status & I2C_PCF_LRB) {
 			i2c_stop(adap);
-			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");)
+			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n"));
 			i = -EREMOTEIO;
 			goto out;
 		}
 
 		DEB3(printk(KERN_DEBUG "i2c-algo-pcf.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n",
-			    i, msgs[i].addr, msgs[i].flags, msgs[i].len);)
+			    i, msgs[i].addr, msgs[i].flags, msgs[i].len));
 
 		if (pmsg->flags & I2C_M_RD) {
 			ret = pcf_readbytes(i2c_adap, pmsg->buf, pmsg->len,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH v2 2/3] i2c: PCF8584: Fix do not use assignment in 'if' conditional
  2025-09-08 13:36               ` [PATCH v2 0/3] i2c: PCF8584: Cover letter Cezar Chiru
  2025-09-08 13:36                 ` [PATCH v2 1/3] i2c: PCF8584: Fix debug macros defines of if statements Cezar Chiru
@ 2025-09-08 13:36                 ` Cezar Chiru
  2025-09-08 13:36                 ` [PATCH v2 3/3] i2c: PCF8584: Fixed space(s) required after different operators Cezar Chiru
  2 siblings, 0 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-08 13:36 UTC (permalink / raw)
  To: andi.shyti, Markus.Elfring; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Fixed errors usage of assignment inside of 'if' conditional
statements. Revealed by checkpatch.pl.
Fixed by moving assignment from inside 'if' to 1 line before each
if conditional statement that caused errors.

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

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 3fc4b5080a32..598bf000bf4a 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -169,7 +169,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	 * check to see S1 now used as R/W ctrl -
 	 * PCF8584 does that when ESO is zero
 	 */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != (0)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp));
 		return -ENXIO; /* definitely not PCF8584 */
 	}
@@ -177,7 +178,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load own address in S0, effective address is (own << 1) */
 	i2c_outb(adap, get_own(adap));
 	/* check it's really written */
-	if ((temp = i2c_inb(adap)) != get_own(adap)) {
+	temp = i2c_inb(adap);
+	if (temp != get_own(adap)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -185,7 +187,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* S1=0xA0, next byte in S2 */
 	set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
 	/* check to see S2 now selected */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != I2C_PCF_ES1) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -193,7 +196,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load clock register S2 */
 	i2c_outb(adap, get_clock(adap));
 	/* check it's really written, the only 5 lowest bits does matter */
-	if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
+	temp = i2c_inb(adap);
+	if ((temp & 0x1f) != get_clock(adap)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -202,7 +206,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	set_pcf(adap, 1, I2C_PCF_IDLE);
 
 	/* check to see PCF is really idled and we can access status register */
-	if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
+	temp = get_pcf(adap, 1);
+	if (temp != (I2C_PCF_PIN | I2C_PCF_BB)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -255,7 +260,8 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
 	/* increment number of bytes to read by one -- read dummy byte */
 	for (i = 0; i <= count; i++) {
 
-		if ((wfp = wait_for_pin(adap, &status))) {
+		wfp = wait_for_pin(adap, &status);
+		if (wfp) {
 			if (wfp == -EINTR)
 				return -EINTR; /* arbitration lost */
 
@@ -415,7 +421,8 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
 	/* register new adapter to i2c module... */
 	adap->algo = &pcf_algo;
 
-	if ((rval = pcf_init_8584(pcf_adap)))
+	rval = pcf_init_8584(pcf_adap);
+	if (rval)
 		return rval;
 
 	rval = i2c_add_adapter(adap);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH v2 3/3] i2c: PCF8584: Fixed space(s) required after different operators
  2025-09-08 13:36               ` [PATCH v2 0/3] i2c: PCF8584: Cover letter Cezar Chiru
  2025-09-08 13:36                 ` [PATCH v2 1/3] i2c: PCF8584: Fix debug macros defines of if statements Cezar Chiru
  2025-09-08 13:36                 ` [PATCH v2 2/3] i2c: PCF8584: Fix do not use assignment in 'if' conditional Cezar Chiru
@ 2025-09-08 13:36                 ` Cezar Chiru
  2 siblings, 0 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-08 13:36 UTC (permalink / raw)
  To: andi.shyti, Markus.Elfring; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Error: spaces required around or before or after  '=', ';', '<'
and ',' operators. Revealed by checkpatch.pl.
Added space(s) around or before or after different operators.

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

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 598bf000bf4a..3439b7387a54 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -223,7 +223,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) {
 		DEB2(dev_dbg(&i2c_adap->dev, "i2c_write: writing %2.2X\n",
 				buf[wrcount] & 0xff));
 		i2c_outb(adap, buf[wrcount]);
@@ -314,7 +314,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);
@@ -328,7 +328,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];
 
 		DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
@@ -373,9 +373,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only read %d bytes.\n",ret));
+					    "only read %d bytes.\n", ret));
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n",ret));
+				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n", ret));
 			}
 		} else {
 			ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len,
@@ -383,9 +383,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only wrote %d bytes.\n",ret));
+					    "only wrote %d bytes.\n", ret));
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n",ret));
+				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n", ret));
 			}
 		}
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH v2 1/3] i2c: PCF8584: Fix debug macros defines of if statements
  2025-09-08 13:36                 ` [PATCH v2 1/3] i2c: PCF8584: Fix debug macros defines of if statements Cezar Chiru
@ 2025-09-08 14:46                   ` Markus Elfring
  2025-09-08 15:42                     ` Cezar Chiru
  0 siblings, 1 reply; 49+ messages in thread
From: Markus Elfring @ 2025-09-08 14:46 UTC (permalink / raw)
  To: Cezar Chiru, linux-i2c; +Cc: LKML, Andi Shyti

…> Change is necessary because …

Does anything hinder you to choose imperative mood for change descriptions?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc5#n94

Would you occasionally care more also for word wrapping?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc5#n658


…> ---
>  drivers/i2c/algos/i2c-algo-pcf.c | 27 ++++++++++++++++++---------
…

Some contributors would appreciate patch version descriptions.
https://lore.kernel.org/all/?q=%22This+looks+like+a+new+version+of+a+previously+submitted+patch%22
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc5#n310

Regards,
Markus

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v2 1/3] i2c: PCF8584: Fix debug macros defines of if statements
  2025-09-08 14:46                   ` Markus Elfring
@ 2025-09-08 15:42                     ` Cezar Chiru
  2025-09-08 17:08                       ` [v2 " Markus Elfring
  0 siblings, 1 reply; 49+ messages in thread
From: Cezar Chiru @ 2025-09-08 15:42 UTC (permalink / raw)
  To: Markus Elfring; +Cc: Andi Shyti, linux-i2c, linux-kernel

On Mon, Sep 08, 2025 at 04:46:47PM +0200, Markus Elfring wrote:

Hello Markus,

First I want to thank you for reviewing my patches and patchset and making
comments for me to improve my patches.

I am new to kernel hacking and this is the first patchset that I submit to
linux kernel. I'm doing my best to improve my work so that it can be 
accepted into the kernel tree.

> …> Change is necessary because …
> 
> Does anything hinder you to choose imperative mood for change descriptions?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc5#n94

Sorry, I didn't understood the first time. I will try my best.

> 
> Would you occasionally care more also for word wrapping?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc5#n658
> 

I will follow from now on the line wrapped at 75 columns.

>
> …> ---
> >  drivers/i2c/algos/i2c-algo-pcf.c | 27 ++++++++++++++++++---------
> …
> 
> Some contributors would appreciate patch version descriptions.
> https://lore.kernel.org/all/?q=%22This+looks+like+a+new+version+of+a+previously+submitted+patch%22
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.17-rc5#n310
> 

After I sent V2 of patchset I realized I didn't included changes after ---
marker line.

I will send V3 trying to apply your suggestions.

Best regards,
Cezar Chiru


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [v2 1/3] i2c: PCF8584: Fix debug macros defines of if statements
  2025-09-08 15:42                     ` Cezar Chiru
@ 2025-09-08 17:08                       ` Markus Elfring
  2025-09-08 17:58                         ` [PATCH v3 0/3] i2c: PCF8584: Fix errors reported by checkpatch.pl Cezar Chiru
  0 siblings, 1 reply; 49+ messages in thread
From: Markus Elfring @ 2025-09-08 17:08 UTC (permalink / raw)
  To: Cezar Chiru, linux-i2c; +Cc: LKML, Andi Shyti

> Sorry, I didn't understood the first time. I will try my best.

Would you get further development inspirations from previously published information?

Regards,
Markus

^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 0/3] i2c: PCF8584: Fix errors reported by checkpatch.pl
  2025-09-08 17:08                       ` [v2 " Markus Elfring
@ 2025-09-08 17:58                         ` Cezar Chiru
  2025-09-08 17:59                           ` [PATCH v3 1/3] i2c: PCF8584: Fix debug macros defines of if statements Cezar Chiru
                                             ` (2 more replies)
  0 siblings, 3 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-08 17:58 UTC (permalink / raw)
  To: andi.shyti, Markus.Elfring; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Hello maintainers,

This patch series fixes 18 errors reported by checkpatch.pl on
drivers/i2c/algos/i2c-algo-pcf.c file.

The series v1->v2->v3 is a response to the discussion on the mailing 
list with Markus Elfring that had comments on my earlier submisions. First
he suggested to split my initial submission in a patch series. Then he had
some valid points on imperative mood usage in commit messages, wrapping
commit message to 75 columns per line.

Here is a brief summary and Order of patches to be applied:

Patch 1/3: i2c: PCF8584: Fix debug macros defines of if statements
This patch encloses the debug macro defines of if statements in do-while
loops.

Patch 2/3: i2c: PCF8584: Fix do not use assignment in if conditional
This patch takes the assignement from if conditional and moves it by 1 line
up.

Patch 3/3: i2c: PCF8584: Fix space(s) required before or after different
           operators
This patch adds space(s) around, before or after some operators

Testing:
  *built kernel and modules with I2C_ALGOPCF=m and my 3 patches applied on
  top.
  *installed kernel and external modules generated by build on my laptop
  *rebooted and loaded i2c-algo-pcf.ko with param i2c_debug=2/3/9.
  *No success message related to i2c_algo_pcf was seen in dmesg but also no
  errors.
  *Module loading and unloading successfull.
  *No PCF8584 Hardware was available.
 
Patches 1 and 3 report 4 and 6 warnings when running checkpatch on them.
But the warnings will be fixed in a new patchset that addresses fixing
warnings.


Cezar Chiru (3):
  i2c: PCF8584: Fix debug macros defines of if statements
  i2c: PCF8584: Fix do not use assignment in if conditional
  i2c: PCF8584: Fix space(s) required before or after different operators

 drivers/i2c/algos/i2c-algo-pcf.c | 62 ++++++++++++++++++++------------
 1 file changed, 39 insertions(+), 23 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v3 1/3] i2c: PCF8584: Fix debug macros defines of if statements
  2025-09-08 17:58                         ` [PATCH v3 0/3] i2c: PCF8584: Fix errors reported by checkpatch.pl Cezar Chiru
@ 2025-09-08 17:59                           ` Cezar Chiru
  2025-09-08 19:18                             ` Markus Elfring
  2025-09-08 17:59                           ` [PATCH v3 2/3] i2c: PCF8584: Fix do not use assignment in if conditional Cezar Chiru
  2025-09-08 17:59                           ` [PATCH v3 3/3] i2c: PCF8584: Fix space(s) required before or after different operators Cezar Chiru
  2 siblings, 1 reply; 49+ messages in thread
From: Cezar Chiru @ 2025-09-08 17:59 UTC (permalink / raw)
  To: andi.shyti, Markus.Elfring; +Cc: linux-i2c, linux-kernel, Cezar Chiru

macros: Enclose 'if' statements debug macros defines in do - while loops.
Fix inconsistent macro usage ending ';', which caused build errors in some
cases.

Signed-off-by: Cezar Chiru <chiru.cezar.89@gmail.com>

---

v1->v2: - Removed space between [subsystem] and ':' in subject line.
        - Attempted to change commit message to imperative mood but I
        didn't understood how.
v2->v3: - Formulated again the commit message to be at imperative mood.
        - Wrapped commit message to 75 columns per line.

 drivers/i2c/algos/i2c-algo-pcf.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index fd563e845d4b..3fc4b5080a32 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -23,10 +23,19 @@
 #include "i2c-algo-pcf.h"
 
 
-#define DEB2(x) if (i2c_debug >= 2) x
-#define DEB3(x) if (i2c_debug >= 3) x /* print several statistical values */
-#define DEBPROTO(x) if (i2c_debug >= 9) x;
-	/* debug the protocol by showing transferred bits */
+#define DEB2(x) do { \
+			if (i2c_debug >= 2)	\
+				x;	\
+		} while (0)
+#define DEB3(x) do { \
+			if (i2c_debug >= 3)	\
+				x; /* print several statistical values */ \
+		} while (0)
+#define DEBPROTO(x)	do { \
+				if (i2c_debug >= 9)	\
+					x;	\
+				/* debug the protocol by showing transferred bits */	\
+			} while (0)
 #define DEF_TIMEOUT 16
 
 /*
@@ -308,7 +317,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 	timeout = wait_for_bb(adap);
 	if (timeout) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: "
-			    "Timeout waiting for BB in pcf_xfer\n");)
+			    "Timeout waiting for BB in pcf_xfer\n"));
 		i = -EIO;
 		goto out;
 	}
@@ -318,7 +327,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 		DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
 		     str_read_write(pmsg->flags & I2C_M_RD),
-		     pmsg->len, pmsg->addr, i + 1, num);)
+		     pmsg->len, pmsg->addr, i + 1, num));
 
 		ret = pcf_doAddress(adap, pmsg);
 
@@ -336,7 +345,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 			}
 			i2c_stop(adap);
 			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: Timeout waiting "
-				    "for PIN(1) in pcf_xfer\n");)
+				    "for PIN(1) in pcf_xfer\n"));
 			i = -EREMOTEIO;
 			goto out;
 		}
@@ -344,13 +353,13 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 		/* Check LRB (last rcvd bit - slave ack) */
 		if (status & I2C_PCF_LRB) {
 			i2c_stop(adap);
-			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");)
+			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n"));
 			i = -EREMOTEIO;
 			goto out;
 		}
 
 		DEB3(printk(KERN_DEBUG "i2c-algo-pcf.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n",
-			    i, msgs[i].addr, msgs[i].flags, msgs[i].len);)
+			    i, msgs[i].addr, msgs[i].flags, msgs[i].len));
 
 		if (pmsg->flags & I2C_M_RD) {
 			ret = pcf_readbytes(i2c_adap, pmsg->buf, pmsg->len,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH v3 2/3] i2c: PCF8584: Fix do not use assignment in if conditional
  2025-09-08 17:58                         ` [PATCH v3 0/3] i2c: PCF8584: Fix errors reported by checkpatch.pl Cezar Chiru
  2025-09-08 17:59                           ` [PATCH v3 1/3] i2c: PCF8584: Fix debug macros defines of if statements Cezar Chiru
@ 2025-09-08 17:59                           ` Cezar Chiru
  2025-09-08 17:59                           ` [PATCH v3 3/3] i2c: PCF8584: Fix space(s) required before or after different operators Cezar Chiru
  2 siblings, 0 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-08 17:59 UTC (permalink / raw)
  To: andi.shyti, Markus.Elfring; +Cc: linux-i2c, linux-kernel, Cezar Chiru

if statement: Use of assignment inside of 'if' conditional is not allowed.
Move assignment from inside 'if' conditional, to one line before each 'if'
conditional statement that caused errors.

Signed-off-by: Cezar Chiru <chiru.cezar.89@gmail.com>

---

v1->v2: - Removed space between [subsystem] and ':' in subject line.
        - Attempted to change commit message to imperative mood but I
        didn't understood how.
v2->v3: - Formulated again the commit message to imperative mood.
        - Wrapped commit message to 75 columns per line.
        - Removed '' from subject line of patch

 drivers/i2c/algos/i2c-algo-pcf.c | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 3fc4b5080a32..598bf000bf4a 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -169,7 +169,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	 * check to see S1 now used as R/W ctrl -
 	 * PCF8584 does that when ESO is zero
 	 */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != (0)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp));
 		return -ENXIO; /* definitely not PCF8584 */
 	}
@@ -177,7 +178,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load own address in S0, effective address is (own << 1) */
 	i2c_outb(adap, get_own(adap));
 	/* check it's really written */
-	if ((temp = i2c_inb(adap)) != get_own(adap)) {
+	temp = i2c_inb(adap);
+	if (temp != get_own(adap)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -185,7 +187,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* S1=0xA0, next byte in S2 */
 	set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
 	/* check to see S2 now selected */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != I2C_PCF_ES1) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -193,7 +196,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load clock register S2 */
 	i2c_outb(adap, get_clock(adap));
 	/* check it's really written, the only 5 lowest bits does matter */
-	if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
+	temp = i2c_inb(adap);
+	if ((temp & 0x1f) != get_clock(adap)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -202,7 +206,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	set_pcf(adap, 1, I2C_PCF_IDLE);
 
 	/* check to see PCF is really idled and we can access status register */
-	if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
+	temp = get_pcf(adap, 1);
+	if (temp != (I2C_PCF_PIN | I2C_PCF_BB)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -255,7 +260,8 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
 	/* increment number of bytes to read by one -- read dummy byte */
 	for (i = 0; i <= count; i++) {
 
-		if ((wfp = wait_for_pin(adap, &status))) {
+		wfp = wait_for_pin(adap, &status);
+		if (wfp) {
 			if (wfp == -EINTR)
 				return -EINTR; /* arbitration lost */
 
@@ -415,7 +421,8 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
 	/* register new adapter to i2c module... */
 	adap->algo = &pcf_algo;
 
-	if ((rval = pcf_init_8584(pcf_adap)))
+	rval = pcf_init_8584(pcf_adap);
+	if (rval)
 		return rval;
 
 	rval = i2c_add_adapter(adap);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH v3 3/3] i2c: PCF8584: Fix space(s) required before or after different operators
  2025-09-08 17:58                         ` [PATCH v3 0/3] i2c: PCF8584: Fix errors reported by checkpatch.pl Cezar Chiru
  2025-09-08 17:59                           ` [PATCH v3 1/3] i2c: PCF8584: Fix debug macros defines of if statements Cezar Chiru
  2025-09-08 17:59                           ` [PATCH v3 2/3] i2c: PCF8584: Fix do not use assignment in if conditional Cezar Chiru
@ 2025-09-08 17:59                           ` Cezar Chiru
  2025-09-09  7:30                             ` Markus Elfring
  2 siblings, 1 reply; 49+ messages in thread
From: Cezar Chiru @ 2025-09-08 17:59 UTC (permalink / raw)
  To: andi.shyti, Markus.Elfring; +Cc: linux-i2c, linux-kernel, Cezar Chiru

operators: Require spaces around or before or after '=', ';', '<' and ','.
Add space(s) around or before or after different operators.

Signed-off-by: Cezar Chiru <chiru.cezar.89@gmail.com>

---

v1->v2: - Removed space between [subsystem] and ':' in subject line.
        - Attempted to change commit message to imperative mood but I
        didn't understood how.
v2->v3: - Formulated again the commit message to imperative mood.
        - Wrapped commit message to 75 columns per line.
        - Changed subject line of patch

 drivers/i2c/algos/i2c-algo-pcf.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 598bf000bf4a..3439b7387a54 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -223,7 +223,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) {
 		DEB2(dev_dbg(&i2c_adap->dev, "i2c_write: writing %2.2X\n",
 				buf[wrcount] & 0xff));
 		i2c_outb(adap, buf[wrcount]);
@@ -314,7 +314,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);
@@ -328,7 +328,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];
 
 		DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
@@ -373,9 +373,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only read %d bytes.\n",ret));
+					    "only read %d bytes.\n", ret));
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n",ret));
+				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n", ret));
 			}
 		} else {
 			ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len,
@@ -383,9 +383,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only wrote %d bytes.\n",ret));
+					    "only wrote %d bytes.\n", ret));
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n",ret));
+				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n", ret));
 			}
 		}
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 1/3] i2c: PCF8584: Fix debug macros defines of if statements
  2025-09-08 17:59                           ` [PATCH v3 1/3] i2c: PCF8584: Fix debug macros defines of if statements Cezar Chiru
@ 2025-09-08 19:18                             ` Markus Elfring
  0 siblings, 0 replies; 49+ messages in thread
From: Markus Elfring @ 2025-09-08 19:18 UTC (permalink / raw)
  To: Cezar Chiru, linux-i2c; +Cc: LKML, Andi Shyti

> macros: Enclose 'if' statements debug macros defines in do - while loops.

Would it be helpful to indicate in each commit message how the change motivation
was influenced by the script “checkpatch.pl”?

Regards,
Markus

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 3/3] i2c: PCF8584: Fix space(s) required before or after different operators
  2025-09-08 17:59                           ` [PATCH v3 3/3] i2c: PCF8584: Fix space(s) required before or after different operators Cezar Chiru
@ 2025-09-09  7:30                             ` Markus Elfring
  2025-09-09  8:18                               ` Cezar Chiru
  0 siblings, 1 reply; 49+ messages in thread
From: Markus Elfring @ 2025-09-09  7:30 UTC (permalink / raw)
  To: Cezar Chiru, linux-i2c; +Cc: LKML, Andi Shyti

> operators: Require spaces around or before or after '=', ';', '<' and ','.
> Add space(s) around or before or after different operators.

How do you think about to refine such a wording approach another bit?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.17-rc5#n274
https://elixir.bootlin.com/linux/v6.17-rc5/source/scripts/checkpatch.pl#L5090-L5399

Regards,
Markus

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v3 3/3] i2c: PCF8584: Fix space(s) required before or after different operators
  2025-09-09  7:30                             ` Markus Elfring
@ 2025-09-09  8:18                               ` Cezar Chiru
  0 siblings, 0 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-09  8:18 UTC (permalink / raw)
  To: Markus Elfring; +Cc: linux-i2c, LKML, Andi Shyti

Hi Markus,

Thank you for the time to review my patch series.

> > operators: Require spaces around or before or after '=', ';', '<' and ','.
> > Add space(s) around or before or after different operators.
>
> How do you think about to refine such a wording approach another bit?
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.17-rc5#n274
> https://elixir.bootlin.com/linux/v6.17-rc5/source/scripts/checkpatch.pl#L5090-L5399

I will refer to binary and ternary operators instead of listing them. Also I
will say punctuation signs like: ';' , ','

^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v4 0/3] i2c: pcf8584: Fix errors reported by checkpatch.pl
  2025-09-07 11:45 [PATCH] i2c : algos : i2c-algo-pcf.c : fixed errors shown by checkpatch Cezar Chiru
  2025-09-07 12:07 ` [PATCH v2] " Cezar Chiru
@ 2025-09-17 13:35 ` Cezar Chiru
  2025-09-17 13:35   ` [PATCH v4 1/3] i2c: pcf8584: Fix debug macros defines of if statements Cezar Chiru
                     ` (2 more replies)
  1 sibling, 3 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-17 13:35 UTC (permalink / raw)
  To: andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Hello maintainers,

This patch series fixes 18 errors reported by checkpatch.pl on 
drivers/i2c/algos/i2c-algo-pcf.c file.

The series PATCH v1 to PATCH v4 is a response to the discussion on the mailing
list with Markus Elfring who had comments on my earlier submissions. 
He suggested:
 -to split my initial submission in a patch series
 -had some valid points on imperative mood usage in commit messages
 -wrapping commit message to 75 columns per line
 -change some of the commit message to point usage of checkpatch.pl

Here is a brief summary and order of patches to be applied:

Patch 1/3: i2c: pcf8584: Fix debug macros defines of if statements
This patch encloses the debug macro defines of if statements in do-while
loops.

Patch 2/3: i2c: pcf8584: Fix do not use assignment inside if conditional
This patch takes the assignement from if conditional and moves it by 1 line
up.

Patch 3/3: i2c: pcf8584: Fix space(s) required before or after different
           operators
This patch adds space(s) around, before or after some binary operators
and punctuation marks.

Testing:
   *built kernel and modules with I2C_ALGOPCF=m and my 3 patches applied on
   top of 6.17.0-rc6.
   *installed kernel and external modules generated by build on my laptop
   *rebooted and loaded i2c-algo-pcf.ko with param i2c_debug=2/3/9.
   *No success message related to i2c_algo_pcf was seen in dmesg but also no
   errors.
   *Module loading and unloading successful.
   *No PCF8584 Hardware was available.
 
Patches 1 and 3 report 4 and 6 warnings when running checkpatch on them.
They appeared because of two errors/warnings on the same line of code.
But the warnings will be fixed in a new patchset that addresses fixing 
warnings.
 


Cezar Chiru (3):
  i2c: pcf8584: Fix debug macros defines of if statements
  i2c: pcf8584: Fix do not use assignment inside if conditional
  i2c: pcf8584: Fix space(s) required before or after different
    operators

 drivers/i2c/algos/i2c-algo-pcf.c | 62 ++++++++++++++++++++------------
 1 file changed, 39 insertions(+), 23 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v4 1/3] i2c: pcf8584: Fix debug macros defines of if statements
  2025-09-17 13:35 ` [PATCH v4 0/3] i2c: pcf8584: Fix errors reported by checkpatch.pl Cezar Chiru
@ 2025-09-17 13:35   ` Cezar Chiru
  2025-09-25 10:35     ` Wolfram Sang
  2025-09-17 13:35   ` [PATCH v4 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional Cezar Chiru
  2025-09-17 13:35   ` [PATCH v4 3/3] i2c: pcf8584: Fix space(s) required before or after different operators Cezar Chiru
  2 siblings, 1 reply; 49+ messages in thread
From: Cezar Chiru @ 2025-09-17 13:35 UTC (permalink / raw)
  To: andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Enclose 'if' statements debug macros defines in do - while loops.
Fix inconsistent macro usage ending ';', which caused build errors in some
cases. 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 | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index fd563e845d4b..3fc4b5080a32 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -23,10 +23,19 @@
 #include "i2c-algo-pcf.h"
 
 
-#define DEB2(x) if (i2c_debug >= 2) x
-#define DEB3(x) if (i2c_debug >= 3) x /* print several statistical values */
-#define DEBPROTO(x) if (i2c_debug >= 9) x;
-	/* debug the protocol by showing transferred bits */
+#define DEB2(x) do { \
+			if (i2c_debug >= 2)	\
+				x;	\
+		} while (0)
+#define DEB3(x) do { \
+			if (i2c_debug >= 3)	\
+				x; /* print several statistical values */ \
+		} while (0)
+#define DEBPROTO(x)	do { \
+				if (i2c_debug >= 9)	\
+					x;	\
+				/* debug the protocol by showing transferred bits */	\
+			} while (0)
 #define DEF_TIMEOUT 16
 
 /*
@@ -308,7 +317,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 	timeout = wait_for_bb(adap);
 	if (timeout) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: "
-			    "Timeout waiting for BB in pcf_xfer\n");)
+			    "Timeout waiting for BB in pcf_xfer\n"));
 		i = -EIO;
 		goto out;
 	}
@@ -318,7 +327,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 		DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
 		     str_read_write(pmsg->flags & I2C_M_RD),
-		     pmsg->len, pmsg->addr, i + 1, num);)
+		     pmsg->len, pmsg->addr, i + 1, num));
 
 		ret = pcf_doAddress(adap, pmsg);
 
@@ -336,7 +345,7 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 			}
 			i2c_stop(adap);
 			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: Timeout waiting "
-				    "for PIN(1) in pcf_xfer\n");)
+				    "for PIN(1) in pcf_xfer\n"));
 			i = -EREMOTEIO;
 			goto out;
 		}
@@ -344,13 +353,13 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 		/* Check LRB (last rcvd bit - slave ack) */
 		if (status & I2C_PCF_LRB) {
 			i2c_stop(adap);
-			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");)
+			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n"));
 			i = -EREMOTEIO;
 			goto out;
 		}
 
 		DEB3(printk(KERN_DEBUG "i2c-algo-pcf.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n",
-			    i, msgs[i].addr, msgs[i].flags, msgs[i].len);)
+			    i, msgs[i].addr, msgs[i].flags, msgs[i].len));
 
 		if (pmsg->flags & I2C_M_RD) {
 			ret = pcf_readbytes(i2c_adap, pmsg->buf, pmsg->len,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH v4 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional
  2025-09-17 13:35 ` [PATCH v4 0/3] i2c: pcf8584: Fix errors reported by checkpatch.pl Cezar Chiru
  2025-09-17 13:35   ` [PATCH v4 1/3] i2c: pcf8584: Fix debug macros defines of if statements Cezar Chiru
@ 2025-09-17 13:35   ` Cezar Chiru
  2025-09-25 10:35     ` Wolfram Sang
  2025-09-17 13:35   ` [PATCH v4 3/3] i2c: pcf8584: Fix space(s) required before or after different operators Cezar Chiru
  2 siblings, 1 reply; 49+ messages in thread
From: Cezar Chiru @ 2025-09-17 13:35 UTC (permalink / raw)
  To: andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Assign inside of 'if' conditional is not allowed. Move assignment from
inside 'if' conditional, to one line before each 'if'conditional statement
that caused errors.
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 | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 3fc4b5080a32..598bf000bf4a 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -169,7 +169,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	 * check to see S1 now used as R/W ctrl -
 	 * PCF8584 does that when ESO is zero
 	 */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != (0)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp));
 		return -ENXIO; /* definitely not PCF8584 */
 	}
@@ -177,7 +178,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load own address in S0, effective address is (own << 1) */
 	i2c_outb(adap, get_own(adap));
 	/* check it's really written */
-	if ((temp = i2c_inb(adap)) != get_own(adap)) {
+	temp = i2c_inb(adap);
+	if (temp != get_own(adap)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -185,7 +187,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* S1=0xA0, next byte in S2 */
 	set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
 	/* check to see S2 now selected */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != I2C_PCF_ES1) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -193,7 +196,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load clock register S2 */
 	i2c_outb(adap, get_clock(adap));
 	/* check it's really written, the only 5 lowest bits does matter */
-	if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
+	temp = i2c_inb(adap);
+	if ((temp & 0x1f) != get_clock(adap)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -202,7 +206,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	set_pcf(adap, 1, I2C_PCF_IDLE);
 
 	/* check to see PCF is really idled and we can access status register */
-	if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
+	temp = get_pcf(adap, 1);
+	if (temp != (I2C_PCF_PIN | I2C_PCF_BB)) {
 		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp));
 		return -ENXIO;
 	}
@@ -255,7 +260,8 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
 	/* increment number of bytes to read by one -- read dummy byte */
 	for (i = 0; i <= count; i++) {
 
-		if ((wfp = wait_for_pin(adap, &status))) {
+		wfp = wait_for_pin(adap, &status);
+		if (wfp) {
 			if (wfp == -EINTR)
 				return -EINTR; /* arbitration lost */
 
@@ -415,7 +421,8 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
 	/* register new adapter to i2c module... */
 	adap->algo = &pcf_algo;
 
-	if ((rval = pcf_init_8584(pcf_adap)))
+	rval = pcf_init_8584(pcf_adap);
+	if (rval)
 		return rval;
 
 	rval = i2c_add_adapter(adap);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH v4 3/3] i2c: pcf8584: Fix space(s) required before or after different operators
  2025-09-17 13:35 ` [PATCH v4 0/3] i2c: pcf8584: Fix errors reported by checkpatch.pl Cezar Chiru
  2025-09-17 13:35   ` [PATCH v4 1/3] i2c: pcf8584: Fix debug macros defines of if statements Cezar Chiru
  2025-09-17 13:35   ` [PATCH v4 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional Cezar Chiru
@ 2025-09-17 13:35   ` Cezar Chiru
  2025-09-25 10:35     ` Wolfram Sang
  2 siblings, 1 reply; 49+ messages in thread
From: Cezar Chiru @ 2025-09-17 13:35 UTC (permalink / raw)
  To: andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Require spaces around or before or after '=', ';', '<' and ','.
Add space(s) around or before or after binary and ternary operators and
punctuation marks. 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 | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 598bf000bf4a..3439b7387a54 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -223,7 +223,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) {
 		DEB2(dev_dbg(&i2c_adap->dev, "i2c_write: writing %2.2X\n",
 				buf[wrcount] & 0xff));
 		i2c_outb(adap, buf[wrcount]);
@@ -314,7 +314,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);
@@ -328,7 +328,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];
 
 		DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
@@ -373,9 +373,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only read %d bytes.\n",ret));
+					    "only read %d bytes.\n", ret));
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n",ret));
+				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n", ret));
 			}
 		} else {
 			ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len,
@@ -383,9 +383,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only wrote %d bytes.\n",ret));
+					    "only wrote %d bytes.\n", ret));
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n",ret));
+				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n", ret));
 			}
 		}
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH v4 1/3] i2c: pcf8584: Fix debug macros defines of if statements
  2025-09-17 13:35   ` [PATCH v4 1/3] i2c: pcf8584: Fix debug macros defines of if statements Cezar Chiru
@ 2025-09-25 10:35     ` Wolfram Sang
  2025-09-25 11:56       ` Cezar Chiru
  2025-09-26 15:45       ` [PATCH v5 0/3] i2c: pcf8584: Fix errors reported by checkpatch Cezar Chiru
  0 siblings, 2 replies; 49+ messages in thread
From: Wolfram Sang @ 2025-09-25 10:35 UTC (permalink / raw)
  To: Cezar Chiru; +Cc: andi.shyti, linux-i2c, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1126 bytes --]

Hi,

On Wed, Sep 17, 2025 at 04:35:22PM +0300, Cezar Chiru wrote:
> Enclose 'if' statements debug macros defines in do - while loops.
> Fix inconsistent macro usage ending ';', which caused build errors in some
> cases. Enforce errors fixing based on checkpatch.pl output on file.

Thank you for the patch.

> Signed-off-by: Cezar Chiru <chiru.cezar.89@gmail.com>
> ---
>  drivers/i2c/algos/i2c-algo-pcf.c | 27 ++++++++++++++++++---------
>  1 file changed, 18 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
> index fd563e845d4b..3fc4b5080a32 100644
> --- a/drivers/i2c/algos/i2c-algo-pcf.c
> +++ b/drivers/i2c/algos/i2c-algo-pcf.c
> @@ -23,10 +23,19 @@
>  #include "i2c-algo-pcf.h"
>  
>  
> -#define DEB2(x) if (i2c_debug >= 2) x
> -#define DEB3(x) if (i2c_debug >= 3) x /* print several statistical values */
> -#define DEBPROTO(x) if (i2c_debug >= 9) x;

Given that nobody updated the code in the last 16 years, I think it is
safe to simply remove these debug macros. Are you open to do that?

Happy hacking,

   Wolfram

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v4 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional
  2025-09-17 13:35   ` [PATCH v4 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional Cezar Chiru
@ 2025-09-25 10:35     ` Wolfram Sang
  0 siblings, 0 replies; 49+ messages in thread
From: Wolfram Sang @ 2025-09-25 10:35 UTC (permalink / raw)
  To: Cezar Chiru; +Cc: andi.shyti, linux-i2c, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 69 bytes --]


> +	if ((temp & 0x7f) != (0)) {

Braces around '0' can go as well.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v4 3/3] i2c: pcf8584: Fix space(s) required before or after different operators
  2025-09-17 13:35   ` [PATCH v4 3/3] i2c: pcf8584: Fix space(s) required before or after different operators Cezar Chiru
@ 2025-09-25 10:35     ` Wolfram Sang
  0 siblings, 0 replies; 49+ messages in thread
From: Wolfram Sang @ 2025-09-25 10:35 UTC (permalink / raw)
  To: Cezar Chiru; +Cc: andi.shyti, linux-i2c, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 439 bytes --]

On Wed, Sep 17, 2025 at 04:35:24PM +0300, Cezar Chiru wrote:
> Require spaces around or before or after '=', ';', '<' and ','.
> Add space(s) around or before or after binary and ternary operators and
> punctuation marks. Enforce errors fixing based on checkpatch.pl output on
> file.
> 
> Signed-off-by: Cezar Chiru <chiru.cezar.89@gmail.com>

This patch is basically OK, but will become smaller if you remove the
DEB2 macro.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v4 1/3] i2c: pcf8584: Fix debug macros defines of if statements
  2025-09-25 10:35     ` Wolfram Sang
@ 2025-09-25 11:56       ` Cezar Chiru
  2025-09-26 15:45       ` [PATCH v5 0/3] i2c: pcf8584: Fix errors reported by checkpatch Cezar Chiru
  1 sibling, 0 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-25 11:56 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: andi.shyti, linux-i2c, linux-kernel

Hi Wolfram,

> > -#define DEB2(x) if (i2c_debug >= 2) x
> > -#define DEB3(x) if (i2c_debug >= 3) x /* print several statistical values */
> > -#define DEBPROTO(x) if (i2c_debug >= 9) x;
>
> Given that nobody updated the code in the last 16 years, I think it is
> safe to simply remove these debug macros. Are you open to do that?

I can do the removal of debug macros. Also for the other changes you
requested I will submit new patches with changes requested soon.
Expect my work by start of next week.

/Cezar Chiru

^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v5 0/3] i2c: pcf8584: Fix errors reported by checkpatch
  2025-09-25 10:35     ` Wolfram Sang
  2025-09-25 11:56       ` Cezar Chiru
@ 2025-09-26 15:45       ` Cezar Chiru
  2025-09-26 15:45         ` [PATCH v5 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c Cezar Chiru
                           ` (3 more replies)
  1 sibling, 4 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-26 15:45 UTC (permalink / raw)
  To: wsa+renesas, andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Hello maintainers,

This patch series fixes 18 errors reported by checkpatch.pl on 
drivers/i2c/algos/i2c-algo-pcf.c file.

The series PATCH v1 to PATCH v4 is a response to the discussion on the
mailing list with Markus Elfring who had comments on my earlier 
submissions. 
He suggested:
 -to split my initial submission in a patch series
 -had some valid points on imperative mood usage in commit messages
 -wrapping commit message to 75 columns per line
 -change some of the commit message to point usage of checkpatch.pl
The series PATCH v4 to PATCH v5 is a response to the discussion on the
mailing list with I2C SUBSYSTEM maintainer Wolfram Sang who requested
some changes:
He requested:
 - to remove debug macros from i2c-algo-pcf.c as no code change was done
 for almost 16 years.
 - remove wrapping paranthesis from value assigned of '(0)''.
 - resolve conficts caused by debug macros removal.

Here is a brief summary and order of patches to be applied:

Patch 1/3: i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
This patch remove the define of debug macros and also their usage from
code.

Patch 2/3: i2c: pcf8584: Fix do not use assignment inside if conditional
This patch takes the assignement from if conditional and moves it by 1 line
up.

Patch 3/3: i2c: pcf8584: Fix space(s) required before or after different
           operators
This patch adds space(s) around, before or after some binary operators
and punctuation signs.

Testing:
   *built kernel and modules with I2C_ALGOPCF=m and my 3 patches applied on
   top of 6.17.0-rc7.
   *installed kernel and external modules generated by build on my laptop
   *rebooted and loaded i2c-algo-pcf.ko without i2c_debug parameter.
   *when loading the .ko with i2c_debug parameter an error is seen in dmesg 
   and this is expected as the parameter was removed.
   *No success message related to i2c_algo_pcf was seen in dmesg but also no
   failures.
   *Module loading and unloading successful.
   *No PCF8584 Hardware was available.

Patch 1 shows multiple errors and warnings reported by checkpatch but they 
are solved by apllying patches 2 and 3 on top. Other errors and warnings
shown by checkpatch on file will be fixed after this patchset will be 
accepted and merged in other commit.

Cezar Chiru (3):
  i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
  i2c: pcf8584: Fix do not use assignment inside if conditional
  i2c: pcf8584: Fix space(s) required before or after different
    operators

 drivers/i2c/algos/i2c-algo-pcf.c | 105 ++++++++++++++-----------------
 1 file changed, 48 insertions(+), 57 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v5 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
  2025-09-26 15:45       ` [PATCH v5 0/3] i2c: pcf8584: Fix errors reported by checkpatch Cezar Chiru
@ 2025-09-26 15:45         ` Cezar Chiru
  2025-09-26 18:07           ` Wolfram Sang
  2025-09-26 15:45         ` [PATCH v5 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional Cezar Chiru
                           ` (2 subsequent siblings)
  3 siblings, 1 reply; 49+ messages in thread
From: Cezar Chiru @ 2025-09-26 15:45 UTC (permalink / raw)
  To: wsa+renesas, andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Remove debug macros from file as no change was done for 16 years.
Request by I2C SUBSYSTEM maintainer Wolfram Sang.
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 | 78 +++++++++++++-------------------
 1 file changed, 31 insertions(+), 47 deletions(-)

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index fd563e845d4b..d4d82f3729d3 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -23,17 +23,8 @@
 #include "i2c-algo-pcf.h"
 
 
-#define DEB2(x) if (i2c_debug >= 2) x
-#define DEB3(x) if (i2c_debug >= 3) x /* print several statistical values */
-#define DEBPROTO(x) if (i2c_debug >= 9) x;
-	/* debug the protocol by showing transferred bits */
 #define DEF_TIMEOUT 16
 
-/*
- * module parameters:
- */
-static int i2c_debug;
-
 /* setting states on the bus with the right timing: */
 
 #define set_pcf(adap, ctl, val) adap->setpcf(adap->data, ctl, val)
@@ -47,27 +38,26 @@ static int i2c_debug;
 
 static void i2c_start(struct i2c_algo_pcf_data *adap)
 {
-	DEBPROTO(printk(KERN_DEBUG "S "));
+	printk(KERN_DEBUG "S ");
 	set_pcf(adap, 1, I2C_PCF_START);
 }
 
 static void i2c_repstart(struct i2c_algo_pcf_data *adap)
 {
-	DEBPROTO(printk(" Sr "));
+	printk(" Sr ");
 	set_pcf(adap, 1, I2C_PCF_REPSTART);
 }
 
 static void i2c_stop(struct i2c_algo_pcf_data *adap)
 {
-	DEBPROTO(printk("P\n"));
+	printk("P\n");
 	set_pcf(adap, 1, I2C_PCF_STOP);
 }
 
 static void handle_lab(struct i2c_algo_pcf_data *adap, const int *status)
 {
-	DEB2(printk(KERN_INFO
-		"i2c-algo-pcf.o: lost arbitration (CSR 0x%02x)\n",
-		*status));
+	printk(KERN_INFO "i2c-algo-pcf.o: lost arbitration (CSR 0x%02x)\n",
+		*status);
 	/*
 	 * Cleanup from LAB -- reset and enable ESO.
 	 * This resets the PCF8584; since we've lost the bus, no
@@ -88,9 +78,8 @@ static void handle_lab(struct i2c_algo_pcf_data *adap, const int *status)
 	if (adap->lab_mdelay)
 		mdelay(adap->lab_mdelay);
 
-	DEB2(printk(KERN_INFO
-		"i2c-algo-pcf.o: reset LAB condition (CSR 0x%02x)\n",
-		get_pcf(adap, 1)));
+	printk(KERN_INFO "i2c-algo-pcf.o: reset LAB condition (CSR 0x%02x)\n",
+		get_pcf(adap, 1));
 }
 
 static int wait_for_bb(struct i2c_algo_pcf_data *adap)
@@ -151,8 +140,7 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 {
 	unsigned char temp;
 
-	DEB3(printk(KERN_DEBUG "i2c-algo-pcf.o: PCF state 0x%02x\n",
-				get_pcf(adap, 1)));
+	printk(KERN_DEBUG "i2c-algo-pcf.o: PCF state 0x%02x\n", get_pcf(adap, 1));
 
 	/* S1=0x80: S0 selected, serial interface off */
 	set_pcf(adap, 1, I2C_PCF_PIN);
@@ -161,7 +149,7 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	 * PCF8584 does that when ESO is zero
 	 */
 	if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp));
+		printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp);
 		return -ENXIO; /* definitely not PCF8584 */
 	}
 
@@ -169,7 +157,7 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	i2c_outb(adap, get_own(adap));
 	/* check it's really written */
 	if ((temp = i2c_inb(adap)) != get_own(adap)) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp));
+		printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp);
 		return -ENXIO;
 	}
 
@@ -177,7 +165,7 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
 	/* check to see S2 now selected */
 	if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S2 (0x%02x).\n", temp));
+		printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S2 (0x%02x).\n", temp);
 		return -ENXIO;
 	}
 
@@ -185,7 +173,7 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	i2c_outb(adap, get_clock(adap));
 	/* check it's really written, the only 5 lowest bits does matter */
 	if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp));
+		printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp);
 		return -ENXIO;
 	}
 
@@ -194,7 +182,7 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 
 	/* check to see PCF is really idled and we can access status register */
 	if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp));
+		printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp);
 		return -ENXIO;
 	}
 
@@ -210,8 +198,8 @@ static int pcf_sendbytes(struct i2c_adapter *i2c_adap, const char *buf,
 	int wrcount, status, timeout;
 
 	for (wrcount=0; wrcount<count; ++wrcount) {
-		DEB2(dev_dbg(&i2c_adap->dev, "i2c_write: writing %2.2X\n",
-				buf[wrcount] & 0xff));
+		dev_dbg(&i2c_adap->dev, "i2c_write: writing %2.2X\n",
+				buf[wrcount] & 0xff);
 		i2c_outb(adap, buf[wrcount]);
 		timeout = wait_for_pin(adap, &status);
 		if (timeout) {
@@ -307,8 +295,8 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 	/* Check for bus busy */
 	timeout = wait_for_bb(adap);
 	if (timeout) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: "
-			    "Timeout waiting for BB in pcf_xfer\n");)
+		printk(KERN_ERR "i2c-algo-pcf.o: "
+			    "Timeout waiting for BB in pcf_xfer\n");
 		i = -EIO;
 		goto out;
 	}
@@ -316,9 +304,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 	for (i = 0;ret >= 0 && i < num; i++) {
 		pmsg = &msgs[i];
 
-		DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
+		printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
 		     str_read_write(pmsg->flags & I2C_M_RD),
-		     pmsg->len, pmsg->addr, i + 1, num);)
+		     pmsg->len, pmsg->addr, i + 1, num);
 
 		ret = pcf_doAddress(adap, pmsg);
 
@@ -335,8 +323,8 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 				goto out;
 			}
 			i2c_stop(adap);
-			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: Timeout waiting "
-				    "for PIN(1) in pcf_xfer\n");)
+			printk(KERN_ERR "i2c-algo-pcf.o: Timeout waiting "
+				    "for PIN(1) in pcf_xfer\n");
 			i = -EREMOTEIO;
 			goto out;
 		}
@@ -344,33 +332,33 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 		/* Check LRB (last rcvd bit - slave ack) */
 		if (status & I2C_PCF_LRB) {
 			i2c_stop(adap);
-			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");)
+			printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");
 			i = -EREMOTEIO;
 			goto out;
 		}
 
-		DEB3(printk(KERN_DEBUG "i2c-algo-pcf.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n",
-			    i, msgs[i].addr, msgs[i].flags, msgs[i].len);)
+		printk(KERN_DEBUG "i2c-algo-pcf.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n",
+			    i, msgs[i].addr, msgs[i].flags, msgs[i].len);
 
 		if (pmsg->flags & I2C_M_RD) {
 			ret = pcf_readbytes(i2c_adap, pmsg->buf, pmsg->len,
 					    (i + 1 == num));
 
 			if (ret != pmsg->len) {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only read %d bytes.\n",ret));
+				printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
+					    "only read %d bytes.\n",ret);
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n",ret));
+				printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n",ret);
 			}
 		} else {
 			ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len,
 					    (i + 1 == num));
 
 			if (ret != pmsg->len) {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only wrote %d bytes.\n",ret));
+				printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
+					    "only wrote %d bytes.\n",ret);
 			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n",ret));
+				printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n",ret);
 			}
 		}
 	}
@@ -401,7 +389,7 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
 	struct i2c_algo_pcf_data *pcf_adap = adap->algo_data;
 	int rval;
 
-	DEB2(dev_dbg(&adap->dev, "hw routines registered.\n"));
+	dev_dbg(&adap->dev, "hw routines registered.\n");
 
 	/* register new adapter to i2c module... */
 	adap->algo = &pcf_algo;
@@ -418,7 +406,3 @@ EXPORT_SYMBOL(i2c_pcf_add_bus);
 MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
 MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm");
 MODULE_LICENSE("GPL");
-
-module_param(i2c_debug, int, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(i2c_debug,
-	"debug level - 0 off; 1 normal; 2,3 more verbose; 9 pcf-protocol");
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH v5 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional
  2025-09-26 15:45       ` [PATCH v5 0/3] i2c: pcf8584: Fix errors reported by checkpatch Cezar Chiru
  2025-09-26 15:45         ` [PATCH v5 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c Cezar Chiru
@ 2025-09-26 15:45         ` Cezar Chiru
  2025-09-26 15:45         ` [PATCH v5 3/3] i2c: pcf8584: Fix space(s) required before or after different operators Cezar Chiru
  2025-10-16 16:14         ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Cezar Chiru
  3 siblings, 0 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-26 15:45 UTC (permalink / raw)
  To: wsa+renesas, andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Assign inside of 'if' conditional is not allowed. Move assignment from
inside 'if' conditional, to one line before each 'if'conditional statement
that caused errors.
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 | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index d4d82f3729d3..c856f4c8e3de 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -148,7 +148,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	 * check to see S1 now used as R/W ctrl -
 	 * PCF8584 does that when ESO is zero
 	 */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != 0) {
 		printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp);
 		return -ENXIO; /* definitely not PCF8584 */
 	}
@@ -156,7 +157,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load own address in S0, effective address is (own << 1) */
 	i2c_outb(adap, get_own(adap));
 	/* check it's really written */
-	if ((temp = i2c_inb(adap)) != get_own(adap)) {
+	temp = i2c_inb(adap);
+	if (temp != get_own(adap)) {
 		printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp);
 		return -ENXIO;
 	}
@@ -164,7 +166,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* S1=0xA0, next byte in S2 */
 	set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
 	/* check to see S2 now selected */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != I2C_PCF_ES1) {
 		printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S2 (0x%02x).\n", temp);
 		return -ENXIO;
 	}
@@ -172,7 +175,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	/* load clock register S2 */
 	i2c_outb(adap, get_clock(adap));
 	/* check it's really written, the only 5 lowest bits does matter */
-	if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
+	temp = i2c_inb(adap);
+	if ((temp & 0x1f) != get_clock(adap)) {
 		printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp);
 		return -ENXIO;
 	}
@@ -181,7 +185,8 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	set_pcf(adap, 1, I2C_PCF_IDLE);
 
 	/* check to see PCF is really idled and we can access status register */
-	if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
+	temp = get_pcf(adap, 1);
+	if (temp != (I2C_PCF_PIN | I2C_PCF_BB)) {
 		printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp);
 		return -ENXIO;
 	}
@@ -234,7 +239,8 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
 	/* increment number of bytes to read by one -- read dummy byte */
 	for (i = 0; i <= count; i++) {
 
-		if ((wfp = wait_for_pin(adap, &status))) {
+		wfp = wait_for_pin(adap, &status);
+		if (wfp) {
 			if (wfp == -EINTR)
 				return -EINTR; /* arbitration lost */
 
@@ -394,7 +400,8 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
 	/* register new adapter to i2c module... */
 	adap->algo = &pcf_algo;
 
-	if ((rval = pcf_init_8584(pcf_adap)))
+	rval = pcf_init_8584(pcf_adap);
+	if (rval)
 		return rval;
 
 	rval = i2c_add_adapter(adap);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH v5 3/3] i2c: pcf8584: Fix space(s) required before or after different operators
  2025-09-26 15:45       ` [PATCH v5 0/3] i2c: pcf8584: Fix errors reported by checkpatch Cezar Chiru
  2025-09-26 15:45         ` [PATCH v5 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c Cezar Chiru
  2025-09-26 15:45         ` [PATCH v5 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional Cezar Chiru
@ 2025-09-26 15:45         ` Cezar Chiru
  2025-10-16 16:14         ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Cezar Chiru
  3 siblings, 0 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-26 15:45 UTC (permalink / raw)
  To: wsa+renesas, andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Require spaces around or before or after '=', ';', '<' and ','.
Add space(s) around or before or after binary and ternary operators and
punctuation signs. 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 | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index c856f4c8e3de..8f7421794a7f 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -202,7 +202,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) {
 		dev_dbg(&i2c_adap->dev, "i2c_write: writing %2.2X\n",
 				buf[wrcount] & 0xff);
 		i2c_outb(adap, buf[wrcount]);
@@ -293,7 +293,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);
@@ -307,7 +307,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];
 
 		printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
@@ -352,9 +352,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only read %d bytes.\n",ret);
+					    "only read %d bytes.\n", ret);
 			} else {
-				printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n",ret);
+				printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n", ret);
 			}
 		} else {
 			ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len,
@@ -362,9 +362,9 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 
 			if (ret != pmsg->len) {
 				printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only wrote %d bytes.\n",ret);
+					    "only wrote %d bytes.\n", ret);
 			} else {
-				printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n",ret);
+				printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n", ret);
 			}
 		}
 	}
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH v5 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
  2025-09-26 15:45         ` [PATCH v5 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c Cezar Chiru
@ 2025-09-26 18:07           ` Wolfram Sang
  2025-09-26 19:05             ` Cezar Chiru
  2025-09-27  4:13             ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Cezar Chiru
  0 siblings, 2 replies; 49+ messages in thread
From: Wolfram Sang @ 2025-09-26 18:07 UTC (permalink / raw)
  To: Cezar Chiru; +Cc: andi.shyti, linux-i2c, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 142 bytes --]


> -	DEBPROTO(printk(KERN_DEBUG "S "));
> +	printk(KERN_DEBUG "S ");

Now you print the former debug printouts unconditionally? Why is that?


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v5 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
  2025-09-26 18:07           ` Wolfram Sang
@ 2025-09-26 19:05             ` Cezar Chiru
  2025-09-27  4:13             ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Cezar Chiru
  1 sibling, 0 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-26 19:05 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: andi.shyti, linux-i2c, linux-kernel

Hi,

I'm a newbie to kernel hacking. this is my first set of changes i'm
working on that I wish to go into
the kernel.

> > -     DEBPROTO(printk(KERN_DEBUG "S "));
> > +     printk(KERN_DEBUG "S ");
>
> Now you print the former debug printouts unconditionally? Why is that?
>

I thought I should get rid of DEB2 DEB3 and DEBPROTO macros. That was my
original understanding.
Should everything with printk be deleted also?

/Cezar Chiru

^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch
  2025-09-26 18:07           ` Wolfram Sang
  2025-09-26 19:05             ` Cezar Chiru
@ 2025-09-27  4:13             ` Cezar Chiru
  2025-09-27  4:13               ` [PATCH v6 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c Cezar Chiru
                                 ` (3 more replies)
  1 sibling, 4 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-27  4:13 UTC (permalink / raw)
  To: wsa+renesas, andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Hello maintainers,

This patch series fixes 18 errors and multiple warnings reported by 
checkpatch.pl on drivers/i2c/algos/i2c-algo-pcf.c file.

The series PATCH v1 to PATCH v4 is a response to the discussion on the
mailing list with Markus Elfring who had comments on my earlier 
submissions. 
He suggested:
 -to split my initial submission in a patch series
 -had some valid points on imperative mood usage in commit messages
 -wrapping commit message to 75 columns per line
 -change some of the commit message to point usage of checkpatch.pl
The series PATCH v4 to PATCH v6 is a response to the discussion on the
mailing list with I2C SUBSYSTEM maintainer Wolfram Sang who requested
some changes:
He requested:
 - to remove debug macros from i2c-algo-pcf.c as no code change was done
 for almost 16 years.
 - remove wrapping paranthesis from value assigned of '(0)''.
 - resolve conficts caused by debug macros removal.
 - remove also printk and dev_dbg function calls related to DEB macros.

Here is a brief summary and order of patches to be applied:
Patch 1/3: i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
This patch remove the define of debug macros and also their usage from
code along with printk and dev_dbg function calls.

Patch 2/3: i2c: pcf8584: Fix do not use assignment inside if conditional
This patch takes the assignement from if conditional and moves it by 1 line
up.

Patch 3/3: i2c: pcf8584: Fix space(s) required before or after different
           operators
This patch adds space(s) around some binary operators.

Testing:
   *built kernel and modules with I2C_ALGOPCF=m and my 3 patches applied on
   top of 6.17.0-rc7.
   *installed kernel and external modules generated by build on my laptop
   *rebooted and loaded i2c-algo-pcf.ko without i2c_debug parameter.
   *when loading the .ko with i2c_debug parameter an error is seen in dmesg
   and this is expected as the parameter was removed.
   *No success message related to i2c_algo_pcf was seen in dmesg but also 
   no failures.
   *Module loading and unloading successful.
   *No PCF8584 Hardware was available.

Cezar Chiru (3):
  i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
  i2c: pcf8584: Fix do not use assignment inside if conditional
  i2c: pcf8584: Fix space(s) required before or after different
    operators

 drivers/i2c/algos/i2c-algo-pcf.c | 93 +++++++-------------------------
 1 file changed, 18 insertions(+), 75 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v6 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
  2025-09-27  4:13             ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Cezar Chiru
@ 2025-09-27  4:13               ` Cezar Chiru
  2025-10-17 20:47                 ` Andi Shyti
  2025-09-27  4:13               ` [PATCH v6 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional Cezar Chiru
                                 ` (2 subsequent siblings)
  3 siblings, 1 reply; 49+ messages in thread
From: Cezar Chiru @ 2025-09-27  4:13 UTC (permalink / raw)
  To: wsa+renesas, andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Remove debug macros and printk and dev_debg function calls from file
as no change was done for 16 years.
Request by I2C SUBSYSTEM maintainer Wolfram Sang.

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

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index fd563e845d4b..7e2d8ff33d75 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -23,17 +23,8 @@
 #include "i2c-algo-pcf.h"
 
 
-#define DEB2(x) if (i2c_debug >= 2) x
-#define DEB3(x) if (i2c_debug >= 3) x /* print several statistical values */
-#define DEBPROTO(x) if (i2c_debug >= 9) x;
-	/* debug the protocol by showing transferred bits */
 #define DEF_TIMEOUT 16
 
-/*
- * module parameters:
- */
-static int i2c_debug;
-
 /* setting states on the bus with the right timing: */
 
 #define set_pcf(adap, ctl, val) adap->setpcf(adap->data, ctl, val)
@@ -47,27 +38,21 @@ static int i2c_debug;
 
 static void i2c_start(struct i2c_algo_pcf_data *adap)
 {
-	DEBPROTO(printk(KERN_DEBUG "S "));
 	set_pcf(adap, 1, I2C_PCF_START);
 }
 
 static void i2c_repstart(struct i2c_algo_pcf_data *adap)
 {
-	DEBPROTO(printk(" Sr "));
 	set_pcf(adap, 1, I2C_PCF_REPSTART);
 }
 
 static void i2c_stop(struct i2c_algo_pcf_data *adap)
 {
-	DEBPROTO(printk("P\n"));
 	set_pcf(adap, 1, I2C_PCF_STOP);
 }
 
 static void handle_lab(struct i2c_algo_pcf_data *adap, const int *status)
 {
-	DEB2(printk(KERN_INFO
-		"i2c-algo-pcf.o: lost arbitration (CSR 0x%02x)\n",
-		*status));
 	/*
 	 * Cleanup from LAB -- reset and enable ESO.
 	 * This resets the PCF8584; since we've lost the bus, no
@@ -88,9 +73,6 @@ static void handle_lab(struct i2c_algo_pcf_data *adap, const int *status)
 	if (adap->lab_mdelay)
 		mdelay(adap->lab_mdelay);
 
-	DEB2(printk(KERN_INFO
-		"i2c-algo-pcf.o: reset LAB condition (CSR 0x%02x)\n",
-		get_pcf(adap, 1)));
 }
 
 static int wait_for_bb(struct i2c_algo_pcf_data *adap)
@@ -151,9 +133,6 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 {
 	unsigned char temp;
 
-	DEB3(printk(KERN_DEBUG "i2c-algo-pcf.o: PCF state 0x%02x\n",
-				get_pcf(adap, 1)));
-
 	/* S1=0x80: S0 selected, serial interface off */
 	set_pcf(adap, 1, I2C_PCF_PIN);
 	/*
@@ -161,7 +140,6 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	 * PCF8584 does that when ESO is zero
 	 */
 	if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp));
 		return -ENXIO; /* definitely not PCF8584 */
 	}
 
@@ -169,7 +147,6 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	i2c_outb(adap, get_own(adap));
 	/* check it's really written */
 	if ((temp = i2c_inb(adap)) != get_own(adap)) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
 
@@ -177,7 +154,6 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
 	/* check to see S2 now selected */
 	if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
 
@@ -185,7 +161,6 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	i2c_outb(adap, get_clock(adap));
 	/* check it's really written, the only 5 lowest bits does matter */
 	if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
 
@@ -194,7 +169,6 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 
 	/* check to see PCF is really idled and we can access status register */
 	if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp));
 		return -ENXIO;
 	}
 
@@ -210,8 +184,6 @@ static int pcf_sendbytes(struct i2c_adapter *i2c_adap, const char *buf,
 	int wrcount, status, timeout;
 
 	for (wrcount=0; wrcount<count; ++wrcount) {
-		DEB2(dev_dbg(&i2c_adap->dev, "i2c_write: writing %2.2X\n",
-				buf[wrcount] & 0xff));
 		i2c_outb(adap, buf[wrcount]);
 		timeout = wait_for_pin(adap, &status);
 		if (timeout) {
@@ -307,8 +279,6 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 	/* Check for bus busy */
 	timeout = wait_for_bb(adap);
 	if (timeout) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: "
-			    "Timeout waiting for BB in pcf_xfer\n");)
 		i = -EIO;
 		goto out;
 	}
@@ -316,10 +286,6 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 	for (i = 0;ret >= 0 && i < num; i++) {
 		pmsg = &msgs[i];
 
-		DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
-		     str_read_write(pmsg->flags & I2C_M_RD),
-		     pmsg->len, pmsg->addr, i + 1, num);)
-
 		ret = pcf_doAddress(adap, pmsg);
 
 		/* Send START */
@@ -335,8 +301,6 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 				goto out;
 			}
 			i2c_stop(adap);
-			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: Timeout waiting "
-				    "for PIN(1) in pcf_xfer\n");)
 			i = -EREMOTEIO;
 			goto out;
 		}
@@ -344,34 +308,17 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 		/* Check LRB (last rcvd bit - slave ack) */
 		if (status & I2C_PCF_LRB) {
 			i2c_stop(adap);
-			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");)
 			i = -EREMOTEIO;
 			goto out;
 		}
 
-		DEB3(printk(KERN_DEBUG "i2c-algo-pcf.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n",
-			    i, msgs[i].addr, msgs[i].flags, msgs[i].len);)
 
 		if (pmsg->flags & I2C_M_RD) {
 			ret = pcf_readbytes(i2c_adap, pmsg->buf, pmsg->len,
 					    (i + 1 == num));
-
-			if (ret != pmsg->len) {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only read %d bytes.\n",ret));
-			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n",ret));
-			}
 		} else {
 			ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len,
 					    (i + 1 == num));
-
-			if (ret != pmsg->len) {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only wrote %d bytes.\n",ret));
-			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n",ret));
-			}
 		}
 	}
 
@@ -401,8 +348,6 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
 	struct i2c_algo_pcf_data *pcf_adap = adap->algo_data;
 	int rval;
 
-	DEB2(dev_dbg(&adap->dev, "hw routines registered.\n"));
-
 	/* register new adapter to i2c module... */
 	adap->algo = &pcf_algo;
 
@@ -418,7 +363,3 @@ EXPORT_SYMBOL(i2c_pcf_add_bus);
 MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
 MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm");
 MODULE_LICENSE("GPL");
-
-module_param(i2c_debug, int, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(i2c_debug,
-	"debug level - 0 off; 1 normal; 2,3 more verbose; 9 pcf-protocol");
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH v6 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional
  2025-09-27  4:13             ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Cezar Chiru
  2025-09-27  4:13               ` [PATCH v6 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c Cezar Chiru
@ 2025-09-27  4:13               ` Cezar Chiru
  2025-09-27  4:14               ` [PATCH v6 3/3] i2c: pcf8584: Fix space(s) required before or after different operators Cezar Chiru
  2025-10-17 20:39               ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Andi Shyti
  3 siblings, 0 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-09-27  4:13 UTC (permalink / raw)
  To: wsa+renesas, andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Assign inside of 'if' conditional is not allowed. Move assignment from
inside 'if' conditional, to one line before each 'if'conditional statement
that caused errors.
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 | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 7e2d8ff33d75..41a81d37e880 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -129,7 +129,7 @@ static int wait_for_pin(struct i2c_algo_pcf_data *adap, int *status)
  *
  * vdovikin: added detect code for PCF8584
  */
-static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
+static int pcf_init_8584(struct i2c_algo_pcf_data *adap)
 {
 	unsigned char temp;
 
@@ -139,38 +139,38 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	 * check to see S1 now used as R/W ctrl -
 	 * PCF8584 does that when ESO is zero
 	 */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != 0)
 		return -ENXIO; /* definitely not PCF8584 */
-	}
 
 	/* load own address in S0, effective address is (own << 1) */
 	i2c_outb(adap, get_own(adap));
 	/* check it's really written */
-	if ((temp = i2c_inb(adap)) != get_own(adap)) {
+	temp = i2c_inb(adap);
+	if (temp != get_own(adap))
 		return -ENXIO;
-	}
 
 	/* S1=0xA0, next byte in S2 */
 	set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
 	/* check to see S2 now selected */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != I2C_PCF_ES1)
 		return -ENXIO;
-	}
 
 	/* load clock register S2 */
 	i2c_outb(adap, get_clock(adap));
 	/* check it's really written, the only 5 lowest bits does matter */
-	if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
+	temp = i2c_inb(adap);
+	if ((temp & 0x1f) != get_clock(adap))
 		return -ENXIO;
-	}
 
 	/* Enable serial interface, idle, S0 selected */
 	set_pcf(adap, 1, I2C_PCF_IDLE);
 
 	/* check to see PCF is really idled and we can access status register */
-	if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
+	temp = get_pcf(adap, 1);
+	if (temp != (I2C_PCF_PIN | I2C_PCF_BB))
 		return -ENXIO;
-	}
 
 	printk(KERN_DEBUG "i2c-algo-pcf.o: detected and initialized PCF8584.\n");
 
@@ -218,7 +218,8 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
 	/* increment number of bytes to read by one -- read dummy byte */
 	for (i = 0; i <= count; i++) {
 
-		if ((wfp = wait_for_pin(adap, &status))) {
+		wfp = wait_for_pin(adap, &status);
+		if (wfp) {
 			if (wfp == -EINTR)
 				return -EINTR; /* arbitration lost */
 
@@ -351,7 +352,8 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
 	/* register new adapter to i2c module... */
 	adap->algo = &pcf_algo;
 
-	if ((rval = pcf_init_8584(pcf_adap)))
+	rval = pcf_init_8584(pcf_adap);
+	if (rval)
 		return rval;
 
 	rval = i2c_add_adapter(adap);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH v6 3/3] i2c: pcf8584: Fix space(s) required before or after different operators
  2025-09-27  4:13             ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Cezar Chiru
  2025-09-27  4:13               ` [PATCH v6 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c Cezar Chiru
  2025-09-27  4:13               ` [PATCH v6 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional Cezar Chiru
@ 2025-09-27  4:14               ` Cezar Chiru
  2025-10-17 20:58                 ` Andi Shyti
  2025-10-17 20:39               ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Andi Shyti
  3 siblings, 1 reply; 49+ messages in thread
From: Cezar Chiru @ 2025-09-27  4:14 UTC (permalink / raw)
  To: wsa+renesas, andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

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


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch
  2025-09-26 15:45       ` [PATCH v5 0/3] i2c: pcf8584: Fix errors reported by checkpatch Cezar Chiru
                           ` (2 preceding siblings ...)
  2025-09-26 15:45         ` [PATCH v5 3/3] i2c: pcf8584: Fix space(s) required before or after different operators Cezar Chiru
@ 2025-10-16 16:14         ` Cezar Chiru
  2025-10-16 16:14           ` [PATCH v6 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c Cezar Chiru
                             ` (2 more replies)
  3 siblings, 3 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-10-16 16:14 UTC (permalink / raw)
  To: wsa+renesas, andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Hello maintainers,

This patch series fixes 18 errors and multiple warnings reported by 
checkpatch.pl on drivers/i2c/algos/i2c-algo-pcf.c file.

The series PATCH v1 to PATCH v4 is a response to the discussion on the
mailing list with Markus Elfring who had comments on my earlier 
submissions. 
He suggested:
 -to split my initial submission in a patch series
 -had some valid points on imperative mood usage in commit messages
 -wrapping commit message to 75 columns per line
 -change some of the commit message to point usage of checkpatch.pl
The series PATCH v4 to PATCH v6 is a response to the discussion on the
mailing list with I2C SUBSYSTEM maintainer Wolfram Sang who requested
some changes:
He requested:
 - to remove debug macros from i2c-algo-pcf.c as no code change was done
 for almost 16 years.
 - remove wrapping paranthesis from value assigned of '(0)''.
 - resolve conficts caused by debug macros removal.
 - remove also printk and dev_dbg function calls related to DEB macros.

Here is a brief summary and order of patches to be applied:
Patch 1/3: i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
This patch remove the define of debug macros and also their usage from
code along with printk and dev_dbg function calls.

Patch 2/3: i2c: pcf8584: Fix do not use assignment inside if conditional
This patch takes the assignement from if conditional and moves it by 1 line
up.

Patch 3/3: i2c: pcf8584: Fix space(s) required before or after different
           operators
This patch adds space(s) around some binary operators.

Testing:
   *built kernel and modules with I2C_ALGOPCF=m and my 3 patches applied on
   top of 6.17.0-rc7.
   *installed kernel and external modules generated by build on my laptop
   *rebooted and loaded i2c-algo-pcf.ko without i2c_debug parameter.
   *when loading the .ko with i2c_debug parameter an error is seen in dmesg
   and this is expected as the parameter was removed.
   *No success message related to i2c_algo_pcf was seen in dmesg but also 
   no failures.
   *Module loading and unloading successful.
   *No PCF8584 Hardware was available.

Cezar Chiru (3):
  i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
  i2c: pcf8584: Fix do not use assignment inside if conditional
  i2c: pcf8584: Fix space(s) required before or after different
    operators

 drivers/i2c/algos/i2c-algo-pcf.c | 93 +++++++-------------------------
 1 file changed, 18 insertions(+), 75 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 49+ messages in thread

* [PATCH v6 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
  2025-10-16 16:14         ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Cezar Chiru
@ 2025-10-16 16:14           ` Cezar Chiru
  2025-10-16 16:14           ` [PATCH v6 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional Cezar Chiru
  2025-10-16 16:14           ` [PATCH v6 3/3] i2c: pcf8584: Fix space(s) required before or after different operators Cezar Chiru
  2 siblings, 0 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-10-16 16:14 UTC (permalink / raw)
  To: wsa+renesas, andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Remove debug macros and printk and dev_debg function calls from file
as no change was done for 16 years.
Request by I2C SUBSYSTEM maintainer Wolfram Sang.

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

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index fd563e845d4b..7e2d8ff33d75 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -23,17 +23,8 @@
 #include "i2c-algo-pcf.h"
 
 
-#define DEB2(x) if (i2c_debug >= 2) x
-#define DEB3(x) if (i2c_debug >= 3) x /* print several statistical values */
-#define DEBPROTO(x) if (i2c_debug >= 9) x;
-	/* debug the protocol by showing transferred bits */
 #define DEF_TIMEOUT 16
 
-/*
- * module parameters:
- */
-static int i2c_debug;
-
 /* setting states on the bus with the right timing: */
 
 #define set_pcf(adap, ctl, val) adap->setpcf(adap->data, ctl, val)
@@ -47,27 +38,21 @@ static int i2c_debug;
 
 static void i2c_start(struct i2c_algo_pcf_data *adap)
 {
-	DEBPROTO(printk(KERN_DEBUG "S "));
 	set_pcf(adap, 1, I2C_PCF_START);
 }
 
 static void i2c_repstart(struct i2c_algo_pcf_data *adap)
 {
-	DEBPROTO(printk(" Sr "));
 	set_pcf(adap, 1, I2C_PCF_REPSTART);
 }
 
 static void i2c_stop(struct i2c_algo_pcf_data *adap)
 {
-	DEBPROTO(printk("P\n"));
 	set_pcf(adap, 1, I2C_PCF_STOP);
 }
 
 static void handle_lab(struct i2c_algo_pcf_data *adap, const int *status)
 {
-	DEB2(printk(KERN_INFO
-		"i2c-algo-pcf.o: lost arbitration (CSR 0x%02x)\n",
-		*status));
 	/*
 	 * Cleanup from LAB -- reset and enable ESO.
 	 * This resets the PCF8584; since we've lost the bus, no
@@ -88,9 +73,6 @@ static void handle_lab(struct i2c_algo_pcf_data *adap, const int *status)
 	if (adap->lab_mdelay)
 		mdelay(adap->lab_mdelay);
 
-	DEB2(printk(KERN_INFO
-		"i2c-algo-pcf.o: reset LAB condition (CSR 0x%02x)\n",
-		get_pcf(adap, 1)));
 }
 
 static int wait_for_bb(struct i2c_algo_pcf_data *adap)
@@ -151,9 +133,6 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 {
 	unsigned char temp;
 
-	DEB3(printk(KERN_DEBUG "i2c-algo-pcf.o: PCF state 0x%02x\n",
-				get_pcf(adap, 1)));
-
 	/* S1=0x80: S0 selected, serial interface off */
 	set_pcf(adap, 1, I2C_PCF_PIN);
 	/*
@@ -161,7 +140,6 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	 * PCF8584 does that when ESO is zero
 	 */
 	if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S0 (0x%02x).\n", temp));
 		return -ENXIO; /* definitely not PCF8584 */
 	}
 
@@ -169,7 +147,6 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	i2c_outb(adap, get_own(adap));
 	/* check it's really written */
 	if ((temp = i2c_inb(adap)) != get_own(adap)) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S0 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
 
@@ -177,7 +154,6 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
 	/* check to see S2 now selected */
 	if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
 
@@ -185,7 +161,6 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	i2c_outb(adap, get_clock(adap));
 	/* check it's really written, the only 5 lowest bits does matter */
 	if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't set S2 (0x%02x).\n", temp));
 		return -ENXIO;
 	}
 
@@ -194,7 +169,6 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 
 	/* check to see PCF is really idled and we can access status register */
 	if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: PCF detection failed -- can't select S1` (0x%02x).\n", temp));
 		return -ENXIO;
 	}
 
@@ -210,8 +184,6 @@ static int pcf_sendbytes(struct i2c_adapter *i2c_adap, const char *buf,
 	int wrcount, status, timeout;
 
 	for (wrcount=0; wrcount<count; ++wrcount) {
-		DEB2(dev_dbg(&i2c_adap->dev, "i2c_write: writing %2.2X\n",
-				buf[wrcount] & 0xff));
 		i2c_outb(adap, buf[wrcount]);
 		timeout = wait_for_pin(adap, &status);
 		if (timeout) {
@@ -307,8 +279,6 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 	/* Check for bus busy */
 	timeout = wait_for_bb(adap);
 	if (timeout) {
-		DEB2(printk(KERN_ERR "i2c-algo-pcf.o: "
-			    "Timeout waiting for BB in pcf_xfer\n");)
 		i = -EIO;
 		goto out;
 	}
@@ -316,10 +286,6 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 	for (i = 0;ret >= 0 && i < num; i++) {
 		pmsg = &msgs[i];
 
-		DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: Doing %s %d bytes to 0x%02x - %d of %d messages\n",
-		     str_read_write(pmsg->flags & I2C_M_RD),
-		     pmsg->len, pmsg->addr, i + 1, num);)
-
 		ret = pcf_doAddress(adap, pmsg);
 
 		/* Send START */
@@ -335,8 +301,6 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 				goto out;
 			}
 			i2c_stop(adap);
-			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: Timeout waiting "
-				    "for PIN(1) in pcf_xfer\n");)
 			i = -EREMOTEIO;
 			goto out;
 		}
@@ -344,34 +308,17 @@ static int pcf_xfer(struct i2c_adapter *i2c_adap,
 		/* Check LRB (last rcvd bit - slave ack) */
 		if (status & I2C_PCF_LRB) {
 			i2c_stop(adap);
-			DEB2(printk(KERN_ERR "i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");)
 			i = -EREMOTEIO;
 			goto out;
 		}
 
-		DEB3(printk(KERN_DEBUG "i2c-algo-pcf.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n",
-			    i, msgs[i].addr, msgs[i].flags, msgs[i].len);)
 
 		if (pmsg->flags & I2C_M_RD) {
 			ret = pcf_readbytes(i2c_adap, pmsg->buf, pmsg->len,
 					    (i + 1 == num));
-
-			if (ret != pmsg->len) {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only read %d bytes.\n",ret));
-			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: read %d bytes.\n",ret));
-			}
 		} else {
 			ret = pcf_sendbytes(i2c_adap, pmsg->buf, pmsg->len,
 					    (i + 1 == num));
-
-			if (ret != pmsg->len) {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: fail: "
-					    "only wrote %d bytes.\n",ret));
-			} else {
-				DEB2(printk(KERN_DEBUG "i2c-algo-pcf.o: wrote %d bytes.\n",ret));
-			}
 		}
 	}
 
@@ -401,8 +348,6 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
 	struct i2c_algo_pcf_data *pcf_adap = adap->algo_data;
 	int rval;
 
-	DEB2(dev_dbg(&adap->dev, "hw routines registered.\n"));
-
 	/* register new adapter to i2c module... */
 	adap->algo = &pcf_algo;
 
@@ -418,7 +363,3 @@ EXPORT_SYMBOL(i2c_pcf_add_bus);
 MODULE_AUTHOR("Hans Berglund <hb@spacetec.no>");
 MODULE_DESCRIPTION("I2C-Bus PCF8584 algorithm");
 MODULE_LICENSE("GPL");
-
-module_param(i2c_debug, int, S_IRUGO | S_IWUSR);
-MODULE_PARM_DESC(i2c_debug,
-	"debug level - 0 off; 1 normal; 2,3 more verbose; 9 pcf-protocol");
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH v6 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional
  2025-10-16 16:14         ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Cezar Chiru
  2025-10-16 16:14           ` [PATCH v6 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c Cezar Chiru
@ 2025-10-16 16:14           ` Cezar Chiru
  2025-10-16 16:14           ` [PATCH v6 3/3] i2c: pcf8584: Fix space(s) required before or after different operators Cezar Chiru
  2 siblings, 0 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-10-16 16:14 UTC (permalink / raw)
  To: wsa+renesas, andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

Assign inside of 'if' conditional is not allowed. Move assignment from
inside 'if' conditional, to one line before each 'if'conditional statement
that caused errors.
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 | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/i2c/algos/i2c-algo-pcf.c b/drivers/i2c/algos/i2c-algo-pcf.c
index 7e2d8ff33d75..41a81d37e880 100644
--- a/drivers/i2c/algos/i2c-algo-pcf.c
+++ b/drivers/i2c/algos/i2c-algo-pcf.c
@@ -129,7 +129,7 @@ static int wait_for_pin(struct i2c_algo_pcf_data *adap, int *status)
  *
  * vdovikin: added detect code for PCF8584
  */
-static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
+static int pcf_init_8584(struct i2c_algo_pcf_data *adap)
 {
 	unsigned char temp;
 
@@ -139,38 +139,38 @@ static int pcf_init_8584 (struct i2c_algo_pcf_data *adap)
 	 * check to see S1 now used as R/W ctrl -
 	 * PCF8584 does that when ESO is zero
 	 */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != (0)) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != 0)
 		return -ENXIO; /* definitely not PCF8584 */
-	}
 
 	/* load own address in S0, effective address is (own << 1) */
 	i2c_outb(adap, get_own(adap));
 	/* check it's really written */
-	if ((temp = i2c_inb(adap)) != get_own(adap)) {
+	temp = i2c_inb(adap);
+	if (temp != get_own(adap))
 		return -ENXIO;
-	}
 
 	/* S1=0xA0, next byte in S2 */
 	set_pcf(adap, 1, I2C_PCF_PIN | I2C_PCF_ES1);
 	/* check to see S2 now selected */
-	if (((temp = get_pcf(adap, 1)) & 0x7f) != I2C_PCF_ES1) {
+	temp = get_pcf(adap, 1);
+	if ((temp & 0x7f) != I2C_PCF_ES1)
 		return -ENXIO;
-	}
 
 	/* load clock register S2 */
 	i2c_outb(adap, get_clock(adap));
 	/* check it's really written, the only 5 lowest bits does matter */
-	if (((temp = i2c_inb(adap)) & 0x1f) != get_clock(adap)) {
+	temp = i2c_inb(adap);
+	if ((temp & 0x1f) != get_clock(adap))
 		return -ENXIO;
-	}
 
 	/* Enable serial interface, idle, S0 selected */
 	set_pcf(adap, 1, I2C_PCF_IDLE);
 
 	/* check to see PCF is really idled and we can access status register */
-	if ((temp = get_pcf(adap, 1)) != (I2C_PCF_PIN | I2C_PCF_BB)) {
+	temp = get_pcf(adap, 1);
+	if (temp != (I2C_PCF_PIN | I2C_PCF_BB))
 		return -ENXIO;
-	}
 
 	printk(KERN_DEBUG "i2c-algo-pcf.o: detected and initialized PCF8584.\n");
 
@@ -218,7 +218,8 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
 	/* increment number of bytes to read by one -- read dummy byte */
 	for (i = 0; i <= count; i++) {
 
-		if ((wfp = wait_for_pin(adap, &status))) {
+		wfp = wait_for_pin(adap, &status);
+		if (wfp) {
 			if (wfp == -EINTR)
 				return -EINTR; /* arbitration lost */
 
@@ -351,7 +352,8 @@ int i2c_pcf_add_bus(struct i2c_adapter *adap)
 	/* register new adapter to i2c module... */
 	adap->algo = &pcf_algo;
 
-	if ((rval = pcf_init_8584(pcf_adap)))
+	rval = pcf_init_8584(pcf_adap);
+	if (rval)
 		return rval;
 
 	rval = i2c_add_adapter(adap);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [PATCH v6 3/3] i2c: pcf8584: Fix space(s) required before or after different operators
  2025-10-16 16:14         ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Cezar Chiru
  2025-10-16 16:14           ` [PATCH v6 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c Cezar Chiru
  2025-10-16 16:14           ` [PATCH v6 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional Cezar Chiru
@ 2025-10-16 16:14           ` Cezar Chiru
  2 siblings, 0 replies; 49+ messages in thread
From: Cezar Chiru @ 2025-10-16 16:14 UTC (permalink / raw)
  To: wsa+renesas, andi.shyti; +Cc: linux-i2c, linux-kernel, Cezar Chiru

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


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch
  2025-09-27  4:13             ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Cezar Chiru
                                 ` (2 preceding siblings ...)
  2025-09-27  4:14               ` [PATCH v6 3/3] i2c: pcf8584: Fix space(s) required before or after different operators Cezar Chiru
@ 2025-10-17 20:39               ` Andi Shyti
  3 siblings, 0 replies; 49+ messages in thread
From: Andi Shyti @ 2025-10-17 20:39 UTC (permalink / raw)
  To: Cezar Chiru; +Cc: wsa+renesas, linux-i2c, linux-kernel

Hi Cezar,

can you please send your new version series as not
--in-reply-to?

I find it very confusing.

Thanks,
Andi

On Sat, Sep 27, 2025 at 07:13:57AM +0300, Cezar Chiru wrote:
> Hello maintainers,
> 
> This patch series fixes 18 errors and multiple warnings reported by 
> checkpatch.pl on drivers/i2c/algos/i2c-algo-pcf.c file.
> 
> The series PATCH v1 to PATCH v4 is a response to the discussion on the
> mailing list with Markus Elfring who had comments on my earlier 
> submissions. 
> He suggested:
>  -to split my initial submission in a patch series
>  -had some valid points on imperative mood usage in commit messages
>  -wrapping commit message to 75 columns per line
>  -change some of the commit message to point usage of checkpatch.pl
> The series PATCH v4 to PATCH v6 is a response to the discussion on the
> mailing list with I2C SUBSYSTEM maintainer Wolfram Sang who requested
> some changes:
> He requested:
>  - to remove debug macros from i2c-algo-pcf.c as no code change was done
>  for almost 16 years.
>  - remove wrapping paranthesis from value assigned of '(0)''.
>  - resolve conficts caused by debug macros removal.
>  - remove also printk and dev_dbg function calls related to DEB macros.
> 
> Here is a brief summary and order of patches to be applied:
> Patch 1/3: i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
> This patch remove the define of debug macros and also their usage from
> code along with printk and dev_dbg function calls.
> 
> Patch 2/3: i2c: pcf8584: Fix do not use assignment inside if conditional
> This patch takes the assignement from if conditional and moves it by 1 line
> up.
> 
> Patch 3/3: i2c: pcf8584: Fix space(s) required before or after different
>            operators
> This patch adds space(s) around some binary operators.
> 
> Testing:
>    *built kernel and modules with I2C_ALGOPCF=m and my 3 patches applied on
>    top of 6.17.0-rc7.
>    *installed kernel and external modules generated by build on my laptop
>    *rebooted and loaded i2c-algo-pcf.ko without i2c_debug parameter.
>    *when loading the .ko with i2c_debug parameter an error is seen in dmesg
>    and this is expected as the parameter was removed.
>    *No success message related to i2c_algo_pcf was seen in dmesg but also 
>    no failures.
>    *Module loading and unloading successful.
>    *No PCF8584 Hardware was available.
> 
> Cezar Chiru (3):
>   i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
>   i2c: pcf8584: Fix do not use assignment inside if conditional
>   i2c: pcf8584: Fix space(s) required before or after different
>     operators
> 
>  drivers/i2c/algos/i2c-algo-pcf.c | 93 +++++++-------------------------
>  1 file changed, 18 insertions(+), 75 deletions(-)
> 
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v6 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
  2025-09-27  4:13               ` [PATCH v6 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c Cezar Chiru
@ 2025-10-17 20:47                 ` Andi Shyti
  0 siblings, 0 replies; 49+ messages in thread
From: Andi Shyti @ 2025-10-17 20:47 UTC (permalink / raw)
  To: Cezar Chiru; +Cc: wsa+renesas, linux-i2c, linux-kernel

Hi Cezar,

On Sat, Sep 27, 2025 at 07:13:58AM +0300, Cezar Chiru wrote:
> Remove debug macros and printk and dev_debg function calls from file
> as no change was done for 16 years.

You have also removed the module parameter.

> Request by I2C SUBSYSTEM maintainer Wolfram Sang.

Please, remove this last sentence, it's not a useful information
to add in a git log. You can either add it in the cover letter or
after the "---" section. I'd say in the cover letter as you have
already done.

The patch looks good. Thanks for taking care of it.

Andi

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [PATCH v6 3/3] i2c: pcf8584: Fix space(s) required before or after different operators
  2025-09-27  4:14               ` [PATCH v6 3/3] i2c: pcf8584: Fix space(s) required before or after different operators Cezar Chiru
@ 2025-10-17 20:58                 ` Andi Shyti
  0 siblings, 0 replies; 49+ messages in thread
From: Andi Shyti @ 2025-10-17 20:58 UTC (permalink / raw)
  To: Cezar Chiru; +Cc: wsa+renesas, linux-i2c, linux-kernel

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
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2025-10-17 20:58 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-07 11:45 [PATCH] i2c : algos : i2c-algo-pcf.c : fixed errors shown by checkpatch Cezar Chiru
2025-09-07 12:07 ` [PATCH v2] " Cezar Chiru
2025-09-07 13:19   ` Markus Elfring
2025-09-07 15:38     ` Cezar Chiru
2025-09-07 17:45       ` [PATCH v3] " Markus Elfring
2025-09-08 11:13         ` [PATCH 0/3] i2c : PCF8584 : Cover Letter Cezar Chiru
2025-09-08 11:13           ` [PATCH 1/3] i2c : pcf8584 : Fix debug macros defines of if statements Cezar Chiru
2025-09-08 12:44             ` Markus Elfring
2025-09-08 13:36               ` [PATCH v2 0/3] i2c: PCF8584: Cover letter Cezar Chiru
2025-09-08 13:36                 ` [PATCH v2 1/3] i2c: PCF8584: Fix debug macros defines of if statements Cezar Chiru
2025-09-08 14:46                   ` Markus Elfring
2025-09-08 15:42                     ` Cezar Chiru
2025-09-08 17:08                       ` [v2 " Markus Elfring
2025-09-08 17:58                         ` [PATCH v3 0/3] i2c: PCF8584: Fix errors reported by checkpatch.pl Cezar Chiru
2025-09-08 17:59                           ` [PATCH v3 1/3] i2c: PCF8584: Fix debug macros defines of if statements Cezar Chiru
2025-09-08 19:18                             ` Markus Elfring
2025-09-08 17:59                           ` [PATCH v3 2/3] i2c: PCF8584: Fix do not use assignment in if conditional Cezar Chiru
2025-09-08 17:59                           ` [PATCH v3 3/3] i2c: PCF8584: Fix space(s) required before or after different operators Cezar Chiru
2025-09-09  7:30                             ` Markus Elfring
2025-09-09  8:18                               ` Cezar Chiru
2025-09-08 13:36                 ` [PATCH v2 2/3] i2c: PCF8584: Fix do not use assignment in 'if' conditional Cezar Chiru
2025-09-08 13:36                 ` [PATCH v2 3/3] i2c: PCF8584: Fixed space(s) required after different operators Cezar Chiru
2025-09-08 11:13           ` [PATCH 2/3] i2c : PCF8584 : Fix do not use assignment in 'if' conditional Cezar Chiru
2025-09-08 11:13           ` [PATCH 3/3] i2c : PCF8584 : Fixed space required after different operators Cezar Chiru
2025-09-17 13:35 ` [PATCH v4 0/3] i2c: pcf8584: Fix errors reported by checkpatch.pl Cezar Chiru
2025-09-17 13:35   ` [PATCH v4 1/3] i2c: pcf8584: Fix debug macros defines of if statements Cezar Chiru
2025-09-25 10:35     ` Wolfram Sang
2025-09-25 11:56       ` Cezar Chiru
2025-09-26 15:45       ` [PATCH v5 0/3] i2c: pcf8584: Fix errors reported by checkpatch Cezar Chiru
2025-09-26 15:45         ` [PATCH v5 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c Cezar Chiru
2025-09-26 18:07           ` Wolfram Sang
2025-09-26 19:05             ` Cezar Chiru
2025-09-27  4:13             ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Cezar Chiru
2025-09-27  4:13               ` [PATCH v6 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c Cezar Chiru
2025-10-17 20:47                 ` Andi Shyti
2025-09-27  4:13               ` [PATCH v6 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional Cezar Chiru
2025-09-27  4:14               ` [PATCH v6 3/3] i2c: pcf8584: Fix space(s) required before or after different operators Cezar Chiru
2025-10-17 20:58                 ` Andi Shyti
2025-10-17 20:39               ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Andi Shyti
2025-09-26 15:45         ` [PATCH v5 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional Cezar Chiru
2025-09-26 15:45         ` [PATCH v5 3/3] i2c: pcf8584: Fix space(s) required before or after different operators Cezar Chiru
2025-10-16 16:14         ` [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch Cezar Chiru
2025-10-16 16:14           ` [PATCH v6 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c Cezar Chiru
2025-10-16 16:14           ` [PATCH v6 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional Cezar Chiru
2025-10-16 16:14           ` [PATCH v6 3/3] i2c: pcf8584: Fix space(s) required before or after different operators Cezar Chiru
2025-09-17 13:35   ` [PATCH v4 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional Cezar Chiru
2025-09-25 10:35     ` Wolfram Sang
2025-09-17 13:35   ` [PATCH v4 3/3] i2c: pcf8584: Fix space(s) required before or after different operators Cezar Chiru
2025-09-25 10:35     ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).