Skip to contentSkip to conversation

Drivers: Staging: ft1000: checkpatch warning fixes

PATCH In review Janakarajan Natarajan 3 participants 9 messages Mar 11, 2015 – Mar 13, 2015 Staging

lore
Share & tools
lore
#0 lore raw

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
index 017c3b9..a01b9e3 100644
@@ -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
index c8d2782..bd0d25c 100644
@@ -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
#1 lore raw
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
---
 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
index 017c3b9..a01b9e3 100644
@@ -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 -0
 	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 +0 -0
index c8d2782..bd0d25c 100644

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
#2 lore raw
In reply to Janakarajan Natarajan
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);
#3 lore raw

v2 cover ft1000 driver checkpatch.pl fixes

In reply to Janakarajan Natarajan

Minor 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
#4 lore raw

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
index c8d2782..8fb0f5a 100644
@@ -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
#5 lore raw

PATCH v2 2/5 Drivers: Staging: ft1000: Fix extra parenthesis warnings

In reply to Janakarajan Natarajan

Minor 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
index 017c3b9..d4006a4 100644
@@ -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
index 8fb0f5a..8c1e5fc 100644
@@ -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
#6 lore raw

PATCH v2 3/5 Drivers: Staging: ft1000: Refactoring if-else statement

In reply to Janakarajan Natarajan

Minor 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
index d4006a4..973bfbf 100644
@@ -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
#7 lore raw

PATCH v2 4/5 Drivers: Staging: ft1000: Fix blank line warning

In reply to Janakarajan Natarajan

Merges 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
index 973bfbf..b43a6fd 100644
@@ -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
#8 lore raw

PATCH v2 5/5 Drivers: Staging: ft1000: checkpatch.pl header file warning fix

In reply to Janakarajan Natarajan

Replaces <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
index b43a6fd..a93eaf5 100644
@@ -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