aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Dooks <ben-linux@fluff.org>2008-02-04 19:02:08 -0500
committerJeff Garzik <jeff@garzik.org>2008-02-11 11:06:27 -0500
commit321f69a4c3bb807abdf1fd6329403ec0449a3d78 (patch)
tree618d05ce1be64489a787200f93cd73fa65138d0e
parent89c8b0e6cd3859a6445398c5aa94ebd21d0e64ce (diff)
DM9000: Use msleep() instead of udelay()
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 <ben-linux@fluff.org> Signed-off-by: Jeff Garzik <jeff@garzik.org>
-rw-r--r--drivers/net/dm9000.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c
index 071aad1af577..2e0add074889 100644
--- a/drivers/net/dm9000.c
+++ b/drivers/net/dm9000.c
@@ -116,6 +116,7 @@ typedef struct board_info {
116 u8 io_mode; /* 0:word, 2:byte */ 116 u8 io_mode; /* 0:word, 2:byte */
117 u8 phy_addr; 117 u8 phy_addr;
118 unsigned int flags; 118 unsigned int flags;
119 unsigned int in_suspend :1;
119 120
120 int debug_level; 121 int debug_level;
121 122
@@ -1108,6 +1109,18 @@ dm9000_hash_table(struct net_device *dev)
1108 1109
1109 1110
1110/* 1111/*
1112 * Sleep, either by using msleep() or if we are suspending, then
1113 * use mdelay() to sleep.
1114 */
1115static void dm9000_msleep(board_info_t *db, unsigned int ms)
1116{
1117 if (db->in_suspend)
1118 mdelay(ms);
1119 else
1120 msleep(ms);
1121}
1122
1123/*
1111 * Read a word from phyxcer 1124 * Read a word from phyxcer
1112 */ 1125 */
1113static int 1126static int
@@ -1131,7 +1144,7 @@ dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
1131 writeb(reg_save, db->io_addr); 1144 writeb(reg_save, db->io_addr);
1132 spin_unlock_irqrestore(&db->lock,flags); 1145 spin_unlock_irqrestore(&db->lock,flags);
1133 1146
1134 udelay(100); /* Wait read complete */ 1147 dm9000_msleep(db, 1); /* Wait read complete */
1135 1148
1136 spin_lock_irqsave(&db->lock,flags); 1149 spin_lock_irqsave(&db->lock,flags);
1137 reg_save = readb(db->io_addr); 1150 reg_save = readb(db->io_addr);
@@ -1175,7 +1188,7 @@ dm9000_phy_write(struct net_device *dev, int phyaddr_unused, int reg, int value)
1175 writeb(reg_save, db->io_addr); 1188 writeb(reg_save, db->io_addr);
1176 spin_unlock_irqrestore(&db->lock,flags); 1189 spin_unlock_irqrestore(&db->lock,flags);
1177 1190
1178 udelay(500); /* Wait write complete */ 1191 dm9000_msleep(db, 1); /* Wait write complete */
1179 1192
1180 spin_lock_irqsave(&db->lock,flags); 1193 spin_lock_irqsave(&db->lock,flags);
1181 reg_save = readb(db->io_addr); 1194 reg_save = readb(db->io_addr);
@@ -1192,8 +1205,12 @@ static int
1192dm9000_drv_suspend(struct platform_device *dev, pm_message_t state) 1205dm9000_drv_suspend(struct platform_device *dev, pm_message_t state)
1193{ 1206{
1194 struct net_device *ndev = platform_get_drvdata(dev); 1207 struct net_device *ndev = platform_get_drvdata(dev);
1208 board_info_t *db;
1195 1209
1196 if (ndev) { 1210 if (ndev) {
1211 db = (board_info_t *) ndev->priv;
1212 db->in_suspend = 1;
1213
1197 if (netif_running(ndev)) { 1214 if (netif_running(ndev)) {
1198 netif_device_detach(ndev); 1215 netif_device_detach(ndev);
1199 dm9000_shutdown(ndev); 1216 dm9000_shutdown(ndev);
@@ -1216,6 +1233,8 @@ dm9000_drv_resume(struct platform_device *dev)
1216 1233
1217 netif_device_attach(ndev); 1234 netif_device_attach(ndev);
1218 } 1235 }
1236
1237 db->in_suspend = 0;
1219 } 1238 }
1220 return 0; 1239 return 0;
1221} 1240}