diff mbox

[1/5] tg3: use usleep_range not msleep for small sleeps

Message ID 1298999069-12740-2-git-send-email-martinez.javier@gmail.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Javier Martinez Canillas March 1, 2011, 5:04 p.m. UTC
Signed-off-by: Javier Martinez Canillas <martinez.javier@gmail.com>
---
 drivers/net/tg3.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

Comments

David Miller March 3, 2011, 4:55 a.m. UTC | #1
From: Javier Martinez Canillas <martinez.javier@gmail.com>
Date: Tue,  1 Mar 2011 18:04:26 +0100

> 
> Signed-off-by: Javier Martinez Canillas <martinez.javier@gmail.com>

Why?
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Javier Martinez Canillas March 3, 2011, 12:14 p.m. UTC | #2
>
>>
>> Signed-off-by: Javier Martinez Canillas <martinez.javier@gmail.com>
>
> Why?
>

As I understand msleep() will stop for a minimum of two jiffies and
that resolution is too low in systems with small HZ values (big
jiffies).
Using msleep() (with small values) in this systems will sleep for more
time than the caller expects.

I used usleep_range() because it is a finer precision implementations of msleep.

Sorry if I'm wrong or the sleep precision is not a concern in this
driver and the change doesn't add any value.

Thanks a lot.
diff mbox

Patch

diff --git a/drivers/net/tg3.c b/drivers/net/tg3.c
index 6be4185..3310c7a 100644
--- a/drivers/net/tg3.c
+++ b/drivers/net/tg3.c
@@ -2410,7 +2410,7 @@  static int tg3_nvram_read_using_eeprom(struct tg3 *tp,
 
 		if (tmp & EEPROM_ADDR_COMPLETE)
 			break;
-		msleep(1);
+		usleep_range(1000, 2000);
 	}
 	if (!(tmp & EEPROM_ADDR_COMPLETE))
 		return -EBUSY;
@@ -2688,7 +2688,7 @@  static int tg3_power_down_prepare(struct tg3 *tp)
 			tg3_read_mem(tp, NIC_SRAM_FW_ASF_STATUS_MBOX, &val);
 			if (val == ~NIC_SRAM_FIRMWARE_MBOX_MAGIC1)
 				break;
-			msleep(1);
+			usleep_range(1000, 2000);
 		}
 	}
 	if (tp->tg3_flags & TG3_FLAG_WOL_CAP)
@@ -8901,7 +8901,7 @@  static int tg3_test_interrupt(struct tg3 *tp)
 			break;
 		}
 
-		msleep(10);
+		usleep_range(10000, 20000);
 	}
 
 	tg3_disable_ints(tp);
@@ -11863,7 +11863,7 @@  static void __devinit tg3_nvram_init(struct tg3 *tp)
 	      (EEPROM_DEFAULT_CLOCK_PERIOD <<
 	       EEPROM_ADDR_CLKPERD_SHIFT)));
 
-	msleep(1);
+	usleep_range(1000, 2000);
 
 	/* Enable seeprom accesses. */
 	tw32_f(GRC_LOCAL_CTRL,
@@ -11956,7 +11956,7 @@  static int tg3_nvram_write_block_using_eeprom(struct tg3 *tp,
 
 			if (val & EEPROM_ADDR_COMPLETE)
 				break;
-			msleep(1);
+			usleep_range(1000, 2000);
 		}
 		if (!(val & EEPROM_ADDR_COMPLETE)) {
 			rc = -EBUSY;
@@ -12263,7 +12263,7 @@  static void __devinit tg3_get_eeprom_hw_cfg(struct tg3 *tp)
 	pci_read_config_word(tp->pdev, tp->pm_cap + PCI_PM_CTRL, &pmcsr);
 	pmcsr &= ~PCI_PM_CTRL_STATE_MASK;
 	pci_write_config_word(tp->pdev, tp->pm_cap + PCI_PM_CTRL, pmcsr);
-	msleep(1);
+	usleep_range(1000, 2000);
 
 	/* Make sure register accesses (indirect or otherwise)
 	 * will function correctly.