Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: amd8111e: fix inappropriate spaces

Delete unncecessary spaces and add some reasonable spaces according to the
coding-style of kernel.

Signed-off-by: Yixing Liu <liuyixing1@huawei.com>
Signed-off-by: Weihang Li <liweihang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Yixing Liu and committed by
David S. Miller
ca3fc0aa e355fa6a

+177 -185
+177 -185
drivers/net/ethernet/amd/amd8111e.c
··· 100 100 { 101 101 void __iomem *mmio = lp->mmio; 102 102 unsigned int reg_val; 103 - unsigned int repeat= REPEAT_CNT; 103 + unsigned int repeat = REPEAT_CNT; 104 104 105 105 reg_val = readl(mmio + PHY_ACCESS); 106 106 while (reg_val & PHY_CMD_ACTIVE) 107 - reg_val = readl( mmio + PHY_ACCESS ); 107 + reg_val = readl(mmio + PHY_ACCESS); 108 108 109 - writel( PHY_RD_CMD | ((phy_id & 0x1f) << 21) | 110 - ((reg & 0x1f) << 16), mmio +PHY_ACCESS); 111 - do{ 109 + writel(PHY_RD_CMD | ((phy_id & 0x1f) << 21) | 110 + ((reg & 0x1f) << 16), mmio + PHY_ACCESS); 111 + do { 112 112 reg_val = readl(mmio + PHY_ACCESS); 113 113 udelay(30); /* It takes 30 us to read/write data */ 114 114 } while (--repeat && (reg_val & PHY_CMD_ACTIVE)); 115 - if(reg_val & PHY_RD_ERR) 115 + if (reg_val & PHY_RD_ERR) 116 116 goto err_phy_read; 117 117 118 118 *val = reg_val & 0xffff; ··· 133 133 134 134 reg_val = readl(mmio + PHY_ACCESS); 135 135 while (reg_val & PHY_CMD_ACTIVE) 136 - reg_val = readl( mmio + PHY_ACCESS ); 136 + reg_val = readl(mmio + PHY_ACCESS); 137 137 138 - writel( PHY_WR_CMD | ((phy_id & 0x1f) << 21) | 138 + writel(PHY_WR_CMD | ((phy_id & 0x1f) << 21) | 139 139 ((reg & 0x1f) << 16)|val, mmio + PHY_ACCESS); 140 140 141 - do{ 141 + do { 142 142 reg_val = readl(mmio + PHY_ACCESS); 143 143 udelay(30); /* It takes 30 us to read/write the data */ 144 144 } while (--repeat && (reg_val & PHY_CMD_ACTIVE)); 145 145 146 - if(reg_val & PHY_RD_ERR) 146 + if (reg_val & PHY_RD_ERR) 147 147 goto err_phy_write; 148 148 149 149 return 0; ··· 159 159 struct amd8111e_priv *lp = netdev_priv(dev); 160 160 unsigned int reg_val; 161 161 162 - amd8111e_read_phy(lp,phy_id,reg_num,&reg_val); 162 + amd8111e_read_phy(lp, phy_id, reg_num, &reg_val); 163 163 return reg_val; 164 164 165 165 } ··· 179 179 static void amd8111e_set_ext_phy(struct net_device *dev) 180 180 { 181 181 struct amd8111e_priv *lp = netdev_priv(dev); 182 - u32 bmcr,advert,tmp; 182 + u32 bmcr, advert, tmp; 183 183 184 184 /* Determine mii register values to set the speed */ 185 185 advert = amd8111e_mdio_read(dev, lp->ext_phy_addr, MII_ADVERTISE); 186 186 tmp = advert & ~(ADVERTISE_ALL | ADVERTISE_100BASE4); 187 - switch (lp->ext_phy_option){ 187 + switch (lp->ext_phy_option) { 188 188 189 189 default: 190 190 case SPEED_AUTONEG: /* advertise all values */ 191 - tmp |= ( ADVERTISE_10HALF|ADVERTISE_10FULL| 192 - ADVERTISE_100HALF|ADVERTISE_100FULL) ; 191 + tmp |= (ADVERTISE_10HALF | ADVERTISE_10FULL | 192 + ADVERTISE_100HALF | ADVERTISE_100FULL); 193 193 break; 194 194 case SPEED10_HALF: 195 195 tmp |= ADVERTISE_10HALF; ··· 224 224 int i; 225 225 226 226 /* Freeing transmit skbs */ 227 - for(i = 0; i < NUM_TX_BUFFERS; i++){ 228 - if(lp->tx_skbuff[i]){ 227 + for (i = 0; i < NUM_TX_BUFFERS; i++) { 228 + if (lp->tx_skbuff[i]) { 229 229 dma_unmap_single(&lp->pci_dev->dev, 230 230 lp->tx_dma_addr[i], 231 231 lp->tx_skbuff[i]->len, DMA_TO_DEVICE); 232 - dev_kfree_skb (lp->tx_skbuff[i]); 232 + dev_kfree_skb(lp->tx_skbuff[i]); 233 233 lp->tx_skbuff[i] = NULL; 234 234 lp->tx_dma_addr[i] = 0; 235 235 } 236 236 } 237 237 /* Freeing previously allocated receive buffers */ 238 - for (i = 0; i < NUM_RX_BUFFERS; i++){ 238 + for (i = 0; i < NUM_RX_BUFFERS; i++) { 239 239 rx_skbuff = lp->rx_skbuff[i]; 240 - if(rx_skbuff != NULL){ 240 + if (rx_skbuff != NULL) { 241 241 dma_unmap_single(&lp->pci_dev->dev, 242 242 lp->rx_dma_addr[i], 243 243 lp->rx_buff_len - 2, DMA_FROM_DEVICE); ··· 258 258 struct amd8111e_priv *lp = netdev_priv(dev); 259 259 unsigned int mtu = dev->mtu; 260 260 261 - if (mtu > ETH_DATA_LEN){ 261 + if (mtu > ETH_DATA_LEN) { 262 262 /* MTU + ethernet header + FCS 263 263 * + optional VLAN tag + skb reserve space 2 264 264 */ 265 265 lp->rx_buff_len = mtu + ETH_HLEN + 10; 266 266 lp->options |= OPTION_JUMBO_ENABLE; 267 - } else{ 267 + } else { 268 268 lp->rx_buff_len = PKT_BUFF_SZ; 269 269 lp->options &= ~OPTION_JUMBO_ENABLE; 270 270 } ··· 285 285 lp->tx_ring_idx = 0; 286 286 287 287 288 - if(lp->opened) 288 + if (lp->opened) 289 289 /* Free previously allocated transmit and receive skbs */ 290 290 amd8111e_free_skbs(dev); 291 291 292 - else{ 292 + else { 293 293 /* allocate the tx and rx descriptors */ 294 294 lp->tx_ring = dma_alloc_coherent(&lp->pci_dev->dev, 295 295 sizeof(struct amd8111e_tx_dr) * NUM_TX_RING_DR, ··· 312 312 313 313 lp->rx_skbuff[i] = netdev_alloc_skb(dev, lp->rx_buff_len); 314 314 if (!lp->rx_skbuff[i]) { 315 - /* Release previos allocated skbs */ 316 - for(--i; i >= 0 ;i--) 317 - dev_kfree_skb(lp->rx_skbuff[i]); 318 - goto err_free_rx_ring; 315 + /* Release previos allocated skbs */ 316 + for (--i; i >= 0; i--) 317 + dev_kfree_skb(lp->rx_skbuff[i]); 318 + goto err_free_rx_ring; 319 319 } 320 - skb_reserve(lp->rx_skbuff[i],2); 320 + skb_reserve(lp->rx_skbuff[i], 2); 321 321 } 322 322 /* Initilaizing receive descriptors */ 323 323 for (i = 0; i < NUM_RX_BUFFERS; i++) { ··· 375 375 case RX_INTR_COAL : 376 376 timeout = coal_conf->rx_timeout; 377 377 event_count = coal_conf->rx_event_count; 378 - if( timeout > MAX_TIMEOUT || 379 - event_count > MAX_EVENT_COUNT ) 378 + if (timeout > MAX_TIMEOUT || 379 + event_count > MAX_EVENT_COUNT) 380 380 return -EINVAL; 381 381 382 382 timeout = timeout * DELAY_TIMER_CONV; 383 383 writel(VAL0|STINTEN, mmio+INTEN0); 384 - writel((u32)DLY_INT_A_R0|( event_count<< 16 )|timeout, 385 - mmio+DLY_INT_A); 384 + writel((u32)DLY_INT_A_R0 | (event_count << 16) | 385 + timeout, mmio + DLY_INT_A); 386 386 break; 387 387 388 - case TX_INTR_COAL : 388 + case TX_INTR_COAL: 389 389 timeout = coal_conf->tx_timeout; 390 390 event_count = coal_conf->tx_event_count; 391 - if( timeout > MAX_TIMEOUT || 392 - event_count > MAX_EVENT_COUNT ) 391 + if (timeout > MAX_TIMEOUT || 392 + event_count > MAX_EVENT_COUNT) 393 393 return -EINVAL; 394 394 395 395 396 396 timeout = timeout * DELAY_TIMER_CONV; 397 - writel(VAL0|STINTEN,mmio+INTEN0); 398 - writel((u32)DLY_INT_B_T0|( event_count<< 16 )|timeout, 399 - mmio+DLY_INT_B); 397 + writel(VAL0 | STINTEN, mmio + INTEN0); 398 + writel((u32)DLY_INT_B_T0 | (event_count << 16) | 399 + timeout, mmio + DLY_INT_B); 400 400 break; 401 401 402 402 case DISABLE_COAL: 403 - writel(0,mmio+STVAL); 404 - writel(STINTEN, mmio+INTEN0); 405 - writel(0, mmio +DLY_INT_B); 406 - writel(0, mmio+DLY_INT_A); 403 + writel(0, mmio + STVAL); 404 + writel(STINTEN, mmio + INTEN0); 405 + writel(0, mmio + DLY_INT_B); 406 + writel(0, mmio + DLY_INT_A); 407 407 break; 408 408 case ENABLE_COAL: 409 409 /* Start the timer */ 410 - writel((u32)SOFT_TIMER_FREQ, mmio+STVAL); /* 0.5 sec */ 411 - writel(VAL0|STINTEN, mmio+INTEN0); 410 + writel((u32)SOFT_TIMER_FREQ, mmio + STVAL); /* 0.5 sec */ 411 + writel(VAL0 | STINTEN, mmio + INTEN0); 412 412 break; 413 413 default: 414 414 break; ··· 423 423 { 424 424 struct amd8111e_priv *lp = netdev_priv(dev); 425 425 void __iomem *mmio = lp->mmio; 426 - int i,reg_val; 426 + int i, reg_val; 427 427 428 428 /* stop the chip */ 429 429 writel(RUN, mmio + CMD0); 430 430 431 - if(amd8111e_init_ring(dev)) 431 + if (amd8111e_init_ring(dev)) 432 432 return -ENOMEM; 433 433 434 434 /* enable the port manager and set auto negotiation always */ 435 - writel((u32) VAL1|EN_PMGR, mmio + CMD3 ); 436 - writel((u32)XPHYANE|XPHYRST , mmio + CTRL2); 435 + writel((u32)VAL1 | EN_PMGR, mmio + CMD3); 436 + writel((u32)XPHYANE | XPHYRST, mmio + CTRL2); 437 437 438 438 amd8111e_set_ext_phy(dev); 439 439 440 440 /* set control registers */ 441 441 reg_val = readl(mmio + CTRL1); 442 442 reg_val &= ~XMTSP_MASK; 443 - writel( reg_val| XMTSP_128 | CACHE_ALIGN, mmio + CTRL1 ); 443 + writel(reg_val | XMTSP_128 | CACHE_ALIGN, mmio + CTRL1); 444 444 445 445 /* enable interrupt */ 446 - writel( APINT5EN | APINT4EN | APINT3EN | APINT2EN | APINT1EN | 446 + writel(APINT5EN | APINT4EN | APINT3EN | APINT2EN | APINT1EN | 447 447 APINT0EN | MIIPDTINTEN | MCCIINTEN | MCCINTEN | MREINTEN | 448 448 SPNDINTEN | MPINTEN | SINTEN | STINTEN, mmio + INTEN0); 449 449 450 450 writel(VAL3 | LCINTEN | VAL1 | TINTEN0 | VAL0 | RINTEN0, mmio + INTEN0); 451 451 452 452 /* initialize tx and rx ring base addresses */ 453 - writel((u32)lp->tx_ring_dma_addr,mmio + XMT_RING_BASE_ADDR0); 454 - writel((u32)lp->rx_ring_dma_addr,mmio+ RCV_RING_BASE_ADDR0); 453 + writel((u32)lp->tx_ring_dma_addr, mmio + XMT_RING_BASE_ADDR0); 454 + writel((u32)lp->rx_ring_dma_addr, mmio + RCV_RING_BASE_ADDR0); 455 455 456 456 writew((u32)NUM_TX_RING_DR, mmio + XMT_RING_LEN0); 457 457 writew((u16)NUM_RX_RING_DR, mmio + RCV_RING_LEN0); 458 458 459 459 /* set default IPG to 96 */ 460 - writew((u32)DEFAULT_IPG,mmio+IPG); 460 + writew((u32)DEFAULT_IPG, mmio + IPG); 461 461 writew((u32)(DEFAULT_IPG-IFS1_DELTA), mmio + IFS1); 462 462 463 - if(lp->options & OPTION_JUMBO_ENABLE){ 463 + if (lp->options & OPTION_JUMBO_ENABLE) { 464 464 writel((u32)VAL2|JUMBO, mmio + CMD3); 465 465 /* Reset REX_UFLO */ 466 - writel( REX_UFLO, mmio + CMD2); 466 + writel(REX_UFLO, mmio + CMD2); 467 467 /* Should not set REX_UFLO for jumbo frames */ 468 - writel( VAL0 | APAD_XMT|REX_RTRY , mmio + CMD2); 469 - }else{ 470 - writel( VAL0 | APAD_XMT | REX_RTRY|REX_UFLO, mmio + CMD2); 468 + writel(VAL0 | APAD_XMT | REX_RTRY, mmio + CMD2); 469 + } else { 470 + writel(VAL0 | APAD_XMT | REX_RTRY | REX_UFLO, mmio + CMD2); 471 471 writel((u32)JUMBO, mmio + CMD3); 472 472 } 473 473 474 474 #if AMD8111E_VLAN_TAG_USED 475 - writel((u32) VAL2|VSIZE|VL_TAG_DEL, mmio + CMD3); 475 + writel((u32)VAL2 | VSIZE | VL_TAG_DEL, mmio + CMD3); 476 476 #endif 477 - writel( VAL0 | APAD_XMT | REX_RTRY, mmio + CMD2 ); 477 + writel(VAL0 | APAD_XMT | REX_RTRY, mmio + CMD2); 478 478 479 479 /* Setting the MAC address to the device */ 480 480 for (i = 0; i < ETH_ALEN; i++) 481 - writeb( dev->dev_addr[i], mmio + PADR + i ); 481 + writeb(dev->dev_addr[i], mmio + PADR + i); 482 482 483 483 /* Enable interrupt coalesce */ 484 - if(lp->options & OPTION_INTR_COAL_ENABLE){ 484 + if (lp->options & OPTION_INTR_COAL_ENABLE) { 485 485 netdev_info(dev, "Interrupt Coalescing Enabled.\n"); 486 - amd8111e_set_coalesce(dev,ENABLE_COAL); 486 + amd8111e_set_coalesce(dev, ENABLE_COAL); 487 487 } 488 488 489 489 /* set RUN bit to start the chip */ ··· 499 499 static void amd8111e_init_hw_default(struct amd8111e_priv *lp) 500 500 { 501 501 unsigned int reg_val; 502 - unsigned int logic_filter[2] ={0,}; 502 + unsigned int logic_filter[2] = {0,}; 503 503 void __iomem *mmio = lp->mmio; 504 504 505 505 506 - /* stop the chip */ 506 + /* stop the chip */ 507 507 writel(RUN, mmio + CMD0); 508 508 509 509 /* AUTOPOLL0 Register *//*TBD default value is 8100 in FPS */ ··· 519 519 writel(0, mmio + XMT_RING_BASE_ADDR3); 520 520 521 521 /* Clear CMD0 */ 522 - writel(CMD0_CLEAR,mmio + CMD0); 522 + writel(CMD0_CLEAR, mmio + CMD0); 523 523 524 524 /* Clear CMD2 */ 525 - writel(CMD2_CLEAR, mmio +CMD2); 525 + writel(CMD2_CLEAR, mmio + CMD2); 526 526 527 527 /* Clear CMD7 */ 528 - writel(CMD7_CLEAR , mmio + CMD7); 528 + writel(CMD7_CLEAR, mmio + CMD7); 529 529 530 530 /* Clear DLY_INT_A and DLY_INT_B */ 531 531 writel(0x0, mmio + DLY_INT_A); ··· 542 542 writel(0x0, mmio + STVAL); 543 543 544 544 /* Clear INTEN0 */ 545 - writel( INTEN0_CLEAR, mmio + INTEN0); 545 + writel(INTEN0_CLEAR, mmio + INTEN0); 546 546 547 547 /* Clear LADRF */ 548 - writel(0x0 , mmio + LADRF); 548 + writel(0x0, mmio + LADRF); 549 549 550 550 /* Set SRAM_SIZE & SRAM_BOUNDARY registers */ 551 - writel( 0x80010,mmio + SRAM_SIZE); 551 + writel(0x80010, mmio + SRAM_SIZE); 552 552 553 553 /* Clear RCV_RING0_LEN */ 554 - writel(0x0, mmio + RCV_RING_LEN0); 554 + writel(0x0, mmio + RCV_RING_LEN0); 555 555 556 556 /* Clear XMT_RING0/1/2/3_LEN */ 557 557 writel(0x0, mmio + XMT_RING_LEN0); ··· 571 571 /* SRAM_SIZE register */ 572 572 reg_val = readl(mmio + SRAM_SIZE); 573 573 574 - if(lp->options & OPTION_JUMBO_ENABLE) 575 - writel( VAL2|JUMBO, mmio + CMD3); 574 + if (lp->options & OPTION_JUMBO_ENABLE) 575 + writel(VAL2 | JUMBO, mmio + CMD3); 576 576 #if AMD8111E_VLAN_TAG_USED 577 - writel(VAL2|VSIZE|VL_TAG_DEL, mmio + CMD3 ); 577 + writel(VAL2 | VSIZE | VL_TAG_DEL, mmio + CMD3); 578 578 #endif 579 579 /* Set default value to CTRL1 Register */ 580 580 writel(CTRL1_DEFAULT, mmio + CTRL1); ··· 616 616 static void amd8111e_free_ring(struct amd8111e_priv *lp) 617 617 { 618 618 /* Free transmit and receive descriptor rings */ 619 - if(lp->rx_ring){ 619 + if (lp->rx_ring) { 620 620 dma_free_coherent(&lp->pci_dev->dev, 621 621 sizeof(struct amd8111e_rx_dr) * NUM_RX_RING_DR, 622 622 lp->rx_ring, lp->rx_ring_dma_addr); 623 623 lp->rx_ring = NULL; 624 624 } 625 625 626 - if(lp->tx_ring){ 626 + if (lp->tx_ring) { 627 627 dma_free_coherent(&lp->pci_dev->dev, 628 628 sizeof(struct amd8111e_tx_dr) * NUM_TX_RING_DR, 629 629 lp->tx_ring, lp->tx_ring_dma_addr); ··· 643 643 int tx_index; 644 644 int status; 645 645 /* Complete all the transmit packet */ 646 - while (lp->tx_complete_idx != lp->tx_idx){ 646 + while (lp->tx_complete_idx != lp->tx_idx) { 647 647 tx_index = lp->tx_complete_idx & TX_RING_DR_MOD_MASK; 648 648 status = le16_to_cpu(lp->tx_ring[tx_index].tx_flags); 649 649 650 - if(status & OWN_BIT) 650 + if (status & OWN_BIT) 651 651 break; /* It still hasn't been Txed */ 652 652 653 653 lp->tx_ring[tx_index].buff_phy_addr = 0; ··· 669 669 le16_to_cpu(lp->tx_ring[tx_index].buff_count); 670 670 671 671 if (netif_queue_stopped(dev) && 672 - lp->tx_complete_idx > lp->tx_idx - NUM_TX_BUFFERS +2){ 672 + lp->tx_complete_idx > lp->tx_idx - NUM_TX_BUFFERS + 2) { 673 673 /* The ring is no longer full, clear tbusy. */ 674 674 /* lp->tx_full = 0; */ 675 - netif_wake_queue (dev); 675 + netif_wake_queue(dev); 676 676 } 677 677 } 678 678 return 0; ··· 685 685 struct net_device *dev = lp->amd8111e_net_dev; 686 686 int rx_index = lp->rx_idx & RX_RING_DR_MOD_MASK; 687 687 void __iomem *mmio = lp->mmio; 688 - struct sk_buff *skb,*new_skb; 688 + struct sk_buff *skb, *new_skb; 689 689 int min_pkt_len, status; 690 690 int num_rx_pkt = 0; 691 691 short pkt_len; ··· 710 710 goto err_next_pkt; 711 711 } 712 712 /* check for STP and ENP */ 713 - if (!((status & STP_BIT) && (status & ENP_BIT))){ 713 + if (!((status & STP_BIT) && (status & ENP_BIT))) { 714 714 /* resetting flags */ 715 715 lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS; 716 716 goto err_next_pkt; ··· 755 755 skb->protocol = eth_type_trans(skb, dev); 756 756 757 757 #if AMD8111E_VLAN_TAG_USED 758 - if (vtag == TT_VLAN_TAGGED){ 758 + if (vtag == TT_VLAN_TAGGED) { 759 759 u16 vlan_tag = le16_to_cpu(lp->rx_ring[rx_index].tag_ctrl_info); 760 760 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tag); 761 761 } ··· 793 793 static int amd8111e_link_change(struct net_device *dev) 794 794 { 795 795 struct amd8111e_priv *lp = netdev_priv(dev); 796 - int status0,speed; 796 + int status0, speed; 797 797 798 798 /* read the link change */ 799 - status0 = readl(lp->mmio + STAT0); 799 + status0 = readl(lp->mmio + STAT0); 800 800 801 - if(status0 & LINK_STATS){ 802 - if(status0 & AUTONEG_COMPLETE) 801 + if (status0 & LINK_STATS) { 802 + if (status0 & AUTONEG_COMPLETE) 803 803 lp->link_config.autoneg = AUTONEG_ENABLE; 804 804 else 805 805 lp->link_config.autoneg = AUTONEG_DISABLE; 806 806 807 - if(status0 & FULL_DPLX) 807 + if (status0 & FULL_DPLX) 808 808 lp->link_config.duplex = DUPLEX_FULL; 809 809 else 810 810 lp->link_config.duplex = DUPLEX_HALF; 811 811 speed = (status0 & SPEED_MASK) >> 7; 812 - if(speed == PHY_SPEED_10) 812 + if (speed == PHY_SPEED_10) 813 813 lp->link_config.speed = SPEED_10; 814 - else if(speed == PHY_SPEED_100) 814 + else if (speed == PHY_SPEED_100) 815 815 lp->link_config.speed = SPEED_100; 816 816 817 817 netdev_info(dev, "Link is Up. Speed is %s Mbps %s Duplex\n", ··· 821 821 "Full" : "Half"); 822 822 823 823 netif_carrier_on(dev); 824 - } 825 - else{ 824 + } else { 826 825 lp->link_config.speed = SPEED_INVALID; 827 826 lp->link_config.duplex = DUPLEX_INVALID; 828 827 lp->link_config.autoneg = AUTONEG_INVALID; ··· 839 840 unsigned int data; 840 841 unsigned int repeat = REPEAT_CNT; 841 842 842 - writew( MIB_RD_CMD | MIB_COUNTER, mmio + MIB_ADDR); 843 + writew(MIB_RD_CMD | MIB_COUNTER, mmio + MIB_ADDR); 843 844 do { 844 845 status = readw(mmio + MIB_ADDR); 845 846 udelay(2); /* controller takes MAX 2 us to get mib data */ ··· 862 863 863 864 if (!lp->opened) 864 865 return new_stats; 865 - spin_lock_irqsave (&lp->lock, flags); 866 + spin_lock_irqsave(&lp->lock, flags); 866 867 867 868 /* stats.rx_packets */ 868 869 new_stats->rx_packets = amd8111e_read_mib(mmio, rcv_broadcast_pkts)+ ··· 942 943 /* Reset the mibs for collecting new statistics */ 943 944 /* writew(MIB_CLEAR, mmio + MIB_ADDR);*/ 944 945 945 - spin_unlock_irqrestore (&lp->lock, flags); 946 + spin_unlock_irqrestore(&lp->lock, flags); 946 947 947 948 return new_stats; 948 949 } ··· 973 974 rx_data_rate = coal_conf->rx_bytes - coal_conf->rx_prev_bytes; 974 975 coal_conf->rx_prev_bytes = coal_conf->rx_bytes; 975 976 976 - if(rx_pkt_rate < 800){ 977 - if(coal_conf->rx_coal_type != NO_COALESCE){ 977 + if (rx_pkt_rate < 800) { 978 + if (coal_conf->rx_coal_type != NO_COALESCE) { 978 979 979 980 coal_conf->rx_timeout = 0x0; 980 981 coal_conf->rx_event_count = 0; 981 - amd8111e_set_coalesce(dev,RX_INTR_COAL); 982 + amd8111e_set_coalesce(dev, RX_INTR_COAL); 982 983 coal_conf->rx_coal_type = NO_COALESCE; 983 984 } 984 - } 985 - else{ 985 + } else { 986 986 987 987 rx_pkt_size = rx_data_rate/rx_pkt_rate; 988 - if (rx_pkt_size < 128){ 989 - if(coal_conf->rx_coal_type != NO_COALESCE){ 988 + if (rx_pkt_size < 128) { 989 + if (coal_conf->rx_coal_type != NO_COALESCE) { 990 990 991 991 coal_conf->rx_timeout = 0; 992 992 coal_conf->rx_event_count = 0; 993 - amd8111e_set_coalesce(dev,RX_INTR_COAL); 993 + amd8111e_set_coalesce(dev, RX_INTR_COAL); 994 994 coal_conf->rx_coal_type = NO_COALESCE; 995 995 } 996 996 997 - } 998 - else if ( (rx_pkt_size >= 128) && (rx_pkt_size < 512) ){ 997 + } else if ((rx_pkt_size >= 128) && (rx_pkt_size < 512)) { 999 998 1000 - if(coal_conf->rx_coal_type != LOW_COALESCE){ 999 + if (coal_conf->rx_coal_type != LOW_COALESCE) { 1001 1000 coal_conf->rx_timeout = 1; 1002 1001 coal_conf->rx_event_count = 4; 1003 - amd8111e_set_coalesce(dev,RX_INTR_COAL); 1002 + amd8111e_set_coalesce(dev, RX_INTR_COAL); 1004 1003 coal_conf->rx_coal_type = LOW_COALESCE; 1005 1004 } 1006 - } 1007 - else if ((rx_pkt_size >= 512) && (rx_pkt_size < 1024)){ 1005 + } else if ((rx_pkt_size >= 512) && (rx_pkt_size < 1024)) { 1008 1006 1009 - if(coal_conf->rx_coal_type != MEDIUM_COALESCE){ 1007 + if (coal_conf->rx_coal_type != MEDIUM_COALESCE) { 1010 1008 coal_conf->rx_timeout = 1; 1011 1009 coal_conf->rx_event_count = 4; 1012 - amd8111e_set_coalesce(dev,RX_INTR_COAL); 1010 + amd8111e_set_coalesce(dev, RX_INTR_COAL); 1013 1011 coal_conf->rx_coal_type = MEDIUM_COALESCE; 1014 1012 } 1015 1013 1016 - } 1017 - else if(rx_pkt_size >= 1024){ 1018 - if(coal_conf->rx_coal_type != HIGH_COALESCE){ 1014 + } else if (rx_pkt_size >= 1024) { 1015 + 1016 + if (coal_conf->rx_coal_type != HIGH_COALESCE) { 1019 1017 coal_conf->rx_timeout = 2; 1020 1018 coal_conf->rx_event_count = 3; 1021 - amd8111e_set_coalesce(dev,RX_INTR_COAL); 1019 + amd8111e_set_coalesce(dev, RX_INTR_COAL); 1022 1020 coal_conf->rx_coal_type = HIGH_COALESCE; 1023 1021 } 1024 1022 } 1025 1023 } 1026 - /* NOW FOR TX INTR COALESC */ 1027 - if(tx_pkt_rate < 800){ 1028 - if(coal_conf->tx_coal_type != NO_COALESCE){ 1024 + /* NOW FOR TX INTR COALESC */ 1025 + if (tx_pkt_rate < 800) { 1026 + if (coal_conf->tx_coal_type != NO_COALESCE) { 1029 1027 1030 1028 coal_conf->tx_timeout = 0x0; 1031 1029 coal_conf->tx_event_count = 0; 1032 - amd8111e_set_coalesce(dev,TX_INTR_COAL); 1030 + amd8111e_set_coalesce(dev, TX_INTR_COAL); 1033 1031 coal_conf->tx_coal_type = NO_COALESCE; 1034 1032 } 1035 - } 1036 - else{ 1033 + } else { 1037 1034 1038 1035 tx_pkt_size = tx_data_rate/tx_pkt_rate; 1039 - if (tx_pkt_size < 128){ 1036 + if (tx_pkt_size < 128) { 1040 1037 1041 - if(coal_conf->tx_coal_type != NO_COALESCE){ 1038 + if (coal_conf->tx_coal_type != NO_COALESCE) { 1042 1039 1043 1040 coal_conf->tx_timeout = 0; 1044 1041 coal_conf->tx_event_count = 0; 1045 - amd8111e_set_coalesce(dev,TX_INTR_COAL); 1042 + amd8111e_set_coalesce(dev, TX_INTR_COAL); 1046 1043 coal_conf->tx_coal_type = NO_COALESCE; 1047 1044 } 1048 1045 1049 - } 1050 - else if ( (tx_pkt_size >= 128) && (tx_pkt_size < 512) ){ 1046 + } else if ((tx_pkt_size >= 128) && (tx_pkt_size < 512)) { 1051 1047 1052 - if(coal_conf->tx_coal_type != LOW_COALESCE){ 1048 + if (coal_conf->tx_coal_type != LOW_COALESCE) { 1053 1049 coal_conf->tx_timeout = 1; 1054 1050 coal_conf->tx_event_count = 2; 1055 - amd8111e_set_coalesce(dev,TX_INTR_COAL); 1051 + amd8111e_set_coalesce(dev, TX_INTR_COAL); 1056 1052 coal_conf->tx_coal_type = LOW_COALESCE; 1057 1053 1058 1054 } 1059 - } 1060 - else if ((tx_pkt_size >= 512) && (tx_pkt_size < 1024)){ 1055 + } else if ((tx_pkt_size >= 512) && (tx_pkt_size < 1024)) { 1061 1056 1062 - if(coal_conf->tx_coal_type != MEDIUM_COALESCE){ 1057 + if (coal_conf->tx_coal_type != MEDIUM_COALESCE) { 1063 1058 coal_conf->tx_timeout = 2; 1064 1059 coal_conf->tx_event_count = 5; 1065 - amd8111e_set_coalesce(dev,TX_INTR_COAL); 1060 + amd8111e_set_coalesce(dev, TX_INTR_COAL); 1066 1061 coal_conf->tx_coal_type = MEDIUM_COALESCE; 1067 1062 } 1068 1063 } else if (tx_pkt_size >= 1024) { ··· 1084 1091 unsigned int intr0, intren0; 1085 1092 unsigned int handled = 1; 1086 1093 1087 - if(unlikely(dev == NULL)) 1094 + if (unlikely(dev == NULL)) 1088 1095 return IRQ_NONE; 1089 1096 1090 1097 spin_lock(&lp->lock); ··· 1098 1105 1099 1106 /* Process all the INT event until INTR bit is clear. */ 1100 1107 1101 - if (!(intr0 & INTR)){ 1108 + if (!(intr0 & INTR)) { 1102 1109 handled = 0; 1103 1110 goto err_no_interrupt; 1104 1111 } ··· 1133 1140 amd8111e_calc_coalesce(dev); 1134 1141 1135 1142 err_no_interrupt: 1136 - writel( VAL0 | INTREN,mmio + CMD0); 1143 + writel(VAL0 | INTREN, mmio + CMD0); 1137 1144 1138 1145 spin_unlock(&lp->lock); 1139 1146 ··· 1173 1180 netif_carrier_off(lp->amd8111e_net_dev); 1174 1181 1175 1182 /* Delete ipg timer */ 1176 - if(lp->options & OPTION_DYN_IPG_ENABLE) 1183 + if (lp->options & OPTION_DYN_IPG_ENABLE) 1177 1184 del_timer_sync(&lp->ipg_data.ipg_timer); 1178 1185 1179 1186 spin_unlock_irq(&lp->lock); ··· 1193 1200 { 1194 1201 struct amd8111e_priv *lp = netdev_priv(dev); 1195 1202 1196 - if(dev->irq ==0 || request_irq(dev->irq, amd8111e_interrupt, IRQF_SHARED, 1197 - dev->name, dev)) 1203 + if (dev->irq == 0 || request_irq(dev->irq, amd8111e_interrupt, 1204 + IRQF_SHARED, dev->name, dev)) 1198 1205 return -EAGAIN; 1199 1206 1200 1207 napi_enable(&lp->napi); ··· 1203 1210 1204 1211 amd8111e_init_hw_default(lp); 1205 1212 1206 - if(amd8111e_restart(dev)){ 1213 + if (amd8111e_restart(dev)) { 1207 1214 spin_unlock_irq(&lp->lock); 1208 1215 napi_disable(&lp->napi); 1209 1216 if (dev->irq) ··· 1211 1218 return -ENOMEM; 1212 1219 } 1213 1220 /* Start ipg timer */ 1214 - if(lp->options & OPTION_DYN_IPG_ENABLE){ 1221 + if (lp->options & OPTION_DYN_IPG_ENABLE) { 1215 1222 add_timer(&lp->ipg_data.ipg_timer); 1216 1223 netdev_info(dev, "Dynamic IPG Enabled\n"); 1217 1224 } ··· 1282 1289 lp->tx_idx++; 1283 1290 1284 1291 /* Trigger an immediate send poll. */ 1285 - writel( VAL1 | TDMD0, lp->mmio + CMD0); 1286 - writel( VAL2 | RDMD0,lp->mmio + CMD0); 1292 + writel(VAL1 | TDMD0, lp->mmio + CMD0); 1293 + writel(VAL2 | RDMD0, lp->mmio + CMD0); 1287 1294 1288 - if(amd8111e_tx_queue_avail(lp) < 0){ 1295 + if (amd8111e_tx_queue_avail(lp) < 0) { 1289 1296 netif_stop_queue(dev); 1290 1297 } 1291 1298 spin_unlock_irqrestore(&lp->lock, flags); ··· 1319 1326 { 1320 1327 struct netdev_hw_addr *ha; 1321 1328 struct amd8111e_priv *lp = netdev_priv(dev); 1322 - u32 mc_filter[2] ; 1329 + u32 mc_filter[2]; 1323 1330 int bit_num; 1324 1331 1325 - if(dev->flags & IFF_PROMISC){ 1326 - writel( VAL2 | PROM, lp->mmio + CMD2); 1332 + if (dev->flags & IFF_PROMISC) { 1333 + writel(VAL2 | PROM, lp->mmio + CMD2); 1327 1334 return; 1328 1335 } 1329 1336 else 1330 - writel( PROM, lp->mmio + CMD2); 1337 + writel(PROM, lp->mmio + CMD2); 1331 1338 if (dev->flags & IFF_ALLMULTI || 1332 1339 netdev_mc_count(dev) > MAX_FILTER_SIZE) { 1333 1340 /* get all multicast packet */ ··· 1432 1439 if (wol_info->wolopts & WAKE_MAGIC) 1433 1440 lp->options |= 1434 1441 (OPTION_WOL_ENABLE | OPTION_WAKE_MAGIC_ENABLE); 1435 - else if(wol_info->wolopts & WAKE_PHY) 1442 + else if (wol_info->wolopts & WAKE_PHY) 1436 1443 lp->options |= 1437 1444 (OPTION_WOL_ENABLE | OPTION_WAKE_PHY_ENABLE); 1438 1445 else ··· 1457 1464 * gets/sets driver speed, gets memory mapped register values, forces 1458 1465 * auto negotiation, sets/gets WOL options for ethtool application. 1459 1466 */ 1460 - static int amd8111e_ioctl(struct net_device *dev , struct ifreq *ifr, int cmd) 1467 + static int amd8111e_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 1461 1468 { 1462 1469 struct mii_ioctl_data *data = if_mii(ifr); 1463 1470 struct amd8111e_priv *lp = netdev_priv(dev); 1464 1471 int err; 1465 1472 u32 mii_regval; 1466 1473 1467 - switch(cmd) { 1474 + switch (cmd) { 1468 1475 case SIOCGMIIPHY: 1469 1476 data->phy_id = lp->ext_phy_addr; 1470 1477 ··· 1504 1511 spin_lock_irq(&lp->lock); 1505 1512 /* Setting the MAC address to the device */ 1506 1513 for (i = 0; i < ETH_ALEN; i++) 1507 - writeb( dev->dev_addr[i], lp->mmio + PADR + i ); 1514 + writeb(dev->dev_addr[i], lp->mmio + PADR + i); 1508 1515 1509 1516 spin_unlock_irq(&lp->lock); 1510 1517 ··· 1529 1536 1530 1537 spin_lock_irq(&lp->lock); 1531 1538 1532 - /* stop the chip */ 1539 + /* stop the chip */ 1533 1540 writel(RUN, lp->mmio + CMD0); 1534 1541 1535 1542 dev->mtu = new_mtu; 1536 1543 1537 1544 err = amd8111e_restart(dev); 1538 1545 spin_unlock_irq(&lp->lock); 1539 - if(!err) 1546 + if (!err) 1540 1547 netif_start_queue(dev); 1541 1548 return err; 1542 1549 } 1543 1550 1544 1551 static int amd8111e_enable_magicpkt(struct amd8111e_priv *lp) 1545 1552 { 1546 - writel( VAL1|MPPLBA, lp->mmio + CMD3); 1547 - writel( VAL0|MPEN_SW, lp->mmio + CMD7); 1553 + writel(VAL1 | MPPLBA, lp->mmio + CMD3); 1554 + writel(VAL0 | MPEN_SW, lp->mmio + CMD7); 1548 1555 1549 1556 /* To eliminate PCI posting bug */ 1550 1557 readl(lp->mmio + CMD7); ··· 1555 1562 { 1556 1563 1557 1564 /* Adapter is already stoped/suspended/interrupt-disabled */ 1558 - writel(VAL0|LCMODE_SW,lp->mmio + CMD7); 1565 + writel(VAL0 | LCMODE_SW, lp->mmio + CMD7); 1559 1566 1560 1567 /* To eliminate PCI posting bug */ 1561 1568 readl(lp->mmio + CMD7); ··· 1577 1584 spin_lock_irq(&lp->lock); 1578 1585 err = amd8111e_restart(dev); 1579 1586 spin_unlock_irq(&lp->lock); 1580 - if(!err) 1587 + if (!err) 1581 1588 netif_wake_queue(dev); 1582 1589 } 1583 1590 ··· 1598 1605 1599 1606 /* stop chip */ 1600 1607 spin_lock_irq(&lp->lock); 1601 - if(lp->options & OPTION_DYN_IPG_ENABLE) 1608 + if (lp->options & OPTION_DYN_IPG_ENABLE) 1602 1609 del_timer_sync(&lp->ipg_data.ipg_timer); 1603 1610 amd8111e_stop_chip(lp); 1604 1611 spin_unlock_irq(&lp->lock); 1605 1612 1606 - if(lp->options & OPTION_WOL_ENABLE){ 1613 + if (lp->options & OPTION_WOL_ENABLE) { 1607 1614 /* enable wol */ 1608 - if(lp->options & OPTION_WAKE_MAGIC_ENABLE) 1615 + if (lp->options & OPTION_WAKE_MAGIC_ENABLE) 1609 1616 amd8111e_enable_magicpkt(lp); 1610 - if(lp->options & OPTION_WAKE_PHY_ENABLE) 1617 + if (lp->options & OPTION_WAKE_PHY_ENABLE) 1611 1618 amd8111e_enable_link_change(lp); 1612 1619 1613 1620 device_set_wakeup_enable(dev_d, 1); 1614 1621 1615 - } 1616 - else{ 1622 + } else { 1617 1623 device_set_wakeup_enable(dev_d, 0); 1618 1624 } 1619 1625 ··· 1632 1640 spin_lock_irq(&lp->lock); 1633 1641 amd8111e_restart(dev); 1634 1642 /* Restart ipg timer */ 1635 - if(lp->options & OPTION_DYN_IPG_ENABLE) 1643 + if (lp->options & OPTION_DYN_IPG_ENABLE) 1636 1644 mod_timer(&lp->ipg_data.ipg_timer, 1637 1645 jiffies + IPG_CONVERGE_JIFFIES); 1638 1646 spin_unlock_irq(&lp->lock); ··· 1649 1657 unsigned int total_col_cnt; 1650 1658 unsigned int tmp_ipg; 1651 1659 1652 - if(lp->link_config.duplex == DUPLEX_FULL){ 1660 + if (lp->link_config.duplex == DUPLEX_FULL) { 1653 1661 ipg_data->ipg = DEFAULT_IPG; 1654 1662 return; 1655 1663 } 1656 1664 1657 - if(ipg_data->ipg_state == SSTATE){ 1665 + if (ipg_data->ipg_state == SSTATE) { 1658 1666 1659 - if(ipg_data->timer_tick == IPG_STABLE_TIME){ 1667 + if (ipg_data->timer_tick == IPG_STABLE_TIME) { 1660 1668 1661 1669 ipg_data->timer_tick = 0; 1662 1670 ipg_data->ipg = MIN_IPG - IPG_STEP; ··· 1668 1676 ipg_data->timer_tick++; 1669 1677 } 1670 1678 1671 - if(ipg_data->ipg_state == CSTATE){ 1679 + if (ipg_data->ipg_state == CSTATE) { 1672 1680 1673 1681 /* Get the current collision count */ 1674 1682 ··· 1676 1684 amd8111e_read_mib(mmio, xmt_collisions); 1677 1685 1678 1686 if ((total_col_cnt - prev_col_cnt) < 1679 - (ipg_data->diff_col_cnt)){ 1687 + (ipg_data->diff_col_cnt)) { 1680 1688 1681 1689 ipg_data->diff_col_cnt = 1682 - total_col_cnt - prev_col_cnt ; 1690 + total_col_cnt - prev_col_cnt; 1683 1691 1684 1692 ipg_data->ipg = ipg_data->current_ipg; 1685 1693 } ··· 1688 1696 1689 1697 if (ipg_data->current_ipg <= MAX_IPG) 1690 1698 tmp_ipg = ipg_data->current_ipg; 1691 - else{ 1699 + else { 1692 1700 tmp_ipg = ipg_data->ipg; 1693 1701 ipg_data->ipg_state = SSTATE; 1694 1702 } ··· 1740 1748 const struct pci_device_id *ent) 1741 1749 { 1742 1750 int err, i; 1743 - unsigned long reg_addr,reg_len; 1751 + unsigned long reg_addr, reg_len; 1744 1752 struct amd8111e_priv *lp; 1745 1753 struct net_device *dev; 1746 1754 1747 1755 err = pci_enable_device(pdev); 1748 - if(err){ 1756 + if (err) { 1749 1757 dev_err(&pdev->dev, "Cannot enable new PCI device\n"); 1750 1758 return err; 1751 1759 } 1752 1760 1753 - if(!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)){ 1761 + if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { 1754 1762 dev_err(&pdev->dev, "Cannot find PCI base address\n"); 1755 1763 err = -ENODEV; 1756 1764 goto err_disable_pdev; 1757 1765 } 1758 1766 1759 1767 err = pci_request_regions(pdev, MODULE_NAME); 1760 - if(err){ 1768 + if (err) { 1761 1769 dev_err(&pdev->dev, "Cannot obtain PCI resources\n"); 1762 1770 goto err_disable_pdev; 1763 1771 } ··· 1790 1798 SET_NETDEV_DEV(dev, &pdev->dev); 1791 1799 1792 1800 #if AMD8111E_VLAN_TAG_USED 1793 - dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX ; 1801 + dev->features |= NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_HW_VLAN_CTAG_RX; 1794 1802 #endif 1795 1803 1796 1804 lp = netdev_priv(dev); ··· 1813 1821 1814 1822 /* Setting user defined parametrs */ 1815 1823 lp->ext_phy_option = speed_duplex[card_idx]; 1816 - if(coalesce[card_idx]) 1824 + if (coalesce[card_idx]) 1817 1825 lp->options |= OPTION_INTR_COAL_ENABLE; 1818 - if(dynamic_ipg[card_idx++]) 1826 + if (dynamic_ipg[card_idx++]) 1819 1827 lp->options |= OPTION_DYN_IPG_ENABLE; 1820 1828 1821 1829 1822 1830 /* Initialize driver entry points */ 1823 1831 dev->netdev_ops = &amd8111e_netdev_ops; 1824 1832 dev->ethtool_ops = &ops; 1825 - dev->irq =pdev->irq; 1833 + dev->irq = pdev->irq; 1826 1834 dev->watchdog_timeo = AMD8111E_TX_TIMEOUT; 1827 1835 dev->min_mtu = AMD8111E_MIN_MTU; 1828 1836 dev->max_mtu = AMD8111E_MAX_MTU; ··· 1853 1861 pci_set_drvdata(pdev, dev); 1854 1862 1855 1863 /* Initialize software ipg timer */ 1856 - if(lp->options & OPTION_DYN_IPG_ENABLE){ 1864 + if (lp->options & OPTION_DYN_IPG_ENABLE) { 1857 1865 timer_setup(&lp->ipg_data.ipg_timer, amd8111e_config_ipg, 0); 1858 1866 lp->ipg_data.ipg_timer.expires = jiffies + 1859 1867 IPG_CONVERGE_JIFFIES; ··· 1862 1870 } 1863 1871 1864 1872 /* display driver and device information */ 1865 - chip_version = (readl(lp->mmio + CHIPID) & 0xf0000000)>>28; 1873 + chip_version = (readl(lp->mmio + CHIPID) & 0xf0000000) >> 28; 1866 1874 dev_info(&pdev->dev, "[ Rev %x ] PCI 10/100BaseT Ethernet %pM\n", 1867 1875 chip_version, dev->dev_addr); 1868 1876 if (lp->ext_phy_id) ··· 1871 1879 else 1872 1880 dev_info(&pdev->dev, "Couldn't detect MII PHY, assuming address 0x01\n"); 1873 1881 1874 - return 0; 1882 + return 0; 1875 1883 1876 1884 err_free_dev: 1877 1885 free_netdev(dev); ··· 1911 1919 static SIMPLE_DEV_PM_OPS(amd8111e_pm_ops, amd8111e_suspend, amd8111e_resume); 1912 1920 1913 1921 static struct pci_driver amd8111e_driver = { 1914 - .name = MODULE_NAME, 1922 + .name = MODULE_NAME, 1915 1923 .id_table = amd8111e_pci_tbl, 1916 1924 .probe = amd8111e_probe_one, 1917 1925 .remove = amd8111e_remove_one,