i2c : algos : i2c-algo-pcf.c : fixed errors shown by checkpatch
PATCH 1/1 i2c : algos : i2c-algo-pcf.c : fixed errors shown by checkpatch
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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 50 +++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 17 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +33 -17
@@ -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);
Signature · 1 line
2.43.0
PATCH v2 1/1 i2c : algos : i2c-algo-pcf.c : fixed errors shown by checkpatch
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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 42 +++++++++++++++++++------------- 1 file changed, 25 insertions(+), 17 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +25 -17
@@ -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);
Signature · 1 line
2.43.0
Quoted 1 line
Fixed all 18 errors revealed using checkpatch.pl on
i2c-algo-pcf.c
…
…
Quoted 1 line
Motivation is to fix all errors and warnings i2c-algo-pcf kerenel
…
kernel?
…
Quoted 7 lines
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 <[email protected]>--- 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
On Sun, Sep 07, 2025 at 03:19:20PM +0200, Markus Elfring wrote:
Hello Markus,
Quoted 5 lines
Quoted 1 line
Fixed all 18 errors revealed using checkpatch.pl on
i2c-algo-pcf.c…
Refactored the commit message to be more compact
Quoted 4 lines
…
Quoted 1 line
Motivation is to fix all errors and warnings i2c-algo-pcf kerenel
…
kernel?
Yes, "kernel" was intended. Fixed.
Quoted 8 lines
Quoted 7 lines
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 <[email protected]>--- 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.
Quoted 5 lines
* 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
From a94b19cb2c689989dbe72c04864bd718f2c05307 Mon Sep 17 00:00:00 2001
From: Cezar Chiru <[email protected]>
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.
---
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(-)
drivers/i2c/algos/i2c-algo-pcf.c +25 -17
@@ -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);
Signature · 1 line
2.43.0
Quoted 3 lines
Quoted 2 lines
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
Quoted 1 line
Markus, Andi, new [PATCH v3] attached to this email.
Please take another look at the usual development message requirements.
Regards,
Markus
cover i2c : PCF8584 : Cover Letter
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(-)
Signature · 1 line
2.43.0
PATCH 1/3 i2c : pcf8584 : Fix debug macros defines of if statements
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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +18 -9
@@ -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,
Signature · 1 line
2.43.0
Re: [PATCH 1/3] i2c : pcf8584 : Fix debug macros defines of if statements
…> 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
v2 cover i2c: PCF8584: Cover letter
---
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(-)
Signature · 1 line
2.43.0
PATCH v2 1/3 i2c: PCF8584: Fix debug macros defines of if statements
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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +18 -9
@@ -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,
Signature · 1 line
2.43.0
Re: [PATCH v2 1/3] i2c: PCF8584: Fix debug macros defines of if statements
…> 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
…> ---
Quoted 1 line
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
Re: [PATCH v2 1/3] i2c: PCF8584: Fix debug macros defines of if statements
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.
Quoted 4 lines
…> 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.
Quoted 4 lines
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.
Quoted 9 lines
…> ---
Quoted 1 line
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
Re: [v2 1/3] i2c: PCF8584: Fix debug macros defines of if statements
Quoted 1 line
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
v3 cover i2c: PCF8584: Fix errors reported by checkpatch.pl
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(-)
Signature · 1 line
2.43.0
PATCH v3 1/3 i2c: PCF8584: Fix debug macros defines of if statements
macros: Enclose 'if' statements debug macros defines in do - while loops. Fix inconsistent macro usage ending ';', which caused build errors in some cases.
---
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(-)
drivers/i2c/algos/i2c-algo-pcf.c +18 -9
@@ -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,
Signature · 1 line
2.43.0
Re: [PATCH v3 1/3] i2c: PCF8584: Fix debug macros defines of if statements
Quoted 1 line
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
PATCH v3 2/3 i2c: PCF8584: Fix do not use assignment in if conditional
In reply to Cezar Chiruif 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.
---
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(-)
drivers/i2c/algos/i2c-algo-pcf.c +14 -7
@@ -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);
Signature · 1 line
2.43.0
PATCH v3 3/3 i2c: PCF8584: Fix space(s) required before or after different operators
In reply to Cezar Chiruoperators: Require spaces around or before or after '=', ';', '<' and ','. Add space(s) around or before or after different operators.
---
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(-)
drivers/i2c/algos/i2c-algo-pcf.c +7 -7
@@ -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)); } } }
Signature · 1 line
2.43.0
Re: [PATCH v3 3/3] i2c: PCF8584: Fix space(s) required before or after different operators
Quoted 2 lines
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
Re: [PATCH v3 3/3] i2c: PCF8584: Fix space(s) required before or after different operators
Hi Markus,
Thank you for the time to review my patch series.
Quoted 6 lines
Quoted 2 lines
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: ';' , ','
PATCH v2 2/3 i2c: PCF8584: Fix do not use assignment in 'if' conditional
In reply to Cezar ChiruFixed 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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +14 -7
@@ -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);
Signature · 1 line
2.43.0
PATCH v2 3/3 i2c: PCF8584: Fixed space(s) required after different operators
In reply to Cezar ChiruError: spaces required around or before or after '=', ';', '<' and ',' operators. Revealed by checkpatch.pl.
Added space(s) around or before or after different operators.
--- drivers/i2c/algos/i2c-algo-pcf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +7 -7
@@ -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)); } } }
Signature · 1 line
2.43.0
PATCH 2/3 i2c : PCF8584 : Fix do not use assignment in 'if' conditional
In reply to Cezar ChiruFixed 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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +14 -7
@@ -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);
Signature · 1 line
2.43.0
PATCH 3/3 i2c : PCF8584 : Fixed space required after different operators
In reply to Cezar ChiruThe error was: spaces required around or before or after '=', ';', '<' and ',' operators.
Fixed by adding space(s) around or before or after different operators.
--- drivers/i2c/algos/i2c-algo-pcf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +7 -7
@@ -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)); } } }
Signature · 1 line
2.43.0
v4 cover i2c: pcf8584: Fix errors reported by checkpatch.pl
In reply to Cezar ChiruHello 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(-)
Signature · 1 line
2.43.0
PATCH v4 1/3 i2c: pcf8584: Fix debug macros defines of if statements
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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +18 -9
@@ -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,
Signature · 1 line
2.43.0
Re: [PATCH v4 1/3] i2c: pcf8584: Fix debug macros defines of if statements
Hi,
Quoted 3 lines · 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.
Thank you for the patch.
Quoted 10 lines
Signed-off-by Cezar Chiru <[email protected]>--- drivers/i2c/algos/i2c-algo-pcf.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)drivers/i2c/algos/i2c-algo-pcf.c +0
-0
drivers/i2c/algos/i2c-algo-pcf.c line 28
Quoted 6 lines
drivers/i2c/algos/i2c-algo-pcf.c +0
-3@@ -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
Re: [PATCH v4 1/3] i2c: pcf8584: Fix debug macros defines of if statements
Hi Wolfram,
Quoted 6 lines
drivers/i2c/algos/i2c-algo-pcf.c line 28
Quoted 3 lines
drivers/i2c/algos/i2c-algo-pcf.c +0
-3-#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
v5 cover i2c: pcf8584: Fix errors reported by checkpatch
In reply to Wolfram SangHello 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(-)
Signature · 1 line
2.43.0
PATCH v5 1/3 i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 78 +++++++++++++------------------- 1 file changed, 31 insertions(+), 47 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +31 -47
@@ -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 <[email protected]>" );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" );
Signature · 1 line
2.43.0
Re: [PATCH v5 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
drivers/i2c/algos/i2c-algo-pcf.c static int i2c_debug; · line 41
Quoted 3 lines
drivers/i2c/algos/i2c-algo-pcf.c +1
-1-DEBPROTO (printk (KERN_DEBUG "S " )); +printk (KERN_DEBUG "S " );
Now you print the former debug printouts unconditionally? Why is that?
Re: [PATCH v5 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
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.
Quoted 5 lines
drivers/i2c/algos/i2c-algo-pcf.c static int i2c_debug; · line 41
Quoted 2 lines
drivers/i2c/algos/i2c-algo-pcf.c +1
-1-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
v6 cover i2c: pcf8584: Fix errors and warnings reported by checkpatch
In reply to Wolfram SangHello 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(-)
Signature · 1 line
2.43.0
PATCH v6 1/3 i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 59 -------------------------------- 1 file changed, 59 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +0 -59
@@ -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 <[email protected]>" );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" );
Signature · 1 line
2.43.0
Andi Shyti
maintainerRe: [PATCH v6 1/3] i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
Hi Cezar,
Quoted 2 lines · Cezar Chiru
Remove debug macros and printk and
dev_debgfunction calls from file as no change was done for 16 years.
You have also removed the module parameter.
Quoted 1 line
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
PATCH v6 2/3 i2c: pcf8584: Fix do not use assignment inside if conditional
In reply to Cezar ChiruAssign 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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +15 -13
@@ -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);
Signature · 1 line
2.43.0
PATCH v6 3/3 i2c: pcf8584: Fix space(s) required before or after different operators
In reply to Cezar ChiruRequire spaces around '=', '>' and '<'. Add space(s) around binary operators.
Enforce errors fixing based on checkpatch.pl output on file.
--- drivers/i2c/algos/i2c-algo-pcf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +3 -3
@@ -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);
Signature · 1 line
2.43.0
Andi Shyti
maintainerRe: [PATCH v6 3/3] i2c: pcf8584: Fix space(s) required before or after different operators
Hi Cezar,
...
drivers/i2c/algos/i2c-algo-pcf.c static int pcf_xfer(struct i2c_adapter *i2c_adap, · line 287
Quoted 6 lines
drivers/i2c/algos/i2c-algo-pcf.c +1
-1@@ -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...
drivers/i2c/algos/i2c-algo-pcf.c static int pcf_xfer(struct i2c_adapter *i2c_adap, · line 290
Quoted 3 lines
drivers/i2c/algos/i2c-algo-pcf.c +0
-0pmsg = &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
Quoted 3 lines
Signature · 1 line
2.43.0
Andi Shyti
maintainerRe: [PATCH v6 0/3] i2c: pcf8584: Fix errors and warnings reported by checkpatch
In reply to Cezar ChiruHi Cezar,
can you please send your new version series as not --in-reply-to?
I find it very confusing.
Thanks,
Andi
Quoted 60 lines · Cezar Chiru
Hello maintainers,
This patch series fixes 18 errors and multiple warnings reported by checkpatch.pl on
drivers/i2c/algos/i2c-algo-pcf.cfile.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 fromi2c-algo-pcf.cas 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 anddev_dbgfunction 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 fromi2c-algo-pcf.cThis patch remove the define of debug macros and also their usage from code along with printk anddev_dbgfunction 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 withouti2c_debugparameter. *when loading the .ko withi2c_debugparameter an error is seen in dmesg and this is expected as the parameter was removed.
*No success message related toi2c_algo_pcfwas 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 fromi2c-algo-pcf.c
i2c: pcf8584: Fix do not use assignment inside if conditional
i2c: pcf8584: Fix space(s) required before or after different
operatorsdrivers/i2c/algos/i2c-algo-pcf.c | 93 +++++++------------------------- 1 file changed, 18 insertions(+), 75 deletions(-)Signature · 1 line
2.43.0
PATCH v5 2/3 i2c: pcf8584: Fix do not use assignment inside if conditional
In reply to Cezar ChiruAssign 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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +14 -7
@@ -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);
Signature · 1 line
2.43.0
PATCH v5 3/3 i2c: pcf8584: Fix space(s) required before or after different operators
In reply to Cezar ChiruRequire 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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +7 -7
@@ -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); } } }
Signature · 1 line
2.43.0
v6 cover i2c: pcf8584: Fix errors and warnings reported by checkpatch
In reply to Cezar ChiruHello 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(-)
Signature · 1 line
2.43.0
PATCH v6 1/3 i2c: pcf8584: Remove debug macros from i2c-algo-pcf.c
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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 59 -------------------------------- 1 file changed, 59 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +0 -59
@@ -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 <[email protected]>" );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" );
Signature · 1 line
2.43.0
PATCH v6 2/3 i2c: pcf8584: Fix do not use assignment inside if conditional
In reply to Cezar ChiruAssign 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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +15 -13
@@ -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);
Signature · 1 line
2.43.0
PATCH v6 3/3 i2c: pcf8584: Fix space(s) required before or after different operators
In reply to Cezar ChiruRequire spaces around '=', '>' and '<'. Add space(s) around binary operators.
Enforce errors fixing based on checkpatch.pl output on file.
--- drivers/i2c/algos/i2c-algo-pcf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +3 -3
@@ -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);
Signature · 1 line
2.43.0
PATCH v4 2/3 i2c: pcf8584: Fix do not use assignment inside if conditional
In reply to Cezar ChiruAssign 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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +14 -7
@@ -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);
Signature · 1 line
2.43.0
Re: [PATCH v4 2/3] i2c: pcf8584: Fix do not use assignment inside if conditional
drivers/i2c/algos/i2c-algo-pcf.c static int pcf_init_8584 (struct i2c_algo_pcf_data *adap) · line 173
Quoted 2 lines
drivers/i2c/algos/i2c-algo-pcf.c +1
-0+if ((temp &0x7f ) != (0 )) {
Braces around '0' can go as well.
PATCH v4 3/3 i2c: pcf8584: Fix space(s) required before or after different operators
In reply to Cezar ChiruRequire 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.
--- drivers/i2c/algos/i2c-algo-pcf.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/i2c/algos/i2c-algo-pcf.c +7 -7
@@ -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)); } } }
Signature · 1 line
2.43.0
Re: [PATCH v4 3/3] i2c: pcf8584: Fix space(s) required before or after different operators
Quoted 6 lines · 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 <[email protected]>
This patch is basically OK, but will become smaller if you remove the DEB2 macro.