diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2007-11-02 01:55:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:03:33 -0500 |
commit | eb76bf29dd4aceaf877b8971fbfda8617abe6e05 (patch) | |
tree | ee31031ee47e84fbaae478e9a075b6ad28577937 /drivers/net/wireless | |
parent | 1b34fd390c340b0554dcda9552f82d77dff8ed23 (diff) |
P54: use temporary variables to reduce size of generated code
When there are 2 linked structures, using a temporary variable to hold a pointer
to the often used structure usually produces better code (smaller and faster)
since compiler does not have to constantly re-fetch data from the first structure.
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/p54pci.c | 77 |
1 files changed, 41 insertions, 36 deletions
diff --git a/drivers/net/wireless/p54pci.c b/drivers/net/wireless/p54pci.c index 410b54387f23..b7a3bde0b66d 100644 --- a/drivers/net/wireless/p54pci.c +++ b/drivers/net/wireless/p54pci.c | |||
@@ -141,6 +141,7 @@ static irqreturn_t p54p_simple_interrupt(int irq, void *dev_id) | |||
141 | static int p54p_read_eeprom(struct ieee80211_hw *dev) | 141 | static int p54p_read_eeprom(struct ieee80211_hw *dev) |
142 | { | 142 | { |
143 | struct p54p_priv *priv = dev->priv; | 143 | struct p54p_priv *priv = dev->priv; |
144 | struct p54p_ring_control *ring_control = priv->ring_control; | ||
144 | int err; | 145 | int err; |
145 | struct p54_control_hdr *hdr; | 146 | struct p54_control_hdr *hdr; |
146 | void *eeprom; | 147 | void *eeprom; |
@@ -164,7 +165,7 @@ static int p54p_read_eeprom(struct ieee80211_hw *dev) | |||
164 | goto out; | 165 | goto out; |
165 | } | 166 | } |
166 | 167 | ||
167 | memset(priv->ring_control, 0, sizeof(*priv->ring_control)); | 168 | memset(ring_control, 0, sizeof(*ring_control)); |
168 | P54P_WRITE(ring_control_base, priv->ring_control_dma); | 169 | P54P_WRITE(ring_control_base, priv->ring_control_dma); |
169 | P54P_READ(ring_control_base); | 170 | P54P_READ(ring_control_base); |
170 | udelay(10); | 171 | udelay(10); |
@@ -194,14 +195,14 @@ static int p54p_read_eeprom(struct ieee80211_hw *dev) | |||
194 | tx_mapping = pci_map_single(priv->pdev, (void *)hdr, | 195 | tx_mapping = pci_map_single(priv->pdev, (void *)hdr, |
195 | EEPROM_READBACK_LEN, PCI_DMA_TODEVICE); | 196 | EEPROM_READBACK_LEN, PCI_DMA_TODEVICE); |
196 | 197 | ||
197 | priv->ring_control->rx_mgmt[0].host_addr = cpu_to_le32(rx_mapping); | 198 | ring_control->rx_mgmt[0].host_addr = cpu_to_le32(rx_mapping); |
198 | priv->ring_control->rx_mgmt[0].len = cpu_to_le16(0x2010); | 199 | ring_control->rx_mgmt[0].len = cpu_to_le16(0x2010); |
199 | priv->ring_control->tx_data[0].host_addr = cpu_to_le32(tx_mapping); | 200 | ring_control->tx_data[0].host_addr = cpu_to_le32(tx_mapping); |
200 | priv->ring_control->tx_data[0].device_addr = hdr->req_id; | 201 | ring_control->tx_data[0].device_addr = hdr->req_id; |
201 | priv->ring_control->tx_data[0].len = cpu_to_le16(EEPROM_READBACK_LEN); | 202 | ring_control->tx_data[0].len = cpu_to_le16(EEPROM_READBACK_LEN); |
202 | 203 | ||
203 | priv->ring_control->host_idx[2] = cpu_to_le32(1); | 204 | ring_control->host_idx[2] = cpu_to_le32(1); |
204 | priv->ring_control->host_idx[1] = cpu_to_le32(1); | 205 | ring_control->host_idx[1] = cpu_to_le32(1); |
205 | 206 | ||
206 | wmb(); | 207 | wmb(); |
207 | mdelay(100); | 208 | mdelay(100); |
@@ -215,8 +216,8 @@ static int p54p_read_eeprom(struct ieee80211_hw *dev) | |||
215 | pci_unmap_single(priv->pdev, rx_mapping, | 216 | pci_unmap_single(priv->pdev, rx_mapping, |
216 | 0x2010, PCI_DMA_FROMDEVICE); | 217 | 0x2010, PCI_DMA_FROMDEVICE); |
217 | 218 | ||
218 | alen = le16_to_cpu(priv->ring_control->rx_mgmt[0].len); | 219 | alen = le16_to_cpu(ring_control->rx_mgmt[0].len); |
219 | if (le32_to_cpu(priv->ring_control->device_idx[2]) != 1 || | 220 | if (le32_to_cpu(ring_control->device_idx[2]) != 1 || |
220 | alen < 0x10) { | 221 | alen < 0x10) { |
221 | printk(KERN_ERR "%s (prism54pci): Cannot read eeprom!\n", | 222 | printk(KERN_ERR "%s (prism54pci): Cannot read eeprom!\n", |
222 | pci_name(priv->pdev)); | 223 | pci_name(priv->pdev)); |
@@ -239,16 +240,17 @@ static int p54p_read_eeprom(struct ieee80211_hw *dev) | |||
239 | static void p54p_refill_rx_ring(struct ieee80211_hw *dev) | 240 | static void p54p_refill_rx_ring(struct ieee80211_hw *dev) |
240 | { | 241 | { |
241 | struct p54p_priv *priv = dev->priv; | 242 | struct p54p_priv *priv = dev->priv; |
243 | struct p54p_ring_control *ring_control = priv->ring_control; | ||
242 | u32 limit, host_idx, idx; | 244 | u32 limit, host_idx, idx; |
243 | 245 | ||
244 | host_idx = le32_to_cpu(priv->ring_control->host_idx[0]); | 246 | host_idx = le32_to_cpu(ring_control->host_idx[0]); |
245 | limit = host_idx; | 247 | limit = host_idx; |
246 | limit -= le32_to_cpu(priv->ring_control->device_idx[0]); | 248 | limit -= le32_to_cpu(ring_control->device_idx[0]); |
247 | limit = ARRAY_SIZE(priv->ring_control->rx_data) - limit; | 249 | limit = ARRAY_SIZE(ring_control->rx_data) - limit; |
248 | 250 | ||
249 | idx = host_idx % ARRAY_SIZE(priv->ring_control->rx_data); | 251 | idx = host_idx % ARRAY_SIZE(ring_control->rx_data); |
250 | while (limit-- > 1) { | 252 | while (limit-- > 1) { |
251 | struct p54p_desc *desc = &priv->ring_control->rx_data[idx]; | 253 | struct p54p_desc *desc = &ring_control->rx_data[idx]; |
252 | 254 | ||
253 | if (!desc->host_addr) { | 255 | if (!desc->host_addr) { |
254 | struct sk_buff *skb; | 256 | struct sk_buff *skb; |
@@ -270,17 +272,18 @@ static void p54p_refill_rx_ring(struct ieee80211_hw *dev) | |||
270 | 272 | ||
271 | idx++; | 273 | idx++; |
272 | host_idx++; | 274 | host_idx++; |
273 | idx %= ARRAY_SIZE(priv->ring_control->rx_data); | 275 | idx %= ARRAY_SIZE(ring_control->rx_data); |
274 | } | 276 | } |
275 | 277 | ||
276 | wmb(); | 278 | wmb(); |
277 | priv->ring_control->host_idx[0] = cpu_to_le32(host_idx); | 279 | ring_control->host_idx[0] = cpu_to_le32(host_idx); |
278 | } | 280 | } |
279 | 281 | ||
280 | static irqreturn_t p54p_interrupt(int irq, void *dev_id) | 282 | static irqreturn_t p54p_interrupt(int irq, void *dev_id) |
281 | { | 283 | { |
282 | struct ieee80211_hw *dev = dev_id; | 284 | struct ieee80211_hw *dev = dev_id; |
283 | struct p54p_priv *priv = dev->priv; | 285 | struct p54p_priv *priv = dev->priv; |
286 | struct p54p_ring_control *ring_control = priv->ring_control; | ||
284 | __le32 reg; | 287 | __le32 reg; |
285 | 288 | ||
286 | spin_lock(&priv->lock); | 289 | spin_lock(&priv->lock); |
@@ -298,12 +301,12 @@ static irqreturn_t p54p_interrupt(int irq, void *dev_id) | |||
298 | struct p54p_desc *desc; | 301 | struct p54p_desc *desc; |
299 | u32 idx, i; | 302 | u32 idx, i; |
300 | i = priv->tx_idx; | 303 | i = priv->tx_idx; |
301 | i %= ARRAY_SIZE(priv->ring_control->tx_data); | 304 | i %= ARRAY_SIZE(ring_control->tx_data); |
302 | priv->tx_idx = idx = le32_to_cpu(priv->ring_control->device_idx[1]); | 305 | priv->tx_idx = idx = le32_to_cpu(ring_control->device_idx[1]); |
303 | idx %= ARRAY_SIZE(priv->ring_control->tx_data); | 306 | idx %= ARRAY_SIZE(ring_control->tx_data); |
304 | 307 | ||
305 | while (i != idx) { | 308 | while (i != idx) { |
306 | desc = &priv->ring_control->tx_data[i]; | 309 | desc = &ring_control->tx_data[i]; |
307 | if (priv->tx_buf[i]) { | 310 | if (priv->tx_buf[i]) { |
308 | kfree(priv->tx_buf[i]); | 311 | kfree(priv->tx_buf[i]); |
309 | priv->tx_buf[i] = NULL; | 312 | priv->tx_buf[i] = NULL; |
@@ -318,17 +321,17 @@ static irqreturn_t p54p_interrupt(int irq, void *dev_id) | |||
318 | desc->flags = 0; | 321 | desc->flags = 0; |
319 | 322 | ||
320 | i++; | 323 | i++; |
321 | i %= ARRAY_SIZE(priv->ring_control->tx_data); | 324 | i %= ARRAY_SIZE(ring_control->tx_data); |
322 | } | 325 | } |
323 | 326 | ||
324 | i = priv->rx_idx; | 327 | i = priv->rx_idx; |
325 | i %= ARRAY_SIZE(priv->ring_control->rx_data); | 328 | i %= ARRAY_SIZE(ring_control->rx_data); |
326 | priv->rx_idx = idx = le32_to_cpu(priv->ring_control->device_idx[0]); | 329 | priv->rx_idx = idx = le32_to_cpu(ring_control->device_idx[0]); |
327 | idx %= ARRAY_SIZE(priv->ring_control->rx_data); | 330 | idx %= ARRAY_SIZE(ring_control->rx_data); |
328 | while (i != idx) { | 331 | while (i != idx) { |
329 | u16 len; | 332 | u16 len; |
330 | struct sk_buff *skb; | 333 | struct sk_buff *skb; |
331 | desc = &priv->ring_control->rx_data[i]; | 334 | desc = &ring_control->rx_data[i]; |
332 | len = le16_to_cpu(desc->len); | 335 | len = le16_to_cpu(desc->len); |
333 | skb = priv->rx_buf[i]; | 336 | skb = priv->rx_buf[i]; |
334 | 337 | ||
@@ -347,7 +350,7 @@ static irqreturn_t p54p_interrupt(int irq, void *dev_id) | |||
347 | } | 350 | } |
348 | 351 | ||
349 | i++; | 352 | i++; |
350 | i %= ARRAY_SIZE(priv->ring_control->rx_data); | 353 | i %= ARRAY_SIZE(ring_control->rx_data); |
351 | } | 354 | } |
352 | 355 | ||
353 | p54p_refill_rx_ring(dev); | 356 | p54p_refill_rx_ring(dev); |
@@ -366,6 +369,7 @@ static void p54p_tx(struct ieee80211_hw *dev, struct p54_control_hdr *data, | |||
366 | size_t len, int free_on_tx) | 369 | size_t len, int free_on_tx) |
367 | { | 370 | { |
368 | struct p54p_priv *priv = dev->priv; | 371 | struct p54p_priv *priv = dev->priv; |
372 | struct p54p_ring_control *ring_control = priv->ring_control; | ||
369 | unsigned long flags; | 373 | unsigned long flags; |
370 | struct p54p_desc *desc; | 374 | struct p54p_desc *desc; |
371 | dma_addr_t mapping; | 375 | dma_addr_t mapping; |
@@ -373,19 +377,19 @@ static void p54p_tx(struct ieee80211_hw *dev, struct p54_control_hdr *data, | |||
373 | 377 | ||
374 | spin_lock_irqsave(&priv->lock, flags); | 378 | spin_lock_irqsave(&priv->lock, flags); |
375 | 379 | ||
376 | device_idx = le32_to_cpu(priv->ring_control->device_idx[1]); | 380 | device_idx = le32_to_cpu(ring_control->device_idx[1]); |
377 | idx = le32_to_cpu(priv->ring_control->host_idx[1]); | 381 | idx = le32_to_cpu(ring_control->host_idx[1]); |
378 | i = idx % ARRAY_SIZE(priv->ring_control->tx_data); | 382 | i = idx % ARRAY_SIZE(ring_control->tx_data); |
379 | 383 | ||
380 | mapping = pci_map_single(priv->pdev, data, len, PCI_DMA_TODEVICE); | 384 | mapping = pci_map_single(priv->pdev, data, len, PCI_DMA_TODEVICE); |
381 | desc = &priv->ring_control->tx_data[i]; | 385 | desc = &ring_control->tx_data[i]; |
382 | desc->host_addr = cpu_to_le32(mapping); | 386 | desc->host_addr = cpu_to_le32(mapping); |
383 | desc->device_addr = data->req_id; | 387 | desc->device_addr = data->req_id; |
384 | desc->len = cpu_to_le16(len); | 388 | desc->len = cpu_to_le16(len); |
385 | desc->flags = 0; | 389 | desc->flags = 0; |
386 | 390 | ||
387 | wmb(); | 391 | wmb(); |
388 | priv->ring_control->host_idx[1] = cpu_to_le32(idx + 1); | 392 | ring_control->host_idx[1] = cpu_to_le32(idx + 1); |
389 | 393 | ||
390 | if (free_on_tx) | 394 | if (free_on_tx) |
391 | priv->tx_buf[i] = data; | 395 | priv->tx_buf[i] = data; |
@@ -397,7 +401,7 @@ static void p54p_tx(struct ieee80211_hw *dev, struct p54_control_hdr *data, | |||
397 | 401 | ||
398 | /* FIXME: unlikely to happen because the device usually runs out of | 402 | /* FIXME: unlikely to happen because the device usually runs out of |
399 | memory before we fill the ring up, but we can make it impossible */ | 403 | memory before we fill the ring up, but we can make it impossible */ |
400 | if (idx - device_idx > ARRAY_SIZE(priv->ring_control->tx_data) - 2) | 404 | if (idx - device_idx > ARRAY_SIZE(ring_control->tx_data) - 2) |
401 | printk(KERN_INFO "%s: tx overflow.\n", wiphy_name(dev->wiphy)); | 405 | printk(KERN_INFO "%s: tx overflow.\n", wiphy_name(dev->wiphy)); |
402 | } | 406 | } |
403 | 407 | ||
@@ -457,6 +461,7 @@ static int p54p_open(struct ieee80211_hw *dev) | |||
457 | static void p54p_stop(struct ieee80211_hw *dev) | 461 | static void p54p_stop(struct ieee80211_hw *dev) |
458 | { | 462 | { |
459 | struct p54p_priv *priv = dev->priv; | 463 | struct p54p_priv *priv = dev->priv; |
464 | struct p54p_ring_control *ring_control = priv->ring_control; | ||
460 | unsigned int i; | 465 | unsigned int i; |
461 | struct p54p_desc *desc; | 466 | struct p54p_desc *desc; |
462 | 467 | ||
@@ -469,7 +474,7 @@ static void p54p_stop(struct ieee80211_hw *dev) | |||
469 | P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_RESET)); | 474 | P54P_WRITE(dev_int, cpu_to_le32(ISL38XX_DEV_INT_RESET)); |
470 | 475 | ||
471 | for (i = 0; i < ARRAY_SIZE(priv->rx_buf); i++) { | 476 | for (i = 0; i < ARRAY_SIZE(priv->rx_buf); i++) { |
472 | desc = &priv->ring_control->rx_data[i]; | 477 | desc = &ring_control->rx_data[i]; |
473 | if (desc->host_addr) | 478 | if (desc->host_addr) |
474 | pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr), | 479 | pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr), |
475 | MAX_RX_SIZE, PCI_DMA_FROMDEVICE); | 480 | MAX_RX_SIZE, PCI_DMA_FROMDEVICE); |
@@ -478,7 +483,7 @@ static void p54p_stop(struct ieee80211_hw *dev) | |||
478 | } | 483 | } |
479 | 484 | ||
480 | for (i = 0; i < ARRAY_SIZE(priv->tx_buf); i++) { | 485 | for (i = 0; i < ARRAY_SIZE(priv->tx_buf); i++) { |
481 | desc = &priv->ring_control->tx_data[i]; | 486 | desc = &ring_control->tx_data[i]; |
482 | if (desc->host_addr) | 487 | if (desc->host_addr) |
483 | pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr), | 488 | pci_unmap_single(priv->pdev, le32_to_cpu(desc->host_addr), |
484 | le16_to_cpu(desc->len), PCI_DMA_TODEVICE); | 489 | le16_to_cpu(desc->len), PCI_DMA_TODEVICE); |
@@ -487,7 +492,7 @@ static void p54p_stop(struct ieee80211_hw *dev) | |||
487 | priv->tx_buf[i] = NULL; | 492 | priv->tx_buf[i] = NULL; |
488 | } | 493 | } |
489 | 494 | ||
490 | memset(priv->ring_control, 0, sizeof(*priv->ring_control)); | 495 | memset(ring_control, 0, sizeof(ring_control)); |
491 | } | 496 | } |
492 | 497 | ||
493 | static int __devinit p54p_probe(struct pci_dev *pdev, | 498 | static int __devinit p54p_probe(struct pci_dev *pdev, |