diff options
author | Jay Cliburn <jacliburn@bellsouth.net> | 2007-07-15 12:03:28 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-07-16 18:29:16 -0400 |
commit | 2ca13da705ac9780ff7cd2ea7948e25303c42f81 (patch) | |
tree | a6e871b8a8a575b53309868e9405282540f72839 /drivers/net | |
parent | 53ffb42cdf3d01f7b6e2101eebed3d12e71a30f5 (diff) |
atl1: fix excessively indented code
Move excessively indented code to separate functions. Also move ring
pointer initialization to its own function.
Signed-off-by: Jay Cliburn <jacliburn@bellsouth.net>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/atl1/atl1_main.c | 86 |
1 files changed, 50 insertions, 36 deletions
diff --git a/drivers/net/atl1/atl1_main.c b/drivers/net/atl1/atl1_main.c index b40f1c7901fe..67ddf8dcf764 100644 --- a/drivers/net/atl1/atl1_main.c +++ b/drivers/net/atl1/atl1_main.c | |||
@@ -220,8 +220,6 @@ s32 atl1_setup_ring_resources(struct atl1_adapter *adapter) | |||
220 | tpd_ring->dma += offset; | 220 | tpd_ring->dma += offset; |
221 | tpd_ring->desc = (u8 *) ring_header->desc + offset; | 221 | tpd_ring->desc = (u8 *) ring_header->desc + offset; |
222 | tpd_ring->size = sizeof(struct tx_packet_desc) * tpd_ring->count; | 222 | tpd_ring->size = sizeof(struct tx_packet_desc) * tpd_ring->count; |
223 | atomic_set(&tpd_ring->next_to_use, 0); | ||
224 | atomic_set(&tpd_ring->next_to_clean, 0); | ||
225 | 223 | ||
226 | /* init RFD ring */ | 224 | /* init RFD ring */ |
227 | rfd_ring->dma = tpd_ring->dma + tpd_ring->size; | 225 | rfd_ring->dma = tpd_ring->dma + tpd_ring->size; |
@@ -229,8 +227,7 @@ s32 atl1_setup_ring_resources(struct atl1_adapter *adapter) | |||
229 | rfd_ring->dma += offset; | 227 | rfd_ring->dma += offset; |
230 | rfd_ring->desc = (u8 *) tpd_ring->desc + (tpd_ring->size + offset); | 228 | rfd_ring->desc = (u8 *) tpd_ring->desc + (tpd_ring->size + offset); |
231 | rfd_ring->size = sizeof(struct rx_free_desc) * rfd_ring->count; | 229 | rfd_ring->size = sizeof(struct rx_free_desc) * rfd_ring->count; |
232 | rfd_ring->next_to_clean = 0; | 230 | |
233 | atomic_set(&rfd_ring->next_to_use, 0); | ||
234 | 231 | ||
235 | /* init RRD ring */ | 232 | /* init RRD ring */ |
236 | rrd_ring->dma = rfd_ring->dma + rfd_ring->size; | 233 | rrd_ring->dma = rfd_ring->dma + rfd_ring->size; |
@@ -238,8 +235,7 @@ s32 atl1_setup_ring_resources(struct atl1_adapter *adapter) | |||
238 | rrd_ring->dma += offset; | 235 | rrd_ring->dma += offset; |
239 | rrd_ring->desc = (u8 *) rfd_ring->desc + (rfd_ring->size + offset); | 236 | rrd_ring->desc = (u8 *) rfd_ring->desc + (rfd_ring->size + offset); |
240 | rrd_ring->size = sizeof(struct rx_return_desc) * rrd_ring->count; | 237 | rrd_ring->size = sizeof(struct rx_return_desc) * rrd_ring->count; |
241 | rrd_ring->next_to_use = 0; | 238 | |
242 | atomic_set(&rrd_ring->next_to_clean, 0); | ||
243 | 239 | ||
244 | /* init CMB */ | 240 | /* init CMB */ |
245 | adapter->cmb.dma = rrd_ring->dma + rrd_ring->size; | 241 | adapter->cmb.dma = rrd_ring->dma + rrd_ring->size; |
@@ -263,6 +259,22 @@ err_nomem: | |||
263 | return -ENOMEM; | 259 | return -ENOMEM; |
264 | } | 260 | } |
265 | 261 | ||
262 | void atl1_init_ring_ptrs(struct atl1_adapter *adapter) | ||
263 | { | ||
264 | struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; | ||
265 | struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring; | ||
266 | struct atl1_rrd_ring *rrd_ring = &adapter->rrd_ring; | ||
267 | |||
268 | atomic_set(&tpd_ring->next_to_use, 0); | ||
269 | atomic_set(&tpd_ring->next_to_clean, 0); | ||
270 | |||
271 | rfd_ring->next_to_clean = 0; | ||
272 | atomic_set(&rfd_ring->next_to_use, 0); | ||
273 | |||
274 | rrd_ring->next_to_use = 0; | ||
275 | atomic_set(&rrd_ring->next_to_clean, 0); | ||
276 | } | ||
277 | |||
266 | /* | 278 | /* |
267 | * atl1_irq_enable - Enable default interrupt generation settings | 279 | * atl1_irq_enable - Enable default interrupt generation settings |
268 | * @adapter: board private structure | 280 | * @adapter: board private structure |
@@ -472,6 +484,31 @@ next: | |||
472 | return num_alloc; | 484 | return num_alloc; |
473 | } | 485 | } |
474 | 486 | ||
487 | static void atl1_clean_alloc_flag(struct atl1_adapter *adapter, | ||
488 | struct rx_return_desc *rrd, u16 offset) | ||
489 | { | ||
490 | struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring; | ||
491 | |||
492 | while (rfd_ring->next_to_clean != (rrd->buf_indx + offset)) { | ||
493 | rfd_ring->buffer_info[rfd_ring->next_to_clean].alloced = 0; | ||
494 | if (++rfd_ring->next_to_clean == rfd_ring->count) { | ||
495 | rfd_ring->next_to_clean = 0; | ||
496 | } | ||
497 | } | ||
498 | } | ||
499 | |||
500 | static void atl1_update_rfd_index(struct atl1_adapter *adapter, | ||
501 | struct rx_return_desc *rrd) | ||
502 | { | ||
503 | u16 num_buf; | ||
504 | |||
505 | num_buf = (rrd->xsz.xsum_sz.pkt_size + adapter->rx_buffer_len - 1) / | ||
506 | adapter->rx_buffer_len; | ||
507 | if (rrd->num_buf == num_buf) | ||
508 | /* clean alloc flag for bad rrd */ | ||
509 | atl1_clean_alloc_flag(adapter, rrd, num_buf); | ||
510 | } | ||
511 | |||
475 | static void atl1_intr_rx(struct atl1_adapter *adapter) | 512 | static void atl1_intr_rx(struct atl1_adapter *adapter) |
476 | { | 513 | { |
477 | int i, count; | 514 | int i, count; |
@@ -509,26 +546,8 @@ chk_rrd: | |||
509 | dev_printk(KERN_DEBUG, &adapter->pdev->dev, | 546 | dev_printk(KERN_DEBUG, &adapter->pdev->dev, |
510 | "bad RRD\n"); | 547 | "bad RRD\n"); |
511 | /* see if update RFD index */ | 548 | /* see if update RFD index */ |
512 | if (rrd->num_buf > 1) { | 549 | if (rrd->num_buf > 1) |
513 | u16 num_buf; | 550 | atl1_update_rfd_index(adapter, rrd); |
514 | num_buf = | ||
515 | (rrd->xsz.xsum_sz.pkt_size + | ||
516 | adapter->rx_buffer_len - | ||
517 | 1) / adapter->rx_buffer_len; | ||
518 | if (rrd->num_buf == num_buf) { | ||
519 | /* clean alloc flag for bad rrd */ | ||
520 | while (rfd_ring->next_to_clean != | ||
521 | (rrd->buf_indx + num_buf)) { | ||
522 | rfd_ring->buffer_info[rfd_ring-> | ||
523 | next_to_clean].alloced = 0; | ||
524 | if (++rfd_ring->next_to_clean == | ||
525 | rfd_ring->count) { | ||
526 | rfd_ring-> | ||
527 | next_to_clean = 0; | ||
528 | } | ||
529 | } | ||
530 | } | ||
531 | } | ||
532 | 551 | ||
533 | /* update rrd */ | 552 | /* update rrd */ |
534 | rrd->xsz.valid = 0; | 553 | rrd->xsz.valid = 0; |
@@ -542,12 +561,7 @@ chk_rrd: | |||
542 | } | 561 | } |
543 | rrd_ok: | 562 | rrd_ok: |
544 | /* clean alloc flag for bad rrd */ | 563 | /* clean alloc flag for bad rrd */ |
545 | while (rfd_ring->next_to_clean != rrd->buf_indx) { | 564 | atl1_clean_alloc_flag(adapter, rrd, 0); |
546 | rfd_ring->buffer_info[rfd_ring->next_to_clean].alloced = | ||
547 | 0; | ||
548 | if (++rfd_ring->next_to_clean == rfd_ring->count) | ||
549 | rfd_ring->next_to_clean = 0; | ||
550 | } | ||
551 | 565 | ||
552 | buffer_info = &rfd_ring->buffer_info[rrd->buf_indx]; | 566 | buffer_info = &rfd_ring->buffer_info[rrd->buf_indx]; |
553 | if (++rfd_ring->next_to_clean == rfd_ring->count) | 567 | if (++rfd_ring->next_to_clean == rfd_ring->count) |
@@ -1058,7 +1072,8 @@ static u32 atl1_configure(struct atl1_adapter *adapter) | |||
1058 | value <<= 16; | 1072 | value <<= 16; |
1059 | value += adapter->rfd_ring.count; | 1073 | value += adapter->rfd_ring.count; |
1060 | iowrite32(value, hw->hw_addr + REG_DESC_RFD_RRD_RING_SIZE); | 1074 | iowrite32(value, hw->hw_addr + REG_DESC_RFD_RRD_RING_SIZE); |
1061 | iowrite32(adapter->tpd_ring.count, hw->hw_addr + REG_DESC_TPD_RING_SIZE); | 1075 | iowrite32(adapter->tpd_ring.count, hw->hw_addr + |
1076 | REG_DESC_TPD_RING_SIZE); | ||
1062 | 1077 | ||
1063 | /* Load Ptr */ | 1078 | /* Load Ptr */ |
1064 | iowrite32(1, hw->hw_addr + REG_LOAD_PTR); | 1079 | iowrite32(1, hw->hw_addr + REG_LOAD_PTR); |
@@ -1258,9 +1273,7 @@ static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb, | |||
1258 | iph->tot_len = 0; | 1273 | iph->tot_len = 0; |
1259 | iph->check = 0; | 1274 | iph->check = 0; |
1260 | tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, | 1275 | tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, |
1261 | iph->daddr, 0, | 1276 | iph->daddr, 0, IPPROTO_TCP, 0); |
1262 | IPPROTO_TCP, | ||
1263 | 0); | ||
1264 | ipofst = skb_network_offset(skb); | 1277 | ipofst = skb_network_offset(skb); |
1265 | if (ipofst != ENET_HEADER_SIZE) /* 802.3 frame */ | 1278 | if (ipofst != ENET_HEADER_SIZE) /* 802.3 frame */ |
1266 | tso->tsopl |= 1 << TSO_PARAM_ETHTYPE_SHIFT; | 1279 | tso->tsopl |= 1 << TSO_PARAM_ETHTYPE_SHIFT; |
@@ -1721,6 +1734,7 @@ s32 atl1_up(struct atl1_adapter *adapter) | |||
1721 | 1734 | ||
1722 | /* hardware has been reset, we need to reload some things */ | 1735 | /* hardware has been reset, we need to reload some things */ |
1723 | atl1_set_multi(netdev); | 1736 | atl1_set_multi(netdev); |
1737 | atl1_init_ring_ptrs(adapter); | ||
1724 | atl1_restore_vlan(adapter); | 1738 | atl1_restore_vlan(adapter); |
1725 | err = atl1_alloc_rx_buffers(adapter); | 1739 | err = atl1_alloc_rx_buffers(adapter); |
1726 | if (unlikely(!err)) /* no RX BUFFER allocated */ | 1740 | if (unlikely(!err)) /* no RX BUFFER allocated */ |