aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/via-velocity.c
diff options
context:
space:
mode:
authorDave Jones <davej@redhat.com>2009-07-20 13:35:21 -0400
committerDavid S. Miller <davem@davemloft.net>2009-07-23 21:01:53 -0400
commitc40674001b162f9218ba2a6f26188177c6a4e763 (patch)
treebe051f8c3f271c8353e70c6e5b798131e17f8ee6 /drivers/net/via-velocity.c
parent83c98a8cd04dd0f848574370594886ba3bf56750 (diff)
Fix up CodingStyle problems in via-velocity.c
Signed-off-by: Dave Jones <davej@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/via-velocity.c')
-rw-r--r--drivers/net/via-velocity.c175
1 files changed, 80 insertions, 95 deletions
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c
index 4ebe2cacf50c..d6a92b794f35 100644
--- a/drivers/net/via-velocity.c
+++ b/drivers/net/via-velocity.c
@@ -61,9 +61,9 @@
61#include <linux/interrupt.h> 61#include <linux/interrupt.h>
62#include <linux/string.h> 62#include <linux/string.h>
63#include <linux/wait.h> 63#include <linux/wait.h>
64#include <asm/io.h> 64#include <linux/io.h>
65#include <linux/if.h> 65#include <linux/if.h>
66#include <asm/uaccess.h> 66#include <linux/uaccess.h>
67#include <linux/proc_fs.h> 67#include <linux/proc_fs.h>
68#include <linux/inetdevice.h> 68#include <linux/inetdevice.h>
69#include <linux/reboot.h> 69#include <linux/reboot.h>
@@ -81,7 +81,7 @@
81#include "via-velocity.h" 81#include "via-velocity.h"
82 82
83 83
84static int velocity_nics = 0; 84static int velocity_nics;
85static int msglevel = MSG_LEVEL_INFO; 85static int msglevel = MSG_LEVEL_INFO;
86 86
87/** 87/**
@@ -93,7 +93,7 @@ static int msglevel = MSG_LEVEL_INFO;
93 * provided mask buffer. 93 * provided mask buffer.
94 */ 94 */
95 95
96static void mac_get_cam_mask(struct mac_regs __iomem * regs, u8 * mask) 96static void mac_get_cam_mask(struct mac_regs __iomem *regs, u8 *mask)
97{ 97{
98 int i; 98 int i;
99 99
@@ -111,7 +111,6 @@ static void mac_get_cam_mask(struct mac_regs __iomem * regs, u8 * mask)
111 111
112 /* Select mar */ 112 /* Select mar */
113 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, &regs->CAMCR); 113 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, &regs->CAMCR);
114
115} 114}
116 115
117 116
@@ -123,7 +122,7 @@ static void mac_get_cam_mask(struct mac_regs __iomem * regs, u8 * mask)
123 * Store a new mask into a CAM 122 * Store a new mask into a CAM
124 */ 123 */
125 124
126static void mac_set_cam_mask(struct mac_regs __iomem * regs, u8 * mask) 125static void mac_set_cam_mask(struct mac_regs __iomem *regs, u8 *mask)
127{ 126{
128 int i; 127 int i;
129 /* Select CAM mask */ 128 /* Select CAM mask */
@@ -131,9 +130,9 @@ static void mac_set_cam_mask(struct mac_regs __iomem * regs, u8 * mask)
131 130
132 writeb(CAMADDR_CAMEN, &regs->CAMADDR); 131 writeb(CAMADDR_CAMEN, &regs->CAMADDR);
133 132
134 for (i = 0; i < 8; i++) { 133 for (i = 0; i < 8; i++)
135 writeb(*mask++, &(regs->MARCAM[i])); 134 writeb(*mask++, &(regs->MARCAM[i]));
136 } 135
137 /* disable CAMEN */ 136 /* disable CAMEN */
138 writeb(0, &regs->CAMADDR); 137 writeb(0, &regs->CAMADDR);
139 138
@@ -141,7 +140,7 @@ static void mac_set_cam_mask(struct mac_regs __iomem * regs, u8 * mask)
141 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, &regs->CAMCR); 140 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, &regs->CAMCR);
142} 141}
143 142
144static void mac_set_vlan_cam_mask(struct mac_regs __iomem * regs, u8 * mask) 143static void mac_set_vlan_cam_mask(struct mac_regs __iomem *regs, u8 *mask)
145{ 144{
146 int i; 145 int i;
147 /* Select CAM mask */ 146 /* Select CAM mask */
@@ -149,9 +148,9 @@ static void mac_set_vlan_cam_mask(struct mac_regs __iomem * regs, u8 * mask)
149 148
150 writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL, &regs->CAMADDR); 149 writeb(CAMADDR_CAMEN | CAMADDR_VCAMSL, &regs->CAMADDR);
151 150
152 for (i = 0; i < 8; i++) { 151 for (i = 0; i < 8; i++)
153 writeb(*mask++, &(regs->MARCAM[i])); 152 writeb(*mask++, &(regs->MARCAM[i]));
154 } 153
155 /* disable CAMEN */ 154 /* disable CAMEN */
156 writeb(0, &regs->CAMADDR); 155 writeb(0, &regs->CAMADDR);
157 156
@@ -168,7 +167,7 @@ static void mac_set_vlan_cam_mask(struct mac_regs __iomem * regs, u8 * mask)
168 * Load an address or vlan tag into a CAM 167 * Load an address or vlan tag into a CAM
169 */ 168 */
170 169
171static void mac_set_cam(struct mac_regs __iomem * regs, int idx, const u8 *addr) 170static void mac_set_cam(struct mac_regs __iomem *regs, int idx, const u8 *addr)
172{ 171{
173 int i; 172 int i;
174 173
@@ -179,9 +178,9 @@ static void mac_set_cam(struct mac_regs __iomem * regs, int idx, const u8 *addr)
179 178
180 writeb(CAMADDR_CAMEN | idx, &regs->CAMADDR); 179 writeb(CAMADDR_CAMEN | idx, &regs->CAMADDR);
181 180
182 for (i = 0; i < 6; i++) { 181 for (i = 0; i < 6; i++)
183 writeb(*addr++, &(regs->MARCAM[i])); 182 writeb(*addr++, &(regs->MARCAM[i]));
184 } 183
185 BYTE_REG_BITS_ON(CAMCR_CAMWR, &regs->CAMCR); 184 BYTE_REG_BITS_ON(CAMCR_CAMWR, &regs->CAMCR);
186 185
187 udelay(10); 186 udelay(10);
@@ -192,7 +191,7 @@ static void mac_set_cam(struct mac_regs __iomem * regs, int idx, const u8 *addr)
192 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, &regs->CAMCR); 191 BYTE_REG_BITS_SET(CAMCR_PS_MAR, CAMCR_PS1 | CAMCR_PS0, &regs->CAMCR);
193} 192}
194 193
195static void mac_set_vlan_cam(struct mac_regs __iomem * regs, int idx, 194static void mac_set_vlan_cam(struct mac_regs __iomem *regs, int idx,
196 const u8 *addr) 195 const u8 *addr)
197{ 196{
198 197
@@ -224,7 +223,7 @@ static void mac_set_vlan_cam(struct mac_regs __iomem * regs, int idx,
224 * the rest of the logic from the result of sleep/wakeup 223 * the rest of the logic from the result of sleep/wakeup
225 */ 224 */
226 225
227static void mac_wol_reset(struct mac_regs __iomem * regs) 226static void mac_wol_reset(struct mac_regs __iomem *regs)
228{ 227{
229 228
230 /* Turn off SWPTAG right after leaving power mode */ 229 /* Turn off SWPTAG right after leaving power mode */
@@ -253,10 +252,10 @@ MODULE_AUTHOR("VIA Networking Technologies, Inc.");
253MODULE_LICENSE("GPL"); 252MODULE_LICENSE("GPL");
254MODULE_DESCRIPTION("VIA Networking Velocity Family Gigabit Ethernet Adapter Driver"); 253MODULE_DESCRIPTION("VIA Networking Velocity Family Gigabit Ethernet Adapter Driver");
255 254
256#define VELOCITY_PARAM(N,D) \ 255#define VELOCITY_PARAM(N, D) \
257 static int N[MAX_UNITS]=OPTION_DEFAULT;\ 256 static int N[MAX_UNITS] = OPTION_DEFAULT;\
258 module_param_array(N, int, NULL, 0); \ 257 module_param_array(N, int, NULL, 0); \
259 MODULE_PARM_DESC(N, D); 258 MODULE_PARM_DESC(N, D);
260 259
261#define RX_DESC_MIN 64 260#define RX_DESC_MIN 64
262#define RX_DESC_MAX 255 261#define RX_DESC_MAX 255
@@ -336,8 +335,8 @@ VELOCITY_PARAM(flow_control, "Enable flow control ability");
336 4: indicate 10Mbps full duplex mode 335 4: indicate 10Mbps full duplex mode
337 336
338 Note: 337 Note:
339 if EEPROM have been set to the force mode, this option is ignored 338 if EEPROM have been set to the force mode, this option is ignored
340 by driver. 339 by driver.
341*/ 340*/
342VELOCITY_PARAM(speed_duplex, "Setting the speed and duplex mode"); 341VELOCITY_PARAM(speed_duplex, "Setting the speed and duplex mode");
343 342
@@ -391,14 +390,14 @@ static void mii_init(struct velocity_info *vptr, u32 mii_status);
391static u32 velocity_get_link(struct net_device *dev); 390static u32 velocity_get_link(struct net_device *dev);
392static u32 velocity_get_opt_media_mode(struct velocity_info *vptr); 391static u32 velocity_get_opt_media_mode(struct velocity_info *vptr);
393static void velocity_print_link_status(struct velocity_info *vptr); 392static void velocity_print_link_status(struct velocity_info *vptr);
394static void safe_disable_mii_autopoll(struct mac_regs __iomem * regs); 393static void safe_disable_mii_autopoll(struct mac_regs __iomem *regs);
395static void velocity_shutdown(struct velocity_info *vptr); 394static void velocity_shutdown(struct velocity_info *vptr);
396static void enable_flow_control_ability(struct velocity_info *vptr); 395static void enable_flow_control_ability(struct velocity_info *vptr);
397static void enable_mii_autopoll(struct mac_regs __iomem * regs); 396static void enable_mii_autopoll(struct mac_regs __iomem *regs);
398static int velocity_mii_read(struct mac_regs __iomem *, u8 byIdx, u16 * pdata); 397static int velocity_mii_read(struct mac_regs __iomem *, u8 byIdx, u16 *pdata);
399static int velocity_mii_write(struct mac_regs __iomem *, u8 byMiiAddr, u16 data); 398static int velocity_mii_write(struct mac_regs __iomem *, u8 byMiiAddr, u16 data);
400static u32 mii_check_media_mode(struct mac_regs __iomem * regs); 399static u32 mii_check_media_mode(struct mac_regs __iomem *regs);
401static u32 check_connection_type(struct mac_regs __iomem * regs); 400static u32 check_connection_type(struct mac_regs __iomem *regs);
402static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status); 401static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status);
403 402
404#ifdef CONFIG_PM 403#ifdef CONFIG_PM
@@ -550,7 +549,7 @@ static void __devinit velocity_set_int_opt(int *opt, int val, int min, int max,
550 * we don't duplicate code for each option. 549 * we don't duplicate code for each option.
551 */ 550 */
552 551
553static void __devinit velocity_set_bool_opt(u32 * opt, int val, int def, u32 flag, char *name, const char *devname) 552static void __devinit velocity_set_bool_opt(u32 *opt, int val, int def, u32 flag, char *name, const char *devname)
554{ 553{
555 (*opt) &= (~flag); 554 (*opt) &= (~flag);
556 if (val == -1) 555 if (val == -1)
@@ -604,7 +603,7 @@ static void __devinit velocity_get_options(struct velocity_opt *opts, int index,
604 603
605static void velocity_init_cam_filter(struct velocity_info *vptr) 604static void velocity_init_cam_filter(struct velocity_info *vptr)
606{ 605{
607 struct mac_regs __iomem * regs = vptr->mac_regs; 606 struct mac_regs __iomem *regs = vptr->mac_regs;
608 607
609 /* Turn on MCFG_PQEN, turn off MCFG_RTGOPT */ 608 /* Turn on MCFG_PQEN, turn off MCFG_RTGOPT */
610 WORD_REG_BITS_SET(MCFG_PQEN, MCFG_RTGOPT, &regs->MCFG); 609 WORD_REG_BITS_SET(MCFG_PQEN, MCFG_RTGOPT, &regs->MCFG);
@@ -647,19 +646,19 @@ static void velocity_vlan_rx_add_vid(struct net_device *dev, unsigned short vid)
647{ 646{
648 struct velocity_info *vptr = netdev_priv(dev); 647 struct velocity_info *vptr = netdev_priv(dev);
649 648
650 spin_lock_irq(&vptr->lock); 649 spin_lock_irq(&vptr->lock);
651 velocity_init_cam_filter(vptr); 650 velocity_init_cam_filter(vptr);
652 spin_unlock_irq(&vptr->lock); 651 spin_unlock_irq(&vptr->lock);
653} 652}
654 653
655static void velocity_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid) 654static void velocity_vlan_rx_kill_vid(struct net_device *dev, unsigned short vid)
656{ 655{
657 struct velocity_info *vptr = netdev_priv(dev); 656 struct velocity_info *vptr = netdev_priv(dev);
658 657
659 spin_lock_irq(&vptr->lock); 658 spin_lock_irq(&vptr->lock);
660 vlan_group_set_device(vptr->vlgrp, vid, NULL); 659 vlan_group_set_device(vptr->vlgrp, vid, NULL);
661 velocity_init_cam_filter(vptr); 660 velocity_init_cam_filter(vptr);
662 spin_unlock_irq(&vptr->lock); 661 spin_unlock_irq(&vptr->lock);
663} 662}
664 663
665static void velocity_init_rx_ring_indexes(struct velocity_info *vptr) 664static void velocity_init_rx_ring_indexes(struct velocity_info *vptr)
@@ -678,7 +677,7 @@ static void velocity_init_rx_ring_indexes(struct velocity_info *vptr)
678static void velocity_rx_reset(struct velocity_info *vptr) 677static void velocity_rx_reset(struct velocity_info *vptr)
679{ 678{
680 679
681 struct mac_regs __iomem * regs = vptr->mac_regs; 680 struct mac_regs __iomem *regs = vptr->mac_regs;
682 int i; 681 int i;
683 682
684 velocity_init_rx_ring_indexes(vptr); 683 velocity_init_rx_ring_indexes(vptr);
@@ -707,7 +706,7 @@ static void velocity_rx_reset(struct velocity_info *vptr)
707static void velocity_init_registers(struct velocity_info *vptr, 706static void velocity_init_registers(struct velocity_info *vptr,
708 enum velocity_init_type type) 707 enum velocity_init_type type)
709{ 708{
710 struct mac_regs __iomem * regs = vptr->mac_regs; 709 struct mac_regs __iomem *regs = vptr->mac_regs;
711 int i, mii_status; 710 int i, mii_status;
712 711
713 mac_wol_reset(regs); 712 mac_wol_reset(regs);
@@ -750,9 +749,9 @@ static void velocity_init_registers(struct velocity_info *vptr,
750 mdelay(5); 749 mdelay(5);
751 750
752 mac_eeprom_reload(regs); 751 mac_eeprom_reload(regs);
753 for (i = 0; i < 6; i++) { 752 for (i = 0; i < 6; i++)
754 writeb(vptr->dev->dev_addr[i], &(regs->PAR[i])); 753 writeb(vptr->dev->dev_addr[i], &(regs->PAR[i]));
755 } 754
756 /* 755 /*
757 * clear Pre_ACPI bit. 756 * clear Pre_ACPI bit.
758 */ 757 */
@@ -829,7 +828,7 @@ static void velocity_init_registers(struct velocity_info *vptr,
829 828
830static int velocity_soft_reset(struct velocity_info *vptr) 829static int velocity_soft_reset(struct velocity_info *vptr)
831{ 830{
832 struct mac_regs __iomem * regs = vptr->mac_regs; 831 struct mac_regs __iomem *regs = vptr->mac_regs;
833 int i = 0; 832 int i = 0;
834 833
835 writel(CR0_SFRST, &regs->CR0Set); 834 writel(CR0_SFRST, &regs->CR0Set);
@@ -881,7 +880,7 @@ static int __devinit velocity_found1(struct pci_dev *pdev, const struct pci_devi
881 const char *drv_string; 880 const char *drv_string;
882 const struct velocity_info_tbl *info = &chip_info_table[ent->driver_data]; 881 const struct velocity_info_tbl *info = &chip_info_table[ent->driver_data];
883 struct velocity_info *vptr; 882 struct velocity_info *vptr;
884 struct mac_regs __iomem * regs; 883 struct mac_regs __iomem *regs;
885 int ret = -ENOMEM; 884 int ret = -ENOMEM;
886 885
887 /* FIXME: this driver, like almost all other ethernet drivers, 886 /* FIXME: this driver, like almost all other ethernet drivers,
@@ -1311,7 +1310,7 @@ static int velocity_init_td_ring(struct velocity_info *vptr)
1311 sizeof(struct velocity_td_info), 1310 sizeof(struct velocity_td_info),
1312 GFP_KERNEL); 1311 GFP_KERNEL);
1313 if (!vptr->tx.infos[j]) { 1312 if (!vptr->tx.infos[j]) {
1314 while(--j >= 0) 1313 while (--j >= 0)
1315 kfree(vptr->tx.infos[j]); 1314 kfree(vptr->tx.infos[j]);
1316 return -ENOMEM; 1315 return -ENOMEM;
1317 } 1316 }
@@ -1328,15 +1327,14 @@ static int velocity_init_td_ring(struct velocity_info *vptr)
1328static void velocity_free_td_ring_entry(struct velocity_info *vptr, 1327static void velocity_free_td_ring_entry(struct velocity_info *vptr,
1329 int q, int n) 1328 int q, int n)
1330{ 1329{
1331 struct velocity_td_info * td_info = &(vptr->tx.infos[q][n]); 1330 struct velocity_td_info *td_info = &(vptr->tx.infos[q][n]);
1332 int i; 1331 int i;
1333 1332
1334 if (td_info == NULL) 1333 if (td_info == NULL)
1335 return; 1334 return;
1336 1335
1337 if (td_info->skb) { 1336 if (td_info->skb) {
1338 for (i = 0; i < td_info->nskb_dma; i++) 1337 for (i = 0; i < td_info->nskb_dma; i++) {
1339 {
1340 if (td_info->skb_dma[i]) { 1338 if (td_info->skb_dma[i]) {
1341 pci_unmap_single(vptr->pdev, td_info->skb_dma[i], 1339 pci_unmap_single(vptr->pdev, td_info->skb_dma[i],
1342 td_info->skb->len, PCI_DMA_TODEVICE); 1340 td_info->skb->len, PCI_DMA_TODEVICE);
@@ -1363,10 +1361,9 @@ static void velocity_free_td_ring(struct velocity_info *vptr)
1363 for (j = 0; j < vptr->tx.numq; j++) { 1361 for (j = 0; j < vptr->tx.numq; j++) {
1364 if (vptr->tx.infos[j] == NULL) 1362 if (vptr->tx.infos[j] == NULL)
1365 continue; 1363 continue;
1366 for (i = 0; i < vptr->options.numtx; i++) { 1364 for (i = 0; i < vptr->options.numtx; i++)
1367 velocity_free_td_ring_entry(vptr, j, i); 1365 velocity_free_td_ring_entry(vptr, j, i);
1368 1366
1369 }
1370 kfree(vptr->tx.infos[j]); 1367 kfree(vptr->tx.infos[j]);
1371 vptr->tx.infos[j] = NULL; 1368 vptr->tx.infos[j] = NULL;
1372 } 1369 }
@@ -1447,9 +1444,8 @@ static inline void velocity_rx_csum(struct rx_desc *rd, struct sk_buff *skb)
1447 if (rd->rdesc1.CSM & CSM_IPOK) { 1444 if (rd->rdesc1.CSM & CSM_IPOK) {
1448 if ((rd->rdesc1.CSM & CSM_TCPKT) || 1445 if ((rd->rdesc1.CSM & CSM_TCPKT) ||
1449 (rd->rdesc1.CSM & CSM_UDPKT)) { 1446 (rd->rdesc1.CSM & CSM_UDPKT)) {
1450 if (!(rd->rdesc1.CSM & CSM_TUPOK)) { 1447 if (!(rd->rdesc1.CSM & CSM_TUPOK))
1451 return; 1448 return;
1452 }
1453 } 1449 }
1454 skb->ip_summed = CHECKSUM_UNNECESSARY; 1450 skb->ip_summed = CHECKSUM_UNNECESSARY;
1455 } 1451 }
@@ -1671,9 +1667,8 @@ static int velocity_tx_srv(struct velocity_info *vptr, u32 status)
1671 } 1667 }
1672 vptr->tx.tail[qnum] = idx; 1668 vptr->tx.tail[qnum] = idx;
1673 1669
1674 if (AVAIL_TD(vptr, qnum) < 1) { 1670 if (AVAIL_TD(vptr, qnum) < 1)
1675 full = 1; 1671 full = 1;
1676 }
1677 } 1672 }
1678 /* 1673 /*
1679 * Look to see if we should kick the transmit network 1674 * Look to see if we should kick the transmit network
@@ -1751,7 +1746,7 @@ static void velocity_error(struct velocity_info *vptr, int status)
1751{ 1746{
1752 1747
1753 if (status & ISR_TXSTLI) { 1748 if (status & ISR_TXSTLI) {
1754 struct mac_regs __iomem * regs = vptr->mac_regs; 1749 struct mac_regs __iomem *regs = vptr->mac_regs;
1755 1750
1756 printk(KERN_ERR "TD structure error TDindex=%hx\n", readw(&regs->TDIdx[0])); 1751 printk(KERN_ERR "TD structure error TDindex=%hx\n", readw(&regs->TDIdx[0]));
1757 BYTE_REG_BITS_ON(TXESR_TDSTR, &regs->TXESR); 1752 BYTE_REG_BITS_ON(TXESR_TDSTR, &regs->TXESR);
@@ -1763,7 +1758,7 @@ static void velocity_error(struct velocity_info *vptr, int status)
1763 } 1758 }
1764 1759
1765 if (status & ISR_SRCI) { 1760 if (status & ISR_SRCI) {
1766 struct mac_regs __iomem * regs = vptr->mac_regs; 1761 struct mac_regs __iomem *regs = vptr->mac_regs;
1767 int linked; 1762 int linked;
1768 1763
1769 if (vptr->options.spd_dpx == SPD_DPX_AUTO) { 1764 if (vptr->options.spd_dpx == SPD_DPX_AUTO) {
@@ -1783,11 +1778,10 @@ static void velocity_error(struct velocity_info *vptr, int status)
1783 /* 1778 /*
1784 * Only enable CD heart beat counter in 10HD mode 1779 * Only enable CD heart beat counter in 10HD mode
1785 */ 1780 */
1786 if (!(vptr->mii_status & VELOCITY_DUPLEX_FULL) && (vptr->mii_status & VELOCITY_SPEED_10)) { 1781 if (!(vptr->mii_status & VELOCITY_DUPLEX_FULL) && (vptr->mii_status & VELOCITY_SPEED_10))
1787 BYTE_REG_BITS_OFF(TESTCFG_HBDIS, &regs->TESTCFG); 1782 BYTE_REG_BITS_OFF(TESTCFG_HBDIS, &regs->TESTCFG);
1788 } else { 1783 else
1789 BYTE_REG_BITS_ON(TESTCFG_HBDIS, &regs->TESTCFG); 1784 BYTE_REG_BITS_ON(TESTCFG_HBDIS, &regs->TESTCFG);
1790 }
1791 } 1785 }
1792 /* 1786 /*
1793 * Get link status from PHYSR0 1787 * Get link status from PHYSR0
@@ -2023,7 +2017,7 @@ out_0:
2023 2017
2024static void velocity_shutdown(struct velocity_info *vptr) 2018static void velocity_shutdown(struct velocity_info *vptr)
2025{ 2019{
2026 struct mac_regs __iomem * regs = vptr->mac_regs; 2020 struct mac_regs __iomem *regs = vptr->mac_regs;
2027 mac_disable_int(regs); 2021 mac_disable_int(regs);
2028 writel(CR0_STOP, &regs->CR0Set); 2022 writel(CR0_STOP, &regs->CR0Set);
2029 writew(0xFFFF, &regs->TDCSRClr); 2023 writew(0xFFFF, &regs->TDCSRClr);
@@ -2195,8 +2189,7 @@ static irqreturn_t velocity_intr(int irq, void *dev_instance)
2195 if (isr_status & (ISR_PTXI | ISR_PPTXI)) 2189 if (isr_status & (ISR_PTXI | ISR_PPTXI))
2196 max_count += velocity_tx_srv(vptr, isr_status); 2190 max_count += velocity_tx_srv(vptr, isr_status);
2197 isr_status = mac_read_isr(vptr->mac_regs); 2191 isr_status = mac_read_isr(vptr->mac_regs);
2198 if (max_count > vptr->options.int_works) 2192 if (max_count > vptr->options.int_works) {
2199 {
2200 printk(KERN_WARNING "%s: excessive work at interrupt.\n", 2193 printk(KERN_WARNING "%s: excessive work at interrupt.\n",
2201 dev->name); 2194 dev->name);
2202 max_count = 0; 2195 max_count = 0;
@@ -2221,7 +2214,7 @@ static irqreturn_t velocity_intr(int irq, void *dev_instance)
2221static void velocity_set_multi(struct net_device *dev) 2214static void velocity_set_multi(struct net_device *dev)
2222{ 2215{
2223 struct velocity_info *vptr = netdev_priv(dev); 2216 struct velocity_info *vptr = netdev_priv(dev);
2224 struct mac_regs __iomem * regs = vptr->mac_regs; 2217 struct mac_regs __iomem *regs = vptr->mac_regs;
2225 u8 rx_mode; 2218 u8 rx_mode;
2226 int i; 2219 int i;
2227 struct dev_mc_list *mclist; 2220 struct dev_mc_list *mclist;
@@ -2270,7 +2263,7 @@ static struct net_device_stats *velocity_get_stats(struct net_device *dev)
2270 struct velocity_info *vptr = netdev_priv(dev); 2263 struct velocity_info *vptr = netdev_priv(dev);
2271 2264
2272 /* If the hardware is down, don't touch MII */ 2265 /* If the hardware is down, don't touch MII */
2273 if(!netif_running(dev)) 2266 if (!netif_running(dev))
2274 return &dev->stats; 2267 return &dev->stats;
2275 2268
2276 spin_lock_irq(&vptr->lock); 2269 spin_lock_irq(&vptr->lock);
@@ -2473,7 +2466,7 @@ static void mii_init(struct velocity_info *vptr, u32 mii_status)
2473 * Turn off the autopoll and wait for it to disable on the chip 2466 * Turn off the autopoll and wait for it to disable on the chip
2474 */ 2467 */
2475 2468
2476static void safe_disable_mii_autopoll(struct mac_regs __iomem * regs) 2469static void safe_disable_mii_autopoll(struct mac_regs __iomem *regs)
2477{ 2470{
2478 u16 ww; 2471 u16 ww;
2479 2472
@@ -2494,7 +2487,7 @@ static void safe_disable_mii_autopoll(struct mac_regs __iomem * regs)
2494 * hardware. Wait for it to enable. 2487 * hardware. Wait for it to enable.
2495 */ 2488 */
2496 2489
2497static void enable_mii_autopoll(struct mac_regs __iomem * regs) 2490static void enable_mii_autopoll(struct mac_regs __iomem *regs)
2498{ 2491{
2499 int ii; 2492 int ii;
2500 2493
@@ -2644,7 +2637,7 @@ static void mii_set_auto_on(struct velocity_info *vptr)
2644 2637
2645 2638
2646/* 2639/*
2647static void mii_set_auto_off(struct velocity_info * vptr) 2640static void mii_set_auto_off(struct velocity_info *vptr)
2648{ 2641{
2649 MII_REG_BITS_OFF(BMCR_AUTO, MII_REG_BMCR, vptr->mac_regs); 2642 MII_REG_BITS_OFF(BMCR_AUTO, MII_REG_BMCR, vptr->mac_regs);
2650} 2643}
@@ -2698,7 +2691,7 @@ static void set_mii_flow_control(struct velocity_info *vptr)
2698static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status) 2691static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
2699{ 2692{
2700 u32 curr_status; 2693 u32 curr_status;
2701 struct mac_regs __iomem * regs = vptr->mac_regs; 2694 struct mac_regs __iomem *regs = vptr->mac_regs;
2702 2695
2703 vptr->mii_status = mii_check_media_mode(vptr->mac_regs); 2696 vptr->mii_status = mii_check_media_mode(vptr->mac_regs);
2704 curr_status = vptr->mii_status & (~VELOCITY_LINK_FAIL); 2697 curr_status = vptr->mii_status & (~VELOCITY_LINK_FAIL);
@@ -2717,9 +2710,8 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
2717 } 2710 }
2718 */ 2711 */
2719 2712
2720 if (PHYID_GET_PHY_ID(vptr->phy_id) == PHYID_CICADA_CS8201) { 2713 if (PHYID_GET_PHY_ID(vptr->phy_id) == PHYID_CICADA_CS8201)
2721 MII_REG_BITS_ON(AUXCR_MDPPS, MII_REG_AUXCR, vptr->mac_regs); 2714 MII_REG_BITS_ON(AUXCR_MDPPS, MII_REG_AUXCR, vptr->mac_regs);
2722 }
2723 2715
2724 /* 2716 /*
2725 * If connection type is AUTO 2717 * If connection type is AUTO
@@ -2768,11 +2760,11 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
2768 2760
2769 MII_REG_BITS_OFF(G1000CR_1000FD | G1000CR_1000, MII_REG_G1000CR, vptr->mac_regs); 2761 MII_REG_BITS_OFF(G1000CR_1000FD | G1000CR_1000, MII_REG_G1000CR, vptr->mac_regs);
2770 2762
2771 if (!(mii_status & VELOCITY_DUPLEX_FULL) && (mii_status & VELOCITY_SPEED_10)) { 2763 if (!(mii_status & VELOCITY_DUPLEX_FULL) && (mii_status & VELOCITY_SPEED_10))
2772 BYTE_REG_BITS_OFF(TESTCFG_HBDIS, &regs->TESTCFG); 2764 BYTE_REG_BITS_OFF(TESTCFG_HBDIS, &regs->TESTCFG);
2773 } else { 2765 else
2774 BYTE_REG_BITS_ON(TESTCFG_HBDIS, &regs->TESTCFG); 2766 BYTE_REG_BITS_ON(TESTCFG_HBDIS, &regs->TESTCFG);
2775 } 2767
2776 /* MII_REG_BITS_OFF(BMCR_SPEED1G, MII_REG_BMCR, vptr->mac_regs); */ 2768 /* MII_REG_BITS_OFF(BMCR_SPEED1G, MII_REG_BMCR, vptr->mac_regs); */
2777 velocity_mii_read(vptr->mac_regs, MII_REG_ANAR, &ANAR); 2769 velocity_mii_read(vptr->mac_regs, MII_REG_ANAR, &ANAR);
2778 ANAR &= (~(ANAR_TXFD | ANAR_TX | ANAR_10FD | ANAR_10)); 2770 ANAR &= (~(ANAR_TXFD | ANAR_TX | ANAR_10FD | ANAR_10));
@@ -2805,7 +2797,7 @@ static int velocity_set_media_mode(struct velocity_info *vptr, u32 mii_status)
2805 * accordingly 2797 * accordingly
2806 */ 2798 */
2807 2799
2808static u32 mii_check_media_mode(struct mac_regs __iomem * regs) 2800static u32 mii_check_media_mode(struct mac_regs __iomem *regs)
2809{ 2801{
2810 u32 status = 0; 2802 u32 status = 0;
2811 u16 ANAR; 2803 u16 ANAR;
@@ -2841,7 +2833,7 @@ static u32 mii_check_media_mode(struct mac_regs __iomem * regs)
2841 return status; 2833 return status;
2842} 2834}
2843 2835
2844static u32 check_connection_type(struct mac_regs __iomem * regs) 2836static u32 check_connection_type(struct mac_regs __iomem *regs)
2845{ 2837{
2846 u32 status = 0; 2838 u32 status = 0;
2847 u8 PHYSR0; 2839 u8 PHYSR0;
@@ -2886,7 +2878,7 @@ static u32 check_connection_type(struct mac_regs __iomem * regs)
2886static void enable_flow_control_ability(struct velocity_info *vptr) 2878static void enable_flow_control_ability(struct velocity_info *vptr)
2887{ 2879{
2888 2880
2889 struct mac_regs __iomem * regs = vptr->mac_regs; 2881 struct mac_regs __iomem *regs = vptr->mac_regs;
2890 2882
2891 switch (vptr->options.flow_cntl) { 2883 switch (vptr->options.flow_cntl) {
2892 2884
@@ -2963,7 +2955,7 @@ static void velocity_ethtool_down(struct net_device *dev)
2963static int velocity_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 2955static int velocity_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
2964{ 2956{
2965 struct velocity_info *vptr = netdev_priv(dev); 2957 struct velocity_info *vptr = netdev_priv(dev);
2966 struct mac_regs __iomem * regs = vptr->mac_regs; 2958 struct mac_regs __iomem *regs = vptr->mac_regs;
2967 u32 status; 2959 u32 status;
2968 status = check_connection_type(vptr->mac_regs); 2960 status = check_connection_type(vptr->mac_regs);
2969 2961
@@ -3020,7 +3012,7 @@ static int velocity_set_settings(struct net_device *dev, struct ethtool_cmd *cmd
3020static u32 velocity_get_link(struct net_device *dev) 3012static u32 velocity_get_link(struct net_device *dev)
3021{ 3013{
3022 struct velocity_info *vptr = netdev_priv(dev); 3014 struct velocity_info *vptr = netdev_priv(dev);
3023 struct mac_regs __iomem * regs = vptr->mac_regs; 3015 struct mac_regs __iomem *regs = vptr->mac_regs;
3024 return BYTE_REG_BITS_IS_ON(PHYSR0_LINKGD, &regs->PHYSR0) ? 1 : 0; 3016 return BYTE_REG_BITS_IS_ON(PHYSR0_LINKGD, &regs->PHYSR0) ? 1 : 0;
3025} 3017}
3026 3018
@@ -3116,7 +3108,7 @@ static const struct ethtool_ops velocity_ethtool_ops = {
3116static int velocity_mii_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 3108static int velocity_mii_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
3117{ 3109{
3118 struct velocity_info *vptr = netdev_priv(dev); 3110 struct velocity_info *vptr = netdev_priv(dev);
3119 struct mac_regs __iomem * regs = vptr->mac_regs; 3111 struct mac_regs __iomem *regs = vptr->mac_regs;
3120 unsigned long flags; 3112 unsigned long flags;
3121 struct mii_ioctl_data *miidata = if_mii(ifr); 3113 struct mii_ioctl_data *miidata = if_mii(ifr);
3122 int err; 3114 int err;
@@ -3128,7 +3120,7 @@ static int velocity_mii_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd
3128 case SIOCGMIIREG: 3120 case SIOCGMIIREG:
3129 if (!capable(CAP_NET_ADMIN)) 3121 if (!capable(CAP_NET_ADMIN))
3130 return -EPERM; 3122 return -EPERM;
3131 if(velocity_mii_read(vptr->mac_regs, miidata->reg_num & 0x1f, &(miidata->val_out)) < 0) 3123 if (velocity_mii_read(vptr->mac_regs, miidata->reg_num & 0x1f, &(miidata->val_out)) < 0)
3132 return -ETIMEDOUT; 3124 return -ETIMEDOUT;
3133 break; 3125 break;
3134 case SIOCSMIIREG: 3126 case SIOCSMIIREG:
@@ -3138,7 +3130,7 @@ static int velocity_mii_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd
3138 err = velocity_mii_write(vptr->mac_regs, miidata->reg_num & 0x1f, miidata->val_in); 3130 err = velocity_mii_write(vptr->mac_regs, miidata->reg_num & 0x1f, miidata->val_in);
3139 spin_unlock_irqrestore(&vptr->lock, flags); 3131 spin_unlock_irqrestore(&vptr->lock, flags);
3140 check_connection_type(vptr->mac_regs); 3132 check_connection_type(vptr->mac_regs);
3141 if(err) 3133 if (err)
3142 return err; 3134 return err;
3143 break; 3135 break;
3144 default: 3136 default:
@@ -3160,9 +3152,9 @@ static int velocity_mii_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd
3160 * power down states 3152 * power down states
3161 */ 3153 */
3162 3154
3163static void velocity_save_context(struct velocity_info *vptr, struct velocity_context * context) 3155static void velocity_save_context(struct velocity_info *vptr, struct velocity_context *context)
3164{ 3156{
3165 struct mac_regs __iomem * regs = vptr->mac_regs; 3157 struct mac_regs __iomem *regs = vptr->mac_regs;
3166 u16 i; 3158 u16 i;
3167 u8 __iomem *ptr = (u8 __iomem *)regs; 3159 u8 __iomem *ptr = (u8 __iomem *)regs;
3168 3160
@@ -3188,13 +3180,12 @@ static void velocity_save_context(struct velocity_info *vptr, struct velocity_co
3188 3180
3189static void velocity_restore_context(struct velocity_info *vptr, struct velocity_context *context) 3181static void velocity_restore_context(struct velocity_info *vptr, struct velocity_context *context)
3190{ 3182{
3191 struct mac_regs __iomem * regs = vptr->mac_regs; 3183 struct mac_regs __iomem *regs = vptr->mac_regs;
3192 int i; 3184 int i;
3193 u8 __iomem *ptr = (u8 __iomem *)regs; 3185 u8 __iomem *ptr = (u8 __iomem *)regs;
3194 3186
3195 for (i = MAC_REG_PAR; i < MAC_REG_CR0_SET; i += 4) { 3187 for (i = MAC_REG_PAR; i < MAC_REG_CR0_SET; i += 4)
3196 writel(*((u32 *) (context->mac_reg + i)), ptr + i); 3188 writel(*((u32 *) (context->mac_reg + i)), ptr + i);
3197 }
3198 3189
3199 /* Just skip cr0 */ 3190 /* Just skip cr0 */
3200 for (i = MAC_REG_CR1_SET; i < MAC_REG_CR0_CLR; i++) { 3191 for (i = MAC_REG_CR1_SET; i < MAC_REG_CR0_CLR; i++) {
@@ -3204,18 +3195,14 @@ static void velocity_restore_context(struct velocity_info *vptr, struct velocity
3204 writeb(*((u8 *) (context->mac_reg + i)), ptr + i); 3195 writeb(*((u8 *) (context->mac_reg + i)), ptr + i);
3205 } 3196 }
3206 3197
3207 for (i = MAC_REG_MAR; i < MAC_REG_IMR; i += 4) { 3198 for (i = MAC_REG_MAR; i < MAC_REG_IMR; i += 4)
3208 writel(*((u32 *) (context->mac_reg + i)), ptr + i); 3199 writel(*((u32 *) (context->mac_reg + i)), ptr + i);
3209 }
3210 3200
3211 for (i = MAC_REG_RDBASE_LO; i < MAC_REG_FIFO_TEST0; i += 4) { 3201 for (i = MAC_REG_RDBASE_LO; i < MAC_REG_FIFO_TEST0; i += 4)
3212 writel(*((u32 *) (context->mac_reg + i)), ptr + i); 3202 writel(*((u32 *) (context->mac_reg + i)), ptr + i);
3213 }
3214 3203
3215 for (i = MAC_REG_TDCSR_SET; i <= MAC_REG_RDCSR_SET; i++) { 3204 for (i = MAC_REG_TDCSR_SET; i <= MAC_REG_RDCSR_SET; i++)
3216 writeb(*((u8 *) (context->mac_reg + i)), ptr + i); 3205 writeb(*((u8 *) (context->mac_reg + i)), ptr + i);
3217 }
3218
3219} 3206}
3220 3207
3221/** 3208/**
@@ -3227,7 +3214,7 @@ static void velocity_restore_context(struct velocity_info *vptr, struct velocity
3227 * we are interested in. 3214 * we are interested in.
3228 */ 3215 */
3229 3216
3230static u16 wol_calc_crc(int size, u8 * pattern, u8 *mask_pattern) 3217static u16 wol_calc_crc(int size, u8 *pattern, u8 *mask_pattern)
3231{ 3218{
3232 u16 crc = 0xFFFF; 3219 u16 crc = 0xFFFF;
3233 u8 mask; 3220 u8 mask;
@@ -3266,7 +3253,7 @@ static u16 wol_calc_crc(int size, u8 * pattern, u8 *mask_pattern)
3266 3253
3267static int velocity_set_wol(struct velocity_info *vptr) 3254static int velocity_set_wol(struct velocity_info *vptr)
3268{ 3255{
3269 struct mac_regs __iomem * regs = vptr->mac_regs; 3256 struct mac_regs __iomem *regs = vptr->mac_regs;
3270 static u8 buf[256]; 3257 static u8 buf[256];
3271 int i; 3258 int i;
3272 3259
@@ -3284,9 +3271,8 @@ static int velocity_set_wol(struct velocity_info *vptr)
3284 writew((WOLCR_LINKON_EN|WOLCR_LINKOFF_EN), &regs->WOLCRSet); 3271 writew((WOLCR_LINKON_EN|WOLCR_LINKOFF_EN), &regs->WOLCRSet);
3285 */ 3272 */
3286 3273
3287 if (vptr->wol_opts & VELOCITY_WOL_UCAST) { 3274 if (vptr->wol_opts & VELOCITY_WOL_UCAST)
3288 writew(WOLCR_UNICAST_EN, &regs->WOLCRSet); 3275 writew(WOLCR_UNICAST_EN, &regs->WOLCRSet);
3289 }
3290 3276
3291 if (vptr->wol_opts & VELOCITY_WOL_ARP) { 3277 if (vptr->wol_opts & VELOCITY_WOL_ARP) {
3292 struct arp_packet *arp = (struct arp_packet *) buf; 3278 struct arp_packet *arp = (struct arp_packet *) buf;
@@ -3347,7 +3333,7 @@ static int velocity_suspend(struct pci_dev *pdev, pm_message_t state)
3347 struct velocity_info *vptr = netdev_priv(dev); 3333 struct velocity_info *vptr = netdev_priv(dev);
3348 unsigned long flags; 3334 unsigned long flags;
3349 3335
3350 if(!netif_running(vptr->dev)) 3336 if (!netif_running(vptr->dev))
3351 return 0; 3337 return 0;
3352 3338
3353 netif_device_detach(vptr->dev); 3339 netif_device_detach(vptr->dev);
@@ -3382,7 +3368,7 @@ static int velocity_resume(struct pci_dev *pdev)
3382 unsigned long flags; 3368 unsigned long flags;
3383 int i; 3369 int i;
3384 3370
3385 if(!netif_running(vptr->dev)) 3371 if (!netif_running(vptr->dev))
3386 return 0; 3372 return 0;
3387 3373
3388 pci_set_power_state(pdev, PCI_D0); 3374 pci_set_power_state(pdev, PCI_D0);
@@ -3399,9 +3385,8 @@ static int velocity_resume(struct pci_dev *pdev)
3399 velocity_tx_srv(vptr, 0); 3385 velocity_tx_srv(vptr, 0);
3400 3386
3401 for (i = 0; i < vptr->tx.numq; i++) { 3387 for (i = 0; i < vptr->tx.numq; i++) {
3402 if (vptr->tx.used[i]) { 3388 if (vptr->tx.used[i])
3403 mac_tx_queue_wake(vptr->mac_regs, i); 3389 mac_tx_queue_wake(vptr->mac_regs, i);
3404 }
3405 } 3390 }
3406 3391
3407 mac_enable_int(vptr->mac_regs); 3392 mac_enable_int(vptr->mac_regs);