diff options
author | Joe Perches <joe@perches.com> | 2009-05-31 16:44:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-06-01 06:13:12 -0400 |
commit | c930a66220bac0815cca74eef94ada221377ffba (patch) | |
tree | 1b25e54ceee6f6208b2d8d498ef56508715e3732 /drivers/net/atl1c/atl1c_main.c | |
parent | 56d417b12e57dfe11c9b7ba4bea3882c62a55815 (diff) |
atl1c_main.c: add wait_for_idle routine
Slight refactoring of duplicated wait for idle checks
Spelling fix
Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: jie.yang@atheros.com
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/atl1c/atl1c_main.c')
-rw-r--r-- | drivers/net/atl1c/atl1c_main.c | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/drivers/net/atl1c/atl1c_main.c b/drivers/net/atl1c/atl1c_main.c index ac76136d70f9..cd547a205fb9 100644 --- a/drivers/net/atl1c/atl1c_main.c +++ b/drivers/net/atl1c/atl1c_main.c | |||
@@ -164,6 +164,24 @@ static inline void atl1c_irq_reset(struct atl1c_adapter *adapter) | |||
164 | } | 164 | } |
165 | 165 | ||
166 | /* | 166 | /* |
167 | * atl1c_wait_until_idle - wait up to AT_HW_MAX_IDLE_DELAY reads | ||
168 | * of the idle status register until the device is actually idle | ||
169 | */ | ||
170 | static u32 atl1c_wait_until_idle(struct atl1c_hw *hw) | ||
171 | { | ||
172 | int timeout; | ||
173 | u32 data; | ||
174 | |||
175 | for (timeout = 0; timeout < AT_HW_MAX_IDLE_DELAY; timeout++) { | ||
176 | AT_READ_REG(hw, REG_IDLE_STATUS, &data); | ||
177 | if ((data & IDLE_STATUS_MASK) == 0) | ||
178 | return 0; | ||
179 | msleep(1); | ||
180 | } | ||
181 | return data; | ||
182 | } | ||
183 | |||
184 | /* | ||
167 | * atl1c_phy_config - Timer Call-back | 185 | * atl1c_phy_config - Timer Call-back |
168 | * @data: pointer to netdev cast into an unsigned long | 186 | * @data: pointer to netdev cast into an unsigned long |
169 | */ | 187 | */ |
@@ -1106,7 +1124,6 @@ static void atl1c_configure_dma(struct atl1c_adapter *adapter) | |||
1106 | static int atl1c_stop_mac(struct atl1c_hw *hw) | 1124 | static int atl1c_stop_mac(struct atl1c_hw *hw) |
1107 | { | 1125 | { |
1108 | u32 data; | 1126 | u32 data; |
1109 | int timeout; | ||
1110 | 1127 | ||
1111 | AT_READ_REG(hw, REG_RXQ_CTRL, &data); | 1128 | AT_READ_REG(hw, REG_RXQ_CTRL, &data); |
1112 | data &= ~(RXQ1_CTRL_EN | RXQ2_CTRL_EN | | 1129 | data &= ~(RXQ1_CTRL_EN | RXQ2_CTRL_EN | |
@@ -1117,25 +1134,13 @@ static int atl1c_stop_mac(struct atl1c_hw *hw) | |||
1117 | data &= ~TXQ_CTRL_EN; | 1134 | data &= ~TXQ_CTRL_EN; |
1118 | AT_WRITE_REG(hw, REG_TWSI_CTRL, data); | 1135 | AT_WRITE_REG(hw, REG_TWSI_CTRL, data); |
1119 | 1136 | ||
1120 | for (timeout = 0; timeout < AT_HW_MAX_IDLE_DELAY; timeout++) { | 1137 | atl1c_wait_until_idle(hw); |
1121 | AT_READ_REG(hw, REG_IDLE_STATUS, &data); | ||
1122 | if ((data & (IDLE_STATUS_RXQ_NO_IDLE | | ||
1123 | IDLE_STATUS_TXQ_NO_IDLE)) == 0) | ||
1124 | break; | ||
1125 | msleep(1); | ||
1126 | } | ||
1127 | 1138 | ||
1128 | AT_READ_REG(hw, REG_MAC_CTRL, &data); | 1139 | AT_READ_REG(hw, REG_MAC_CTRL, &data); |
1129 | data &= ~(MAC_CTRL_TX_EN | MAC_CTRL_RX_EN); | 1140 | data &= ~(MAC_CTRL_TX_EN | MAC_CTRL_RX_EN); |
1130 | AT_WRITE_REG(hw, REG_MAC_CTRL, data); | 1141 | AT_WRITE_REG(hw, REG_MAC_CTRL, data); |
1131 | 1142 | ||
1132 | for (timeout = 0; timeout < AT_HW_MAX_IDLE_DELAY; timeout++) { | 1143 | return (int)atl1c_wait_until_idle(hw); |
1133 | AT_READ_REG(hw, REG_IDLE_STATUS, &data); | ||
1134 | if ((data & IDLE_STATUS_MASK) == 0) | ||
1135 | return 0; | ||
1136 | msleep(1); | ||
1137 | } | ||
1138 | return data; | ||
1139 | } | 1144 | } |
1140 | 1145 | ||
1141 | static void atl1c_enable_rx_ctrl(struct atl1c_hw *hw) | 1146 | static void atl1c_enable_rx_ctrl(struct atl1c_hw *hw) |
@@ -1178,8 +1183,6 @@ static int atl1c_reset_mac(struct atl1c_hw *hw) | |||
1178 | { | 1183 | { |
1179 | struct atl1c_adapter *adapter = (struct atl1c_adapter *)hw->adapter; | 1184 | struct atl1c_adapter *adapter = (struct atl1c_adapter *)hw->adapter; |
1180 | struct pci_dev *pdev = adapter->pdev; | 1185 | struct pci_dev *pdev = adapter->pdev; |
1181 | u32 idle_status_data = 0; | ||
1182 | int timeout = 0; | ||
1183 | int ret; | 1186 | int ret; |
1184 | 1187 | ||
1185 | AT_WRITE_REG(hw, REG_IMR, 0); | 1188 | AT_WRITE_REG(hw, REG_IMR, 0); |
@@ -1198,15 +1201,10 @@ static int atl1c_reset_mac(struct atl1c_hw *hw) | |||
1198 | AT_WRITE_FLUSH(hw); | 1201 | AT_WRITE_FLUSH(hw); |
1199 | msleep(10); | 1202 | msleep(10); |
1200 | /* Wait at least 10ms for All module to be Idle */ | 1203 | /* Wait at least 10ms for All module to be Idle */ |
1201 | for (timeout = 0; timeout < AT_HW_MAX_IDLE_DELAY; timeout++) { | 1204 | |
1202 | AT_READ_REG(hw, REG_IDLE_STATUS, &idle_status_data); | 1205 | if (atl1c_wait_until_idle(hw)) { |
1203 | if ((idle_status_data & IDLE_STATUS_MASK) == 0) | ||
1204 | break; | ||
1205 | msleep(1); | ||
1206 | } | ||
1207 | if (timeout >= AT_HW_MAX_IDLE_DELAY) { | ||
1208 | dev_err(&pdev->dev, | 1206 | dev_err(&pdev->dev, |
1209 | "MAC state machine cann't be idle since" | 1207 | "MAC state machine can't be idle since" |
1210 | " disabled for 10ms second\n"); | 1208 | " disabled for 10ms second\n"); |
1211 | return -1; | 1209 | return -1; |
1212 | } | 1210 | } |