Re: [patch 07/22] NET: DM9000: Use msleep() instead of udelay()

2007-12-07 Thread Ben Dooks
On Fri, Nov 23, 2007 at 08:39:45PM -0500, Jeff Garzik wrote:
 are you sure you cannot sleep during suspend?

Yes. This is not the first driver that has had this problem,
see the sm501 as another example.

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
--
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 07/22] NET: DM9000: Use msleep() instead of udelay()

2007-11-23 Thread Jeff Garzik

are you sure you cannot sleep during suspend?

-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[patch 07/22] NET: DM9000: Use msleep() instead of udelay()

2007-11-19 Thread Ben Dooks
We can use sleeping functions when reading and writing the
PHY registers, so let us sleep instead of busy waiting for
the PHY.

Note, this also fixes a bug reading the PHY where only 100uS
was being used instead of 150uS

Signed-off-by: Ben Dooks [EMAIL PROTECTED]

Index: linux-2.6.23-quilt3/drivers/net/dm9000.c
===
--- linux-2.6.23-quilt3.orig/drivers/net/dm9000.c
+++ linux-2.6.23-quilt3/drivers/net/dm9000.c
@@ -114,6 +114,7 @@ typedef struct board_info {
u8 io_mode; /* 0:word, 2:byte */
u8 phy_addr;
unsigned int flags;
+   unsigned int in_suspend :1;
 
int debug_level;
 
@@ -1174,6 +1175,18 @@ dm9000_hash_table(struct net_device *dev
 
 
 /*
+ * Sleep, either by using msleep() or if we are suspending, then
+ * use mdelay() to sleep.
+ */
+static void dm9000_msleep(board_info_t *db, unsigned int ms)
+{
+   if (db-in_suspend)
+   mdelay(ms);
+   else
+   msleep(ms);
+}
+
+/*
  *   Read a word from phyxcer
  */
 static int
@@ -1197,7 +1210,7 @@ dm9000_phy_read(struct net_device *dev, 
writeb(reg_save, db-io_addr);
spin_unlock_irqrestore(db-lock,flags);
 
-   udelay(100);/* Wait read complete */
+   dm9000_msleep(db, 1);   /* Wait read complete */
 
spin_lock_irqsave(db-lock,flags);
reg_save = readb(db-io_addr);
@@ -1241,7 +1254,7 @@ dm9000_phy_write(struct net_device *dev,
writeb(reg_save, db-io_addr);
spin_unlock_irqrestore(db-lock,flags);
 
-   udelay(500);/* Wait write complete */
+   dm9000_msleep(db, 1);   /* Wait write complete */
 
spin_lock_irqsave(db-lock,flags);
reg_save = readb(db-io_addr);
@@ -1258,8 +1271,12 @@ static int
 dm9000_drv_suspend(struct platform_device *dev, pm_message_t state)
 {
struct net_device *ndev = platform_get_drvdata(dev);
+   board_info_t *db;
 
if (ndev) {
+   db = (board_info_t *) ndev-priv;
+   db-in_suspend = 1;
+
if (netif_running(ndev)) {
netif_device_detach(ndev);
dm9000_shutdown(ndev);
@@ -1282,6 +1299,8 @@ dm9000_drv_resume(struct platform_device
 
netif_device_attach(ndev);
}
+
+   db-in_suspend = 0;
}
return 0;
 }

-- 
Ben ([EMAIL PROTECTED], http://www.fluff.org/)

  'a smiley only costs 4 bytes'
-
To unsubscribe from this list: send the line unsubscribe netdev in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html