Skip to contentSkip to conversation

staging: ft1000: remove unused variables

PATCH In review Sudip Mukherjee 2 participants 6 messages Mar 7, 2015 – Mar 17, 2015 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 staging: ft1000: remove unused variables

these variables were assigned some values but they were never being reused again.

---

this patch will generate some checkpatch warning about line being above 80char, but the code is so much indented that it is difficult to break the line.

 drivers/staging/ft1000/ft1000-usb/ft1000_debug.c   | 14 ++--
 .../staging/ft1000/ft1000-usb/ft1000_download.c    | 92 +++++++++++-----------
 2 files changed, 50 insertions(+), 56 deletions(-)
drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +6 -8
index 58ad946..86dd699 100644
@@ -297,14 +297,13 @@ void ft1000_destroy_dev(struct net_device *netdev)
  */
 static int ft1000_open(struct inode *inode, struct file *file)
 {
-	struct ft1000_info *info;
 	struct ft1000_usb *dev = (struct ft1000_usb *)inode->i_private;
 	int i, num;
 
 	num = (MINOR(inode->i_rdev) & 0xf);
 	pr_debug("minor number=%d\n", num);
 
-	info = file->private_data = netdev_priv(dev->net);
+	file->private_data = netdev_priv(dev->net);
 
 	pr_debug("f_owner = %p number of application = %d\n",
 		 &file->f_owner, dev->appcnt);
@@ -528,7 +527,6 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
 		u16 *pmsg;
 		u16 total_len;
 		u16 app_index;
-		u16 status;
 
 		/* pr_debug("IOCTL_FT1000_SET_DPRAM called\n");*/
 
@@ -590,22 +588,22 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
 				} else {
 					/* Put message into Slow Queue */
 					/* Only put a message into the DPRAM if msg doorbell is available */
-					status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
+					ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
 					/* pr_debug("READ REGISTER tempword=%x\n", tempword); */
 					if (tempword & FT1000_DB_DPRAM_TX) {
 						/* Suspend for 2ms and try again due to DSP doorbell busy */
 						mdelay(2);
-						status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
+						ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
 						if (tempword & FT1000_DB_DPRAM_TX) {
 							/* Suspend for 1ms and try again due to DSP doorbell busy */
 							mdelay(1);
-							status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
+							ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
 							if (tempword & FT1000_DB_DPRAM_TX) {
-								status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
+								ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
 								if (tempword & FT1000_DB_DPRAM_TX) {
 									/* Suspend for 3ms and try again due to DSP doorbell busy */
 									mdelay(3);
-									status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
+									ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
 									if (tempword & FT1000_DB_DPRAM_TX) {
 										pr_debug("Doorbell not available\n");
 										result = -ENOTTY;
drivers/staging/ft1000/ft1000-usb/ft1000_download.c +44 -48

193 lines not on this page · raw message

Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 2/2 staging: ft1000: remove code indention

modified the code to keep the logic same but removed some indention.

---

this patch will generate checkpatch warning about line more than 80char, and too many use of tab. but unless the total function is rewrtten it will be difficult to fix that.

 drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 44 +++++++++++-------------
 1 file changed, 21 insertions(+), 23 deletions(-)
drivers/staging/ft1000/ft1000-usb/ft1000_debug.c +21 -23
index 86dd699..584c59a 100644
@@ -587,32 +587,30 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
 				if (qtype) {
 				} else {
 					/* Put message into Slow Queue */
-					/* Only put a message into the DPRAM if msg doorbell is available */
-					ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
-					/* pr_debug("READ REGISTER tempword=%x\n", tempword); */
-					if (tempword & FT1000_DB_DPRAM_TX) {
-						/* Suspend for 2ms and try again due to DSP doorbell busy */
-						mdelay(2);
+					u8 cnt = 0;
+
+					do {
+						/* Only put a message into the DPRAM if msg doorbell is available */
 						ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
+						/* pr_debug("READ REGISTER tempword=%x\n", tempword); */
 						if (tempword & FT1000_DB_DPRAM_TX) {
+							/* Suspend for 2ms and try again due to DSP doorbell busy */
+							if (cnt == 0)
+								mdelay(2);
 							/* Suspend for 1ms and try again due to DSP doorbell busy */
-							mdelay(1);
-							ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
-							if (tempword & FT1000_DB_DPRAM_TX) {
-								ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
-								if (tempword & FT1000_DB_DPRAM_TX) {
-									/* Suspend for 3ms and try again due to DSP doorbell busy */
-									mdelay(3);
-									ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
-									if (tempword & FT1000_DB_DPRAM_TX) {
-										pr_debug("Doorbell not available\n");
-										result = -ENOTTY;
-										kfree(dpram_data);
-										break;
-									}
-								}
-							}
-						}
+							else if (cnt == 1)
+								mdelay(1);
+							/* Suspend for 3ms and try again due to DSP doorbell busy */
+							else
+								mdelay(3);
+						} else
+							break;
+					} while (++cnt < 3);
+					if (tempword & FT1000_DB_DPRAM_TX) {
+						pr_debug("Doorbell not available\n");
+						result = -ENOTTY;
+						kfree(dpram_data);
+						break;
 					}
 
 					/*pr_debug("finished reading register\n"); */
Signature · 1 line
1.8.1.2
#2 lore raw

Re: [PATCH 2/2] staging: ft1000: remove code indention

Quoted 11 lines · Sudip Mukherjee

modified the code to keep the logic same but removed some indention.

---

this patch will generate checkpatch warning about line more than 80char, and too many use of tab. but unless the total function is rewrtten it will be difficult to fix that.

 drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 44 +++++++++++-------------
 1 file changed, 21 insertions(+), 23 deletions(-)

I don't see how this looks any better, do you?

#3 lore raw

Re: [PATCH 2/2] staging: ft1000: remove code indention

Quoted 6 lines · Greg Kroah-Hartman
Quoted 5 lines · Sudip Mukherjee

modified the code to keep the logic same but removed some indention.

---

Quoted 8 lines
Quoted 6 lines

this patch will generate checkpatch warning about line more than 80char, and too many use of tab. but unless the total function is rewrtten it will be difficult to fix that.

 drivers/staging/ft1000/ft1000-usb/ft1000_debug.c | 44 +++++++++++-------------
 1 file changed, 21 insertions(+), 23 deletions(-)

I don't see how this looks any better, do you?

well, better in the sense very little indention was fixed and code which was repeating in if-else if - else was placed in a loop, but a small if-else was still there for the different delay between retries. I will see if i can make it more better.

regards
sudip

maintainer
#4 lore raw
In reply to Sudip Mukherjee
Quoted 2 lines · Sudip Mukherjee

these variables were assigned some values but they were never being reused again.

But some of them should have been checked, right? Or, if no one cares, fix up the function to not return anything, like for all of the read_register() calls.

Please do that instead.

thanks,

greg k-h

#5 lore raw
Quoted 9 lines · Greg KH
Quoted 2 lines · Sudip Mukherjee

these variables were assigned some values but they were never being reused again.

But some of them should have been checked, right? Or, if no one cares, fix up the function to not return anything, like for all of the read_register() calls.

Please do that instead.

but the return value of ft1000_read_register() is being used in some places like card_send_command() or in ft1000_ioctl(). we can use the return value (if error) in the poll() or ioctl() instead of returning -1 or -ENOTTY. but in the other places, its - no one cares.

regards
sudip

Quoted 4 lines

thanks,

greg k-h