staging/rtl8192u: fix coding style problems
PATCH v2 1/3 staging/rtl8192u: fix coding style problems
fixed some of the coding style problems reported by checkpatch
--- drivers/staging/rtl8192u/r8180_93cx6.c | 36 +++++++++++++++++--------------- 1 file changed, 19 insertions(+), 17 deletions(-)
drivers/staging/rtl8192u/r8180_93cx6.c +19 -17
@@ -22,13 +22,16 @@void eprom_cs (struct net_device *dev,short bit) { -if (bit) +if (bit) { +/* enable EPROM */ write_nic_byte_E (dev,EPROM_CMD , - (1 <<EPROM_CS_SHIFT ) | \ -read_nic_byte_E (dev,EPROM_CMD ));//enable EPROM -else -write_nic_byte_E (dev,EPROM_CMD ,read_nic_byte_E (dev,EPROM_CMD )\ - &~(1 <<EPROM_CS_SHIFT ));//disable EPROM + (1 <<EPROM_CS_SHIFT ) | +read_nic_byte_E (dev,EPROM_CMD )); + }else { +/* disable EPROM */ +write_nic_byte_E (dev,EPROM_CMD ,read_nic_byte_E (dev,EPROM_CMD ) + & ~(1 <<EPROM_CS_SHIFT )); + }force_pci_posting (dev);udelay (EPROM_DELAY );
@@ -38,24 +41,24 @@ void eprom_cs(struct net_device *dev, short bit)void eprom_ck_cycle (struct net_device *dev) {write_nic_byte_E (dev,EPROM_CMD , - (1 <<EPROM_CK_SHIFT ) |read_nic_byte_E (dev,EPROM_CMD )); + (1 <<EPROM_CK_SHIFT ) |read_nic_byte_E (dev,EPROM_CMD ));force_pci_posting (dev);udelay (EPROM_DELAY );write_nic_byte_E (dev,EPROM_CMD , -read_nic_byte_E (dev,EPROM_CMD ) &~ (1 <<EPROM_CK_SHIFT )); +read_nic_byte_E (dev,EPROM_CMD ) & ~(1 <<EPROM_CK_SHIFT ));force_pci_posting (dev);udelay (EPROM_DELAY ); } -void eprom_w (struct net_device *dev,short bit) +void eprom_w (struct net_device *dev,short bit) { -if (bit) -write_nic_byte_E (dev,EPROM_CMD , (1 <<EPROM_W_SHIFT ) | \ -read_nic_byte_E (dev,EPROM_CMD )); +if (bit) +write_nic_byte_E (dev,EPROM_CMD , (1 <<EPROM_W_SHIFT ) | +read_nic_byte_E (dev,EPROM_CMD ));else -write_nic_byte_E (dev,EPROM_CMD ,read_nic_byte_E (dev,EPROM_CMD )\ - &~(1 <<EPROM_W_SHIFT )); +write_nic_byte_E (dev,EPROM_CMD ,read_nic_byte_E (dev,EPROM_CMD ) + & ~(1 <<EPROM_W_SHIFT ));force_pci_posting (dev);udelay (EPROM_DELAY );
@@ -66,11 +69,10 @@ short eprom_r(struct net_device *dev) {short bit; - bit=(read_nic_byte_E (dev,EPROM_CMD ) & (1 <<EPROM_R_SHIFT ) ); + bit = (read_nic_byte_E (dev,EPROM_CMD ) & (1 <<EPROM_R_SHIFT ));udelay (EPROM_DELAY ); -if (bit)return 1 ; -return 0 ; +return !!bit; }
Signature · 1 line
1.7.9.5
Greg Kroah-Hartman
maintainerQuoted 68 lines · Devendra Naga
fixed some of the coding style problems reported by checkpatch
Signed-off-by Devendra Naga <[email protected]>--- drivers/staging/rtl8192u/r8180_93cx6.c | 36 +++++++++++++++++--------------- 1 file changed, 19 insertions(+), 17 deletions(-)drivers/staging/rtl8192u/r8180_93cx6.c +17
-14@@ -22,13 +22,16 @@void eprom_cs (struct net_device *dev,short bit) { -if (bit) +if (bit) { +/* enable EPROM */ write_nic_byte_E (dev,EPROM_CMD , - (1 <<EPROM_CS_SHIFT ) | \ -read_nic_byte_E (dev,EPROM_CMD ));//enable EPROM -else -write_nic_byte_E (dev,EPROM_CMD ,read_nic_byte_E (dev,EPROM_CMD )\ - &~(1 <<EPROM_CS_SHIFT ));//disable EPROM + (1 <<EPROM_CS_SHIFT ) | +read_nic_byte_E (dev,EPROM_CMD )); + }else { +/* disable EPROM */ +write_nic_byte_E (dev,EPROM_CMD ,read_nic_byte_E (dev,EPROM_CMD ) + & ~(1 <<EPROM_CS_SHIFT )); + }force_pci_posting (dev);udelay (EPROM_DELAY );@@ -38,24 +41,24 @@ void eprom_cs(struct net_device *dev, short bit)void eprom_ck_cycle (struct net_device *dev) {write_nic_byte_E (dev,EPROM_CMD , - (1 <<EPROM_CK_SHIFT ) |read_nic_byte_E (dev,EPROM_CMD )); + (1 <<EPROM_CK_SHIFT ) |read_nic_byte_E (dev,EPROM_CMD ));force_pci_posting (dev);udelay (EPROM_DELAY );write_nic_byte_E (dev,EPROM_CMD , -read_nic_byte_E (dev,EPROM_CMD ) &~ (1 <<EPROM_CK_SHIFT )); +read_nic_byte_E (dev,EPROM_CMD ) & ~(1 <<EPROM_CK_SHIFT ));force_pci_posting (dev);udelay (EPROM_DELAY ); } -void eprom_w (struct net_device *dev,short bit) +void eprom_w (struct net_device *dev,short bit) { -if (bit) -write_nic_byte_E (dev,EPROM_CMD , (1 <<EPROM_W_SHIFT ) | \ -read_nic_byte_E (dev,EPROM_CMD )); +if (bit) +write_nic_byte_E (dev,EPROM_CMD , (1 <<EPROM_W_SHIFT ) | +read_nic_byte_E (dev,EPROM_CMD ));else -write_nic_byte_E (dev,EPROM_CMD ,read_nic_byte_E (dev,EPROM_CMD )\ - &~(1 <<EPROM_W_SHIFT )); +write_nic_byte_E (dev,EPROM_CMD ,read_nic_byte_E (dev,EPROM_CMD ) + & ~(1 <<EPROM_W_SHIFT ));force_pci_posting (dev);udelay (EPROM_DELAY );
drivers/staging/rtl8192u/r8180_93cx6.c short eprom_r(struct net_device *dev) · line 75
Quoted 10 lines
drivers/staging/rtl8192u/r8180_93cx6.c +2
-3@@ -66,11 +69,10 @@ short eprom_r(struct net_device *dev) {short bit; - bit=(read_nic_byte_E (dev,EPROM_CMD ) & (1 <<EPROM_R_SHIFT ) ); + bit = (read_nic_byte_E (dev,EPROM_CMD ) & (1 <<EPROM_R_SHIFT ));udelay (EPROM_DELAY ); -if (bit)return 1 ; -return 0 ; +return !!bit;
Oh come on, really? !! is more "clear" here?
No, please be painfully obvious, that's the only way to write kernel code. Not like this.
greg k-h
Quoted 2 lines · Greg Kroah-Hartman
Quoted 1 line · Devendra Naga
fixed some of the coding style problems reported by checkpatch
[]
Quoted 8 lines
Quoted 8 lines
drivers/staging/rtl8192u/r8180_93cx6.c +1
-1@@ -66,11 +69,10 @@ short eprom_r(struct net_device *dev) {short bit; - bit=(read_nic_byte_E (dev,EPROM_CMD ) & (1 <<EPROM_R_SHIFT ) ); + bit = (read_nic_byte_E (dev,EPROM_CMD ) & (1 <<EPROM_R_SHIFT ));udelay (EPROM_DELAY );
Quoted 5 lines
drivers/staging/rtl8192u/r8180_93cx6.c short eprom_r(struct net_device *dev) · line 75
Quoted 3 lines
drivers/staging/rtl8192u/r8180_93cx6.c +1
-2-if (bit)return 1 ; -return 0 ; +return !!bit;Oh come on, really? !! is more "clear" here?
Depends on the reader. !! is pretty common.
Quoted 2 lines
No, please be painfully obvious, that's the only way to write kernel code. Not like this.
I'd just make the return a bool instead.
Also, there are unnecessary parens that could
be removed to make the code clearer.
(1<<EPROM_R_SHIFT), (1<<EPROM_W_SHIFT) and
(1<<EPROM_CK_SHIFT) could be new #defines too.
Hi Joe,
Quoted 18 lines · Joe Perches
Quoted 2 lines · Greg Kroah-Hartman
Quoted 1 line · Devendra Naga
fixed some of the coding style problems reported by checkpatch
[]
Quoted 8 lines
Quoted 8 lines
drivers/staging/rtl8192u/r8180_93cx6.c +1
-1@@ -66,11 +69,10 @@ short eprom_r(struct net_device *dev) { short bit; - bit=(read_nic_byte_E(dev, EPROM_CMD) & (1<<EPROM_R_SHIFT) ); + bit = (read_nic_byte_E(dev, EPROM_CMD) & (1<<EPROM_R_SHIFT)); udelay(EPROM_DELAY);Quoted 5 lines
drivers/staging/rtl8192u/r8180_93cx6.c short eprom_r(struct net_device *dev) · line 75
Quoted 3 lines
drivers/staging/rtl8192u/r8180_93cx6.c +1
-2- if(bit) return 1; - return 0; + return !!bit;Oh come on, really? !! is more "clear" here?
Quoted 7 lines
Depends on the reader. !! is pretty common.
Quoted 2 lines
No, please be painfully obvious, that's the only way to write kernel code. Not like this.
I'd just make the return a bool instead.
taking another variable and assign it like bool ret = !!bit, and
returning ret?, i think this doesn't look better.
Quoted 7 lines
Also, there are unnecessary parens that could
be removed to make the code clearer.(1<<EPROM_R_SHIFT), (1<<EPROM_W_SHIFT) and
(1<<EPROM_CK_SHIFT) could be new #defines too.
Will do.
thanks joe.
Devendra.
Quoted 23 lines · devendra.aaru
Hi Joe,
Quoted 20 lines · Joe Perches
Quoted 2 lines · Greg Kroah-Hartman
Quoted 1 line · Devendra Naga
fixed some of the coding style problems reported by checkpatch
[]
Quoted 8 lines
Quoted 8 lines
drivers/staging/rtl8192u/r8180_93cx6.c +1
-1@@ -66,11 +69,10 @@ short eprom_r(struct net_device *dev) { short bit; - bit=(read_nic_byte_E(dev, EPROM_CMD) & (1<<EPROM_R_SHIFT) ); + bit = (read_nic_byte_E(dev, EPROM_CMD) & (1<<EPROM_R_SHIFT)); udelay(EPROM_DELAY);Quoted 5 lines
drivers/staging/rtl8192u/r8180_93cx6.c short eprom_r(struct net_device *dev) · line 75
Quoted 3 lines
drivers/staging/rtl8192u/r8180_93cx6.c +1
-2- if(bit) return 1; - return 0; + return !!bit;Oh come on, really? !! is more "clear" here?
Depends on the reader. !! is pretty common.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
No, please be painfully obvious, that's the only way to write kernel code. Not like this.
I'd just make the return a bool instead.
taking another variable and assign it like bool ret = !!bit, and
returning ret?, i think this doesn't look better.
*eye roll*
if (bit) return 1; return 0;
regards,
dan carpenter
Quoted 1 line · devendra.aaru
Hi Joe,
Hi Devendra.
Quoted 5 lines · Joe Perches
Quoted 1 line
I'd just make the return a bool instead.
taking another variable and assign it like bool ret = !!bit, and
returning ret?, i think this doesn't look better.
No. just
return val; or return (bool)val;
if using the implicit conversion bothers you.
Quoted 11 lines · Greg Kroah-Hartman
Quoted 7 lines · Devendra Naga
- bit=(read_nic_byte_E(dev,
EPROM_CMD) & (1<<EPROM_R_SHIFT) );
+ bit = (read_nic_byte_E(dev, EPROM_CMD)& (1<<EPROM_R_SHIFT));udelay(EPROM_DELAY);- if(bit) return 1;
- return 0;
+ return !!bit;Oh come on, really? !! is more "clear" here?
It looks ok to me,
Quoted 3 lines
No, please be painfully obvious, that's the only way to write kernel code. Not like this.
Ok, so no !!'s ? and just that if (bit) thingy?
Quoted 1 line
greg k-h