Drivers: Staging: ft1000: checkpatch warning fixes
PATCH 1/1 Drivers: Staging: ft1000: checkpatch warning fixes
Addition of blank line after declaration in ft1000_hw.c
Minor changes to remove {} from single line if and remove extra parenthesis. Fixes checkpatch warning for <asm/bitops.h> and <asm/io.h> usage.
--- drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 12 ++++++------ drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 9 +++------ 2 files changed, 9 insertions(+), 12 deletions(-)
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +6 -6
@@ -28,8 +28,8 @@#include <linux/timer.h> #include <linux/interrupt.h> #include <linux/in.h> -#include <asm/io.h> -#include <asm/bitops.h> +#include <linux/io.h> +#include <linux/bitops.h> #include <linux/netdevice.h> #include <linux/etherdevice.h>
@@ -1948,11 +1948,11 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id)ft1000_read_reg (dev,FT1000_REG_MAG_DFSR ); } -if (tempword &0x1f ) { +if (tempword &0x1f )ft1000_copy_up_pkt (dev); - }else { +else break ; - } + cnt++; }while (cnt <MAX_RCV_LOOP );
@@ -2008,8 +2008,8 @@ static void ft1000_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) {struct ft1000_info *ft_info; - ft_info =netdev_priv (dev); + ft_info =netdev_priv (dev);strlcpy (info->driver,"ft1000" ,sizeof (info->driver));snprintf (info->bus_info,sizeof (info->bus_info),"PCMCIA 0x%lx" , dev->base_addr);
drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +3 -6
@@ -317,9 +317,8 @@ static int ft1000_open(struct inode *inode, struct file *file)/* Search for available application info block */ for (i =0 ; i <MAX_NUM_APP ; i++) { -if ((dev->app_info[i].fileobject ==NULL )) { +if (dev->app_info[i].fileobject ==NULL )break ; - } }/* Fail due to lack of application info block */
@@ -575,9 +574,8 @@ static long ft1000_ioctl(struct file *file, unsigned int command, }else {/* Check if this message came from a registered application */ for (i =0 ; i <MAX_NUM_APP ; i++) { -if (ft1000dev->app_info[i].fileobject == &file->f_owner) { +if (ft1000dev->app_info[i].fileobject == &file->f_owner)break ; - } }if (i ==MAX_NUM_APP ) {pr_debug ("No matching application fileobject\n" );
@@ -629,9 +627,8 @@ static long ft1000_ioctl(struct file *file, unsigned int command, pmsg = (u16 *)&dpram_data->pseudohdr; ppseudo_hdr = (struct pseudo_hdr *)pmsg; total_len = msgsz+2 ; -if (total_len &0x1 ) { +if (total_len &0x1 ) total_len++; - }/* Insert slow queue sequence number */ ppseudo_hdr->seq_num = info->squeseqnum++;
Signature · 6 lines
1.9.1 --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com
Quoted 4 lines · Janakarajan Natarajan
Addition of blank line after declaration in
ft1000_hw.c
Minor changes to remove {} from single line if and remove extra parenthesis. Fixes checkpatch warning for <asm/bitops.h> and <asm/io.h> usage.
Greg may complain that you've done too much in 1 patch.
Quoted 37 lines
Signed-off-by Janakarajan Natarajan <[email protected]>--- drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 12 ++++++------ drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 9 +++------ 2 files changed, 9 insertions(+), 12 deletions(-)drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +5
-5@@ -28,8 +28,8 @@#include <linux/timer.h> #include <linux/interrupt.h> #include <linux/in.h> -#include <asm/io.h> -#include <asm/bitops.h> +#include <linux/io.h> +#include <linux/bitops.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> @@ -1948,11 +1948,11 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id)ft1000_read_reg (dev,FT1000_REG_MAG_DFSR ); } -if (tempword &0x1f ) { +if (tempword &0x1f )ft1000_copy_up_pkt (dev); - }else { +else break ; - } + cnt++; }while (cnt <MAX_RCV_LOOP );
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c static void ft1000_get_drvinfo(struct net_device *dev, · line 2012
Quoted 6 lines
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +1
-1@@ -2008,8 +2008,8 @@ static void ft1000_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) {struct ft1000_info *ft_info; - ft_info =netdev_priv (dev); + ft_info =netdev_priv (dev);
You could just do:
struct ft1000_info *ft_info = netdev_priv(dev)
Quoted 8 lines
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +0
-0strlcpy (info->driver,"ft1000" ,sizeof (info->driver));snprintf (info->bus_info,sizeof (info->bus_info),"PCMCIA 0x%lx" , dev->base_addr);drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +0
-0
drivers/staging/ft1000/ft1000-usb/ft1000_debug.c static int ft1000_open(struct inode *inode, struct file *file) · line 322
Quoted 7 lines
drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +1
-2@@ -317,9 +317,8 @@ static int ft1000_open(struct inode *inode, struct file *file)/* Search for available application info block */ for (i =0 ; i <MAX_NUM_APP ; i++) { -if ((dev->app_info[i].fileobject ==NULL )) { +if (dev->app_info[i].fileobject ==NULL )break ; - }
Here you can simply do:
if (!dev->app_info[i].file_object)
Quoted 26 lines
drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +2
-4}/* Fail due to lack of application info block */ @@ -575,9 +574,8 @@ static long ft1000_ioctl(struct file *file, unsigned int command, }else {/* Check if this message came from a registered application */ for (i =0 ; i <MAX_NUM_APP ; i++) { -if (ft1000dev->app_info[i].fileobject == &file->f_owner) { +if (ft1000dev->app_info[i].fileobject == &file->f_owner)break ; - } }if (i ==MAX_NUM_APP ) {pr_debug ("No matching application fileobject\n" );@@ -629,9 +627,8 @@ static long ft1000_ioctl(struct file *file, unsigned int command, pmsg = (u16 *)&dpram_data->pseudohdr; ppseudo_hdr = (struct pseudo_hdr *)pmsg; total_len = msgsz+2 ; -if (total_len &0x1 ) { +if (total_len &0x1 ) total_len++; - }/* Insert slow queue sequence number */ ppseudo_hdr->seq_num = info->squeseqnum++;
Signature · 2 lines
Thanks, Giedrius
Quoted 3 lines · Janakarajan Natarajan
Addition of blank line after declaration in
ft1000_hw.c
Minor changes to remove {} from single line if and remove extra parenthesis. Fixes checkpatch warning for <asm/bitops.h> and <asm/io.h> usage.
Most prefer separate patches for each type of change, so this single patch could be 3 patches.
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c
Quoted 1 line
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +0
-0
and for more trivia:
Quoted 4 lines
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +0
-0@@ -1948,11 +1948,11 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id)ft1000_read_reg (dev,FT1000_REG_MAG_DFSR ); }
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c static irqreturn_t ft1000_interrupt(int irq, void *dev_id) · line 1957
Quoted 10 lines
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +3
-3-if (tempword &0x1f ) { +if (tempword &0x1f )ft1000_copy_up_pkt (dev); - }else { +else break ; - } + cnt++; }while (cnt <MAX_RCV_LOOP );
do {
if (foo)
bar;
else
break;
} while (baz);is generally better written
do {
if (!foo)
break;
bar;
} while (baz);so
if (!(tempword & 0x1f)) break; ft100_copy_up_pkt(dev); cnt++; } while (cnt < MAX_RCV_LOOP);
or maybe
if (!(tempword & 0x1f)) break; ft100_copy_up_pkt(dev); } while (++cnt < MAX_RCV_LOOP);
v2 cover ft1000 driver checkpatch.pl fixes
In reply to Janakarajan NatarajanMinor changes to fix ft1000 driver checkpatch.pl warnings
Janakarajan Natarajan (5):
Drivers: Staging: ft1000: Single line if-statement changes
Drivers: Staging: ft1000: Fix extra parenthesis warnings
Drivers: Staging: ft1000: Refactoring if-else statement
Drivers: Staging: ft1000: Fix blank line after declartion warning
Drivers: Staging: ft1000: checkpatch.pl header file warning fix
v2: if-else refactored as suggested by Joe Perches <[email protected]
Variable reworked as suggested by Giedrius Statkevicius <[email protected]>
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 16 +++++++--------- drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 6 ++---- 2 files changed, 9 insertions(+), 13 deletions(-)
Signature · 6 lines
1.9.1 --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com
PATCH v2 1/5 Drivers: Staging: ft1000: Single line if-statement changes
Minor change to remove {} for single line if statements
--- drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +2 -4
@@ -317,9 +317,8 @@ static int ft1000_open(struct inode *inode, struct file *file)/* Search for available application info block */ for (i =0 ; i <MAX_NUM_APP ; i++) { -if ((dev->app_info[i].fileobject ==NULL )) { +if ((dev->app_info[i].fileobject ==NULL ))break ; - } }/* Fail due to lack of application info block */
@@ -575,9 +574,8 @@ static long ft1000_ioctl(struct file *file, unsigned int command, }else {/* Check if this message came from a registered application */ for (i =0 ; i <MAX_NUM_APP ; i++) { -if (ft1000dev->app_info[i].fileobject == &file->f_owner) { +if (ft1000dev->app_info[i].fileobject == &file->f_owner)break ; - } }if (i ==MAX_NUM_APP ) {pr_debug ("No matching application fileobject\n" );
Signature · 6 lines
1.9.1 --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com
PATCH v2 2/5 Drivers: Staging: ft1000: Fix extra parenthesis warnings
In reply to Janakarajan NatarajanMinor changes to remove extra parenthesis
--- drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 2 +- drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +1 -1
@@ -911,7 +911,7 @@ static bool ft1000_receive_cmd(struct net_device *dev, u16 *pbuffer, tempword = *ppseudohdr++;for (i =1 ; i <7 ; i++) tempword ^= *ppseudohdr++; -if ((tempword != *ppseudohdr)) { +if (tempword != *ppseudohdr) {pr_debug ("Pseudo header checksum mismatch\n" );/* Drop this message */ return false;
drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +1 -1
@@ -317,7 +317,7 @@ static int ft1000_open(struct inode *inode, struct file *file)/* Search for available application info block */ for (i =0 ; i <MAX_NUM_APP ; i++) { -if ((dev->app_info[i].fileobject ==NULL )) +if (!dev->app_info[i].fileobject)break ; }
Signature · 6 lines
1.9.1 --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com
PATCH v2 3/5 Drivers: Staging: ft1000: Refactoring if-else statement
In reply to Janakarajan NatarajanMinor change to convert if-else to if statement
--- drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +3 -4
@@ -1948,11 +1948,10 @@ static irqreturn_t ft1000_interrupt(int irq, void *dev_id)ft1000_read_reg (dev,FT1000_REG_MAG_DFSR ); } -if (tempword &0x1f ) { -ft1000_copy_up_pkt (dev); - }else { +if (!(tempword &0x1f ))break ; - } + +ft1000_copy_up_pkt (dev); cnt++; }while (cnt <MAX_RCV_LOOP );
Signature · 6 lines
1.9.1 --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com
PATCH v2 4/5 Drivers: Staging: ft1000: Fix blank line warning
In reply to Janakarajan NatarajanMerges variable declaration and definition.
--- drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +1 -2
@@ -2006,8 +2006,7 @@ void stop_ft1000_card(struct net_device *dev)static void ft1000_get_drvinfo (struct net_device *dev,struct ethtool_drvinfo *info) { -struct ft1000_info *ft_info; - ft_info =netdev_priv (dev); +struct ft1000_info *ft_info =netdev_priv (dev);strlcpy (info->driver,"ft1000" ,sizeof (info->driver)); snprintf(info->bus_info, sizeof(info->bus_info), "PCMCIA 0x%lx",
Signature · 6 lines
1.9.1 --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com
PATCH v2 5/5 Drivers: Staging: ft1000: checkpatch.pl header file warning fix
In reply to Janakarajan NatarajanReplaces <asm/io.h> and <asm/bitops.h> with <linux/io.h> and <linux/bitops.h>
--- drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/ft1000/ft1000-pcmcia/ft1000_hw.c +2 -2
@@ -28,8 +28,8 @@#include <linux/timer.h> #include <linux/interrupt.h> #include <linux/in.h> -#include <asm/io.h> -#include <asm/bitops.h> +#include <linux/io.h> +#include <linux/bitops.h> #include <linux/netdevice.h> #include <linux/etherdevice.h>
Signature · 6 lines
1.9.1 --- This email has been checked for viruses by Avast antivirus software. http://www.avast.com