1 diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c b/drivers/net/ethernet/sgi/ioc3-eth.c
2 index b58c89fdc348..e5d68cba4766 100644
3 --- a/drivers/net/ethernet/sgi/ioc3-eth.c
4 +++ b/drivers/net/ethernet/sgi/ioc3-eth.c
6 #include <asm/pci/bridge.h>
9 - * 64 RX buffers. This is tunable in the range of 16 <= x < 512. The
10 - * value must be a power of two.
11 + * 64 RX buffers. This is tunable in the range of 16 <= x < 512.
12 + * The value must be a power of two.
16 -#define ETCSR_FD ((17<<ETCSR_IPGR2_SHIFT) | (11<<ETCSR_IPGR1_SHIFT) | 21)
17 -#define ETCSR_HD ((21<<ETCSR_IPGR2_SHIFT) | (21<<ETCSR_IPGR1_SHIFT) | 21)
18 +#define ETCSR_FD ((17 << ETCSR_IPGR2_SHIFT) | (11 << ETCSR_IPGR1_SHIFT) | 21)
19 +#define ETCSR_HD ((21 << ETCSR_IPGR2_SHIFT) | (21 << ETCSR_IPGR1_SHIFT) | 21)
21 /* Private per NIC data of the driver. */
23 @@ -101,7 +101,7 @@ static int ioc3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
24 static void ioc3_set_multicast_list(struct net_device *dev);
25 static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev);
26 static void ioc3_timeout(struct net_device *dev);
27 -static inline unsigned int ioc3_hash(const unsigned char *addr);
28 +static inline u32 ioc3_hash(const u8 *addr);
29 static inline void ioc3_stop(struct ioc3_private *ip);
30 static void ioc3_init(struct net_device *dev);
32 @@ -112,13 +112,14 @@ static const struct ethtool_ops ioc3_ethtool_ops;
34 #define IOC3_CACHELINE 128UL
36 -static inline unsigned long aligned_rx_skb_addr(unsigned long addr)
37 +static inline unsigned long
38 +aligned_rx_skb_addr(unsigned long addr)
40 return (~addr + 1) & (IOC3_CACHELINE - 1UL);
43 -static inline struct sk_buff * ioc3_alloc_skb(unsigned long length,
44 - unsigned int gfp_mask)
45 +static inline struct sk_buff *
46 +ioc3_alloc_skb(unsigned long length, u32 gfp_mask)
50 @@ -132,7 +133,8 @@ static inline struct sk_buff * ioc3_alloc_skb(unsigned long length,
54 -static inline unsigned long ioc3_map(void *ptr, unsigned long vdev)
55 +static inline unsigned long
56 +ioc3_map(void *ptr, unsigned long vdev)
58 #ifdef CONFIG_SGI_IP27
59 vdev <<= 57; /* Shift to PCI64_ATTR_VIRTUAL */
60 @@ -145,7 +147,8 @@ static inline unsigned long ioc3_map(void *ptr, unsigned long vdev)
63 /* BEWARE: The IOC3 documentation documents the size of rx buffers as
64 - 1644 while it's actually 1664. This one was nasty to track down ... */
65 + * 1644 while it's actually 1664. This one was nasty to track down...
68 #define RX_BUF_ALLOC_SIZE (1664 + RX_OFFSET + IOC3_CACHELINE)
70 @@ -156,8 +159,7 @@ static inline unsigned long ioc3_map(void *ptr, unsigned long vdev)
72 #define IOC3_SIZE 0x100000
75 - * IOC3 is a big endian device
76 +/* IOC3 is a big endian device
78 * Unorthodox but makes the users of these macros more readable - the pointer
79 * to the IOC3's memory mapped registers is expected as struct ioc3 * ioc3
80 @@ -217,25 +219,28 @@ static inline unsigned long ioc3_map(void *ptr, unsigned long vdev)
81 #define ioc3_r_midr_w() be32_to_cpu(ioc3->midr_w)
82 #define ioc3_w_midr_w(v) do { ioc3->midr_w = cpu_to_be32(v); } while (0)
84 -static inline u32 mcr_pack(u32 pulse, u32 sample)
86 +mcr_pack(u32 pulse, u32 sample)
88 return (pulse << 10) | (sample << 2);
91 -static int nic_wait(struct ioc3 *ioc3)
93 +nic_wait(struct ioc3 *ioc3)
99 - } while (!(mcr & 2));
101 + mcr = ioc3_r_mcr();
102 + } while (!(mcr & 2));
108 -static int nic_reset(struct ioc3 *ioc3)
110 +nic_reset(struct ioc3 *ioc3)
115 ioc3_w_mcr(mcr_pack(500, 65));
116 presence = nic_wait(ioc3);
117 @@ -243,10 +248,11 @@ static int nic_reset(struct ioc3 *ioc3)
118 ioc3_w_mcr(mcr_pack(0, 500));
125 -static inline int nic_read_bit(struct ioc3 *ioc3)
127 +int nic_read_bit(struct ioc3 *ioc3)
131 @@ -258,7 +264,8 @@ static inline int nic_read_bit(struct ioc3 *ioc3)
135 -static inline void nic_write_bit(struct ioc3 *ioc3, int bit)
137 +nic_write_bit(struct ioc3 *ioc3, int bit)
140 ioc3_w_mcr(mcr_pack(6, 110));
141 @@ -271,7 +278,8 @@ static inline void nic_write_bit(struct ioc3 *ioc3, int bit)
143 * Read a byte from an iButton device
145 -static u32 nic_read_byte(struct ioc3 *ioc3)
147 +nic_read_byte(struct ioc3 *ioc3)
151 @@ -285,7 +293,8 @@ static u32 nic_read_byte(struct ioc3 *ioc3)
153 * Write a byte to an iButton device
155 -static void nic_write_byte(struct ioc3 *ioc3, int byte)
157 +nic_write_byte(struct ioc3 *ioc3, int byte)
161 @@ -297,7 +306,8 @@ static void nic_write_byte(struct ioc3 *ioc3, int byte)
165 -static u64 nic_find(struct ioc3 *ioc3, int *last)
167 +nic_find(struct ioc3 *ioc3, int *last)
169 int a, b, index, disc;
171 @@ -342,7 +352,8 @@ static u64 nic_find(struct ioc3 *ioc3, int *last)
175 -static int nic_init(struct ioc3 *ioc3)
177 +nic_init(struct ioc3 *ioc3)
179 const char *unknown = "unknown";
180 const char *type = unknown;
181 @@ -360,7 +371,7 @@ static int nic_init(struct ioc3 *ioc3)
185 - /* Let the caller try again. */
186 + /* Let the caller try again. */
190 @@ -394,7 +405,8 @@ static int nic_init(struct ioc3 *ioc3)
191 * Read the NIC (Number-In-a-Can) device used to store the MAC address on
192 * SN0 / SN00 nodeboards and PCI cards.
194 -static void ioc3_get_eaddr_nic(struct ioc3_private *ip)
196 +ioc3_get_eaddr_nic(struct ioc3_private *ip)
198 struct ioc3 *ioc3 = ip->regs;
200 @@ -431,24 +443,27 @@ static void ioc3_get_eaddr_nic(struct ioc3_private *ip)
201 * NIC is in in order to know how to read the NIC address. We also have
202 * to know if it's a PCI card or a NIC in on the node board ...
204 -static void ioc3_get_eaddr(struct ioc3_private *ip)
206 +ioc3_get_eaddr(struct ioc3_private *ip)
208 ioc3_get_eaddr_nic(ip);
210 printk("Ethernet address is %pM.\n", ip->dev->dev_addr);
213 -static void __ioc3_set_mac_address(struct net_device *dev)
215 +__ioc3_set_mac_address(struct net_device *dev)
217 struct ioc3_private *ip = netdev_priv(dev);
218 struct ioc3 *ioc3 = ip->regs;
220 ioc3_w_emar_h((dev->dev_addr[5] << 8) | dev->dev_addr[4]);
221 ioc3_w_emar_l((dev->dev_addr[3] << 24) | (dev->dev_addr[2] << 16) |
222 - (dev->dev_addr[1] << 8) | dev->dev_addr[0]);
223 + (dev->dev_addr[1] << 8) | dev->dev_addr[0]);
226 -static int ioc3_set_mac_address(struct net_device *dev, void *addr)
228 +ioc3_set_mac_address(struct net_device *dev, void *addr)
230 struct ioc3_private *ip = netdev_priv(dev);
231 struct sockaddr *sa = addr;
232 @@ -466,7 +481,8 @@ static int ioc3_set_mac_address(struct net_device *dev, void *addr)
233 * Caller must hold the ioc3_lock ever for MII readers. This is also
234 * used to protect the transmitter side but it's low contention.
236 -static int ioc3_mdio_read(struct net_device *dev, int phy, int reg)
238 +ioc3_mdio_read(struct net_device *dev, int phy, int reg)
240 struct ioc3_private *ip = netdev_priv(dev);
241 struct ioc3 *ioc3 = ip->regs;
242 @@ -478,7 +494,8 @@ static int ioc3_mdio_read(struct net_device *dev, int phy, int reg)
243 return ioc3_r_midr_r() & MIDR_DATA_MASK;
246 -static void ioc3_mdio_write(struct net_device *dev, int phy, int reg, int data)
248 +ioc3_mdio_write(struct net_device *dev, int phy, int reg, int data)
250 struct ioc3_private *ip = netdev_priv(dev);
251 struct ioc3 *ioc3 = ip->regs;
252 @@ -489,9 +506,11 @@ static void ioc3_mdio_write(struct net_device *dev, int phy, int reg, int data)
253 while (ioc3_r_micr() & MICR_BUSY);
256 -static int ioc3_mii_init(struct ioc3_private *ip);
258 +ioc3_mii_init(struct ioc3_private *ip);
260 -static struct net_device_stats *ioc3_get_stats(struct net_device *dev)
261 +static struct net_device_stats *
262 +ioc3_get_stats(struct net_device *dev)
264 struct ioc3_private *ip = netdev_priv(dev);
265 struct ioc3 *ioc3 = ip->regs;
266 @@ -500,14 +519,14 @@ static struct net_device_stats *ioc3_get_stats(struct net_device *dev)
270 -static void ioc3_tcpudp_checksum(struct sk_buff *skb, uint32_t hwsum, int len)
272 +ioc3_tcpudp_checksum(struct sk_buff *skb, u32 hwsum, int len)
274 struct ethhdr *eh = eth_hdr(skb);
275 - uint32_t csum, ehsum;
276 - unsigned int proto;
277 + u32 csum, ehsum, proto;
285 * Did hardware handle the checksum at all? The cases we can handle
286 @@ -537,12 +556,12 @@ static void ioc3_tcpudp_checksum(struct sk_buff *skb, uint32_t hwsum, int len)
287 /* Same as tx - compute csum of pseudo header */
289 (ih->tot_len - (ih->ihl << 2)) +
290 - htons((uint16_t)ih->protocol) +
291 + htons((u16)ih->protocol) +
292 (ih->saddr >> 16) + (ih->saddr & 0xffff) +
293 (ih->daddr >> 16) + (ih->daddr & 0xffff);
295 /* Sum up ethernet dest addr, src addr and protocol */
296 - ew = (uint16_t *) eh;
298 ehsum = ew[0] + ew[1] + ew[2] + ew[3] + ew[4] + ew[5] + ew[6];
300 ehsum = (ehsum & 0xffff) + (ehsum >> 16);
301 @@ -554,11 +573,11 @@ static void ioc3_tcpudp_checksum(struct sk_buff *skb, uint32_t hwsum, int len)
302 checksum of the trailing ethernet CRC. */
303 cp = (char *)eh + len; /* points at trailing CRC */
305 - csum += 0xffff ^ (uint16_t) ((cp[1] << 8) | cp[0]);
306 - csum += 0xffff ^ (uint16_t) ((cp[3] << 8) | cp[2]);
307 + csum += 0xffff ^ (u16)((cp[1] << 8) | cp[0]);
308 + csum += 0xffff ^ (u16)((cp[3] << 8) | cp[2]);
310 - csum += 0xffff ^ (uint16_t) ((cp[0] << 8) | cp[1]);
311 - csum += 0xffff ^ (uint16_t) ((cp[2] << 8) | cp[3]);
312 + csum += 0xffff ^ (u16)((cp[0] << 8) | cp[1]);
313 + csum += 0xffff ^ (u16)((cp[2] << 8) | cp[3]);
316 csum = (csum & 0xffff) + (csum >> 16);
317 @@ -568,7 +587,8 @@ static void ioc3_tcpudp_checksum(struct sk_buff *skb, uint32_t hwsum, int len)
318 skb->ip_summed = CHECKSUM_UNNECESSARY;
321 -static inline void ioc3_rx(struct net_device *dev)
323 +ioc3_rx(struct net_device *dev)
325 struct ioc3_private *ip = netdev_priv(dev);
326 struct sk_buff *skb, *new_skb;
327 @@ -578,8 +598,8 @@ static inline void ioc3_rx(struct net_device *dev)
331 - rxr = ip->rxr; /* Ring base */
332 - rx_entry = ip->rx_ci; /* RX consume index */
333 + rxr = ip->rxr; /* Ring base */
334 + rx_entry = ip->rx_ci; /* RX consume index */
337 skb = ip->rx_skbs[rx_entry];
338 @@ -587,7 +607,7 @@ static inline void ioc3_rx(struct net_device *dev)
339 w0 = be32_to_cpu(rxb->w0);
341 while (w0 & ERXBUF_V) {
342 - err = be32_to_cpu(rxb->err); /* It's valid ... */
343 + err = be32_to_cpu(rxb->err); /* It's valid */
344 if (err & ERXBUF_GOODPKT) {
345 len = ((w0 >> ERXBUF_BYTECNT_SHIFT) & 0x7ff) - 4;
347 @@ -596,7 +616,8 @@ static inline void ioc3_rx(struct net_device *dev)
348 new_skb = ioc3_alloc_skb(RX_BUF_ALLOC_SIZE, GFP_ATOMIC);
350 /* Ouch, drop packet and just recycle packet
351 - to keep the ring filled. */
352 + * to keep the ring filled.
354 dev->stats.rx_dropped++;
357 @@ -612,19 +633,21 @@ static inline void ioc3_rx(struct net_device *dev)
359 /* Because we reserve afterwards. */
360 skb_put(new_skb, (1664 + RX_OFFSET));
361 - rxb = (struct ioc3_erxbuf *) new_skb->data;
362 + rxb = (struct ioc3_erxbuf *)new_skb->data;
363 skb_reserve(new_skb, RX_OFFSET);
365 - dev->stats.rx_packets++; /* Statistics */
366 + dev->stats.rx_packets++; /* Statistics */
367 dev->stats.rx_bytes += len;
369 - /* The frame is invalid and the skb never
370 - reached the network layer so we can just
372 + /* The frame is invalid and the skb never reached the
373 + * network layer so we can just recycle it.
376 dev->stats.rx_errors++;
378 - if (err & ERXBUF_CRCERR) /* Statistics */
381 + if (err & ERXBUF_CRCERR)
382 dev->stats.rx_crc_errors++;
383 if (err & ERXBUF_FRAMERR)
384 dev->stats.rx_frame_errors++;
385 @@ -632,10 +655,10 @@ static inline void ioc3_rx(struct net_device *dev)
386 ip->rx_skbs[n_entry] = new_skb;
387 rxr[n_entry] = cpu_to_be64(ioc3_map(rxb, 1));
388 rxb->w0 = 0; /* Clear valid flag */
389 - n_entry = (n_entry + 1) & 511; /* Update erpir */
390 + n_entry = (n_entry + 1) & 0x1ff; /* Update erpir */
392 - /* Now go on to the next ring entry. */
393 - rx_entry = (rx_entry + 1) & 511;
394 + /* Now go on to the next ring entry. */
395 + rx_entry = (rx_entry + 1) & 0x1ff;
396 skb = ip->rx_skbs[rx_entry];
397 rxb = (struct ioc3_erxbuf *) (skb->data - RX_OFFSET);
398 w0 = be32_to_cpu(rxb->w0);
399 @@ -645,7 +668,8 @@ static inline void ioc3_rx(struct net_device *dev)
400 ip->rx_ci = rx_entry;
403 -static inline void ioc3_tx(struct net_device *dev)
405 +ioc3_tx(struct net_device *dev)
407 struct ioc3_private *ip = netdev_priv(dev);
408 unsigned long packets, bytes;
409 @@ -657,7 +681,7 @@ static inline void ioc3_tx(struct net_device *dev)
410 spin_lock(&ip->ioc3_lock);
411 etcir = ioc3_r_etcir();
413 - tx_entry = (etcir >> 7) & 127;
414 + tx_entry = (etcir >> 7) & 0x7f;
418 @@ -669,10 +693,10 @@ static inline void ioc3_tx(struct net_device *dev)
419 dev_kfree_skb_irq(skb);
420 ip->tx_skbs[o_entry] = NULL;
422 - o_entry = (o_entry + 1) & 127; /* Next */
423 + o_entry = (o_entry + 1) & 0x7f; /* Next */
425 etcir = ioc3_r_etcir(); /* More pkts sent? */
426 - tx_entry = (etcir >> 7) & 127;
427 + tx_entry = (etcir >> 7) & 0x7f;
430 dev->stats.tx_packets += packets;
431 @@ -693,10 +717,11 @@ static inline void ioc3_tx(struct net_device *dev)
432 * with such error interrupts if something really goes wrong, so we might
433 * also consider to take the interface down.
435 -static void ioc3_error(struct net_device *dev, u32 eisr)
437 +ioc3_error(struct net_device *dev, u32 eisr)
439 struct ioc3_private *ip = netdev_priv(dev);
440 - unsigned char *iface = dev->name;
441 + u8 *iface = dev->name;
443 spin_lock(&ip->ioc3_lock);
445 @@ -722,25 +747,27 @@ static void ioc3_error(struct net_device *dev, u32 eisr)
446 spin_unlock(&ip->ioc3_lock);
449 -/* The interrupt handler does all of the Rx thread work and cleans up
450 - after the Tx thread. */
451 -static irqreturn_t ioc3_interrupt(int irq, void *_dev)
452 +/* The interrupt handler does all of the Rx thread work and cleans up after
456 +ioc3_interrupt(int irq, void *_dev)
458 struct net_device *dev = (struct net_device *)_dev;
459 struct ioc3_private *ip = netdev_priv(dev);
460 struct ioc3 *ioc3 = ip->regs;
461 const u32 enabled = EISR_RXTIMERINT | EISR_RXOFLO | EISR_RXBUFOFLO |
462 - EISR_RXMEMERR | EISR_RXPARERR | EISR_TXBUFUFLO |
463 - EISR_TXEXPLICIT | EISR_TXMEMERR;
464 + EISR_RXMEMERR | EISR_RXPARERR | EISR_TXBUFUFLO |
465 + EISR_TXEXPLICIT | EISR_TXMEMERR;
468 eisr = ioc3_r_eisr() & enabled;
471 - (void) ioc3_r_eisr(); /* Flush */
472 + (void)ioc3_r_eisr(); /* Flush */
474 if (eisr & (EISR_RXOFLO | EISR_RXBUFOFLO | EISR_RXMEMERR |
475 - EISR_RXPARERR | EISR_TXBUFUFLO | EISR_TXMEMERR))
476 + EISR_RXPARERR | EISR_TXBUFUFLO | EISR_TXMEMERR))
477 ioc3_error(dev, eisr);
478 if (eisr & EISR_RXTIMERINT)
480 @@ -750,7 +777,8 @@ static irqreturn_t ioc3_interrupt(int irq, void *_dev)
484 -static inline void ioc3_setup_duplex(struct ioc3_private *ip)
486 +ioc3_setup_duplex(struct ioc3_private *ip)
488 struct ioc3 *ioc3 = ip->regs;
490 @@ -764,7 +792,8 @@ static inline void ioc3_setup_duplex(struct ioc3_private *ip)
491 ioc3_w_emcr(ip->emcr);
494 -static void ioc3_timer(struct timer_list *t)
496 +ioc3_timer(struct timer_list *t)
498 struct ioc3_private *ip = from_timer(ip, t, ioc3_timer);
500 @@ -772,7 +801,7 @@ static void ioc3_timer(struct timer_list *t)
501 mii_check_media(&ip->mii, 1, 0);
502 ioc3_setup_duplex(ip);
504 - ip->ioc3_timer.expires = jiffies + ((12 * HZ)/10); /* 1.2s */
505 + ip->ioc3_timer.expires = jiffies + ((12 * HZ) / 10); /* 1.2s */
506 add_timer(&ip->ioc3_timer);
509 @@ -784,7 +813,8 @@ static void ioc3_timer(struct timer_list *t)
510 * yet the interface seems to work fine, so if probing fails we for now will
511 * simply default to PHY 31 instead of bailing out.
513 -static int ioc3_mii_init(struct ioc3_private *ip)
515 +ioc3_mii_init(struct ioc3_private *ip)
517 int i, found = 0, res = 0;
518 int ioc3_phy_workaround = 1;
519 @@ -795,7 +825,7 @@ static int ioc3_mii_init(struct ioc3_private *ip)
521 if (word != 0xffff && word != 0x0000) {
523 - break; /* Found a PHY */
524 + break; /* Found a PHY */
528 @@ -815,13 +845,15 @@ static int ioc3_mii_init(struct ioc3_private *ip)
532 -static void ioc3_mii_start(struct ioc3_private *ip)
534 +ioc3_mii_start(struct ioc3_private *ip)
536 - ip->ioc3_timer.expires = jiffies + (12 * HZ)/10; /* 1.2 sec. */
537 + ip->ioc3_timer.expires = jiffies + (12 * HZ) / 10; /* 1.2 sec. */
538 add_timer(&ip->ioc3_timer);
541 -static inline void ioc3_clean_rx_ring(struct ioc3_private *ip)
543 +ioc3_clean_rx_ring(struct ioc3_private *ip)
547 @@ -830,10 +862,10 @@ static inline void ioc3_clean_rx_ring(struct ioc3_private *ip)
548 ip->rx_skbs[ip->rx_pi] = ip->rx_skbs[ip->rx_ci];
549 ip->rxr[ip->rx_pi++] = ip->rxr[ip->rx_ci++];
553 + ip->rx_pi &= 0x1ff;
554 + ip->rx_ci &= 0x1ff;
556 - for (i = ip->rx_ci; i != ip->rx_pi; i = (i+1) & 511) {
557 + for (i = ip->rx_ci; i != ip->rx_pi; i = (i + 1) & 0x1ff) {
558 struct ioc3_erxbuf *rxb;
559 skb = ip->rx_skbs[i];
560 rxb = (struct ioc3_erxbuf *) (skb->data - RX_OFFSET);
561 @@ -841,7 +873,8 @@ static inline void ioc3_clean_rx_ring(struct ioc3_private *ip)
565 -static inline void ioc3_clean_tx_ring(struct ioc3_private *ip)
567 +ioc3_clean_tx_ring(struct ioc3_private *ip)
571 @@ -858,7 +891,8 @@ static inline void ioc3_clean_tx_ring(struct ioc3_private *ip)
575 -static void ioc3_free_rings(struct ioc3_private *ip)
577 +ioc3_free_rings(struct ioc3_private *ip)
580 int rx_entry, n_entry;
581 @@ -878,14 +912,15 @@ static void ioc3_free_rings(struct ioc3_private *ip)
583 dev_kfree_skb_any(skb);
585 - n_entry = (n_entry + 1) & 511;
586 + n_entry = (n_entry + 1) & 0x1ff;
588 free_page((unsigned long)ip->rxr);
593 -static void ioc3_alloc_rings(struct net_device *dev)
595 +ioc3_alloc_rings(struct net_device *dev)
597 struct ioc3_private *ip = netdev_priv(dev);
598 struct ioc3_erxbuf *rxb;
599 @@ -899,9 +934,10 @@ static void ioc3_alloc_rings(struct net_device *dev)
601 printk("ioc3_alloc_rings(): get_zeroed_page() failed!\n");
603 - /* Now the rx buffers. The RX ring may be larger but
604 - we only allocate 16 buffers for now. Need to tune
605 - this for performance and memory later. */
606 + /* Now the rx buffers. The RX ring may be larger but we only
607 + * allocate 16 buffers for now. Need to tune this for
608 + * performance and memory later.
610 for (i = 0; i < RX_BUFFS; i++) {
613 @@ -933,7 +969,8 @@ static void ioc3_alloc_rings(struct net_device *dev)
617 -static void ioc3_init_rings(struct net_device *dev)
619 +ioc3_init_rings(struct net_device *dev)
621 struct ioc3_private *ip = netdev_priv(dev);
622 struct ioc3 *ioc3 = ip->regs;
623 @@ -954,22 +991,23 @@ static void ioc3_init_rings(struct net_device *dev)
625 ring = ioc3_map(ip->txr, 0);
627 - ip->txqlen = 0; /* nothing queued */
628 + ip->txqlen = 0; /* nothing queued */
630 /* Now the tx ring base, consume & produce registers. */
631 ioc3_w_etbr_h(ring >> 32);
632 ioc3_w_etbr_l(ring & 0xffffffff);
633 ioc3_w_etpir(ip->tx_pi << 7);
634 ioc3_w_etcir(ip->tx_ci << 7);
635 - (void) ioc3_r_etcir(); /* Flush */
636 + (void)ioc3_r_etcir(); /* Flush */
639 -static inline void ioc3_ssram_disc(struct ioc3_private *ip)
641 +ioc3_ssram_disc(struct ioc3_private *ip)
643 struct ioc3 *ioc3 = ip->regs;
644 volatile u32 *ssram0 = &ioc3->ssram[0x0000];
645 volatile u32 *ssram1 = &ioc3->ssram[0x4000];
646 - unsigned int pattern = 0x5555;
647 + u32 pattern = 0x5555;
649 /* Assume the larger size SSRAM and enable parity checking */
650 ioc3_w_emcr(ioc3_r_emcr() | (EMCR_BUFSIZ | EMCR_RAMPAR));
651 @@ -986,18 +1024,19 @@ static inline void ioc3_ssram_disc(struct ioc3_private *ip)
652 ip->emcr = EMCR_BUFSIZ | EMCR_RAMPAR;
655 -static void ioc3_init(struct net_device *dev)
657 +ioc3_init(struct net_device *dev)
659 struct ioc3_private *ip = netdev_priv(dev);
660 struct ioc3 *ioc3 = ip->regs;
662 - del_timer_sync(&ip->ioc3_timer); /* Kill if running */
663 + del_timer_sync(&ip->ioc3_timer); /* Kill if running */
665 - ioc3_w_emcr(EMCR_RST); /* Reset */
666 - (void) ioc3_r_emcr(); /* Flush WB */
667 - udelay(4); /* Give it time ... */
668 + ioc3_w_emcr(EMCR_RST); /* Reset */
669 + (void)ioc3_r_emcr(); /* Flush WB */
670 + udelay(4); /* Give it time... */
672 - (void) ioc3_r_emcr();
673 + (void)ioc3_r_emcr();
676 #ifdef CONFIG_SGI_IP27
677 @@ -1005,7 +1044,7 @@ static void ioc3_init(struct net_device *dev)
679 ioc3_w_erbar(0); /* Let PCI API get it right */
681 - (void) ioc3_r_etcdc(); /* Clear on read */
682 + (void)ioc3_r_etcdc(); /* Clear on read */
683 ioc3_w_ercsr(15); /* RX low watermark */
684 ioc3_w_ertr(0); /* Interrupt immediately */
685 __ioc3_set_mac_address(dev);
686 @@ -1015,25 +1054,27 @@ static void ioc3_init(struct net_device *dev)
688 ioc3_init_rings(dev);
690 - ip->emcr |= ((RX_OFFSET / 2) << EMCR_RXOFF_SHIFT) | EMCR_TXDMAEN |
691 - EMCR_TXEN | EMCR_RXDMAEN | EMCR_RXEN | EMCR_PADEN;
692 + ip->emcr |= (((RX_OFFSET / 2) << EMCR_RXOFF_SHIFT) | EMCR_TXDMAEN |
693 + EMCR_TXEN | EMCR_RXDMAEN | EMCR_RXEN | EMCR_PADEN);
694 ioc3_w_emcr(ip->emcr);
695 ioc3_w_eier(EISR_RXTIMERINT | EISR_RXOFLO | EISR_RXBUFOFLO |
696 - EISR_RXMEMERR | EISR_RXPARERR | EISR_TXBUFUFLO |
697 - EISR_TXEXPLICIT | EISR_TXMEMERR);
698 + EISR_RXMEMERR | EISR_RXPARERR | EISR_TXBUFUFLO |
699 + EISR_TXEXPLICIT | EISR_TXMEMERR);
700 (void) ioc3_r_eier();
703 -static inline void ioc3_stop(struct ioc3_private *ip)
705 +ioc3_stop(struct ioc3_private *ip)
707 struct ioc3 *ioc3 = ip->regs;
709 - ioc3_w_emcr(0); /* Shutup */
710 - ioc3_w_eier(0); /* Disable interrupts */
711 - (void) ioc3_r_eier(); /* Flush */
712 + ioc3_w_emcr(0); /* Shutup */
713 + ioc3_w_eier(0); /* Disable interrupts */
714 + (void)ioc3_r_eier(); /* Flush */
717 -static int ioc3_open(struct net_device *dev)
719 +ioc3_open(struct net_device *dev)
721 struct ioc3_private *ip = netdev_priv(dev);
723 @@ -1052,18 +1093,17 @@ static int ioc3_open(struct net_device *dev)
727 -static int ioc3_close(struct net_device *dev)
729 +ioc3_close(struct net_device *dev)
731 struct ioc3_private *ip = netdev_priv(dev);
733 del_timer_sync(&ip->ioc3_timer);
735 netif_stop_queue(dev);
738 free_irq(dev->irq, dev);
745 @@ -1077,15 +1117,15 @@ static int ioc3_close(struct net_device *dev)
746 * MiniDINs; all other subdevices are left swinging in the wind, leave
750 -static int ioc3_adjacent_is_ioc3(struct pci_dev *pdev, int slot)
752 +ioc3_adjacent_is_ioc3(struct pci_dev *pdev, int slot)
754 struct pci_dev *dev = pci_get_slot(pdev->bus, PCI_DEVFN(slot, 0));
758 - if (dev->vendor == PCI_VENDOR_ID_SGI &&
759 - dev->device == PCI_DEVICE_ID_SGI_IOC3)
760 + if ((dev->vendor == PCI_VENDOR_ID_SGI) &&
761 + (dev->device == PCI_DEVICE_ID_SGI_IOC3))
765 @@ -1093,7 +1133,8 @@ static int ioc3_adjacent_is_ioc3(struct pci_dev *pdev, int slot)
769 -static int ioc3_is_menet(struct pci_dev *pdev)
771 +ioc3_is_menet(struct pci_dev *pdev)
773 return pdev->bus->parent == NULL &&
774 ioc3_adjacent_is_ioc3(pdev, 0) &&
775 @@ -1135,23 +1176,23 @@ static int ioc3_is_menet(struct pci_dev *pdev)
776 * Can't use UPF_IOREMAP as the whole of IOC3 resources have already been
779 -static void ioc3_8250_register(struct ioc3_uartregs __iomem *uart)
781 +ioc3_8250_register(struct ioc3_uartregs __iomem *uart)
783 #define COSMISC_CONSTANT 6
785 struct uart_8250_port port = {
789 .flags = UPF_SKIP_TEST | UPF_BOOT_AUTOCONF,
792 .uartclk = (22000000 << 1) / COSMISC_CONSTANT,
794 - .membase = (unsigned char __iomem *) uart,
795 - .mapbase = (unsigned long) uart,
797 + .membase = (u8 __iomem *)uart,
798 + .mapbase = (unsigned long)uart,
805 uart->iu_lcr = lcr | UART_LCR_DLAB;
806 @@ -1161,10 +1202,10 @@ static void ioc3_8250_register(struct ioc3_uartregs __iomem *uart)
807 serial8250_register_8250_port(&port);
810 -static void ioc3_serial_probe(struct pci_dev *pdev, struct ioc3 *ioc3)
812 +ioc3_serial_probe(struct pci_dev *pdev, struct ioc3 *ioc3)
815 - * We need to recognice and treat the fourth MENET serial as it
816 + /* We need to recognice and treat the fourth MENET serial as it
817 * does not have an SuperIO chip attached to it, therefore attempting
818 * to access it will result in bus errors. We call something an
819 * MENET if PCI slot 0, 1, 2 and 3 of a master PCI bus all have an IOC3
820 @@ -1175,8 +1216,7 @@ static void ioc3_serial_probe(struct pci_dev *pdev, struct ioc3 *ioc3)
821 if (ioc3_is_menet(pdev) && PCI_SLOT(pdev->devfn) == 3)
825 - * Switch IOC3 to PIO mode. It probably already was but let's be
826 + /* Switch IOC3 to PIO mode. It probably already was but let's be
829 ioc3->gpcr_s = GPCR_UARTA_MODESEL | GPCR_UARTB_MODESEL;
830 @@ -1208,7 +1248,8 @@ static void ioc3_serial_probe(struct pci_dev *pdev, struct ioc3 *ioc3)
834 -static const struct net_device_ops ioc3_netdev_ops = {
835 +static const struct net_device_ops
837 .ndo_open = ioc3_open,
838 .ndo_stop = ioc3_close,
839 .ndo_start_xmit = ioc3_start_xmit,
840 @@ -1220,9 +1261,10 @@ static const struct net_device_ops ioc3_netdev_ops = {
841 .ndo_set_mac_address = ioc3_set_mac_address,
844 -static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
846 +ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
848 - unsigned int sw_physid1, sw_physid2;
849 + u32 sw_physid1, sw_physid2;
850 struct net_device *dev = NULL;
851 struct ioc3_private *ip;
853 @@ -1359,7 +1401,8 @@ static int ioc3_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
857 -static void ioc3_remove_one(struct pci_dev *pdev)
859 +ioc3_remove_one(struct pci_dev *pdev)
861 struct net_device *dev = pci_get_drvdata(pdev);
862 struct ioc3_private *ip = netdev_priv(dev);
863 @@ -1377,27 +1420,29 @@ static void ioc3_remove_one(struct pci_dev *pdev)
867 -static const struct pci_device_id ioc3_pci_tbl[] = {
868 +static const struct pci_device_id
870 { PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC3, PCI_ANY_ID, PCI_ANY_ID },
873 MODULE_DEVICE_TABLE(pci, ioc3_pci_tbl);
875 -static struct pci_driver ioc3_driver = {
876 +static struct pci_driver
879 .id_table = ioc3_pci_tbl,
881 .remove = ioc3_remove_one,
884 -static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev)
886 +ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev)
888 - unsigned long data;
889 struct ioc3_private *ip = netdev_priv(dev);
890 struct ioc3 *ioc3 = ip->regs;
892 struct ioc3_etxd *desc;
894 + unsigned long data;
899 @@ -1410,25 +1455,26 @@ static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev)
901 if (skb->ip_summed == CHECKSUM_PARTIAL) {
902 const struct iphdr *ih = ip_hdr(skb);
903 - const int proto = ntohs(ih->protocol);
904 - unsigned int csoff;
905 - uint32_t csum, ehsum;
907 + const u32 proto = ntohs(ih->protocol);
908 + u32 csoff, csum, ehsum;
911 - /* The MAC header. skb->mac seem the logic approach
912 - to find the MAC header - except it's a NULL pointer ... */
913 - eh = (uint16_t *) skb->data;
914 + /* The MAC header. skb->mac seems the logical approach
915 + * to find the MAC header. Except if it's a NULL pointer...
917 + eh = (u16 *)skb->data;
919 /* Sum up dest addr, src addr and protocol */
920 ehsum = eh[0] + eh[1] + eh[2] + eh[3] + eh[4] + eh[5] + eh[6];
922 - /* Skip IP header; it's sum is always zero and was
923 - already filled in by ip_output.c */
924 + /* Skip IP header; it's sum is always zero and was already
925 + * filled in by ip_output.c
927 csum = csum_tcpudp_nofold(ih->saddr, ih->daddr,
928 - ih->tot_len - (ih->ihl << 2),
929 - proto, csum_fold(ehsum));
930 + ih->tot_len - (ih->ihl << 2),
931 + proto, csum_fold(ehsum));
933 - csum = (csum & 0xffff) + (csum >> 16); /* Fold again */
934 + csum = (csum & 0xffff) + (csum >> 16); /* Fold again */
935 csum = (csum & 0xffff) + (csum >> 16);
937 csoff = ETH_HLEN + (ih->ihl << 2);
938 @@ -1468,9 +1514,9 @@ static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev)
939 unsigned long s2 = data + len - b2;
941 desc->cmd = cpu_to_be32(len | ETXD_INTWHENDONE |
942 - ETXD_B1V | ETXD_B2V | w0);
943 + ETXD_B1V | ETXD_B2V | w0);
944 desc->bufcnt = cpu_to_be32((s1 << ETXD_B1CNT_SHIFT) |
945 - (s2 << ETXD_B2CNT_SHIFT));
946 + (s2 << ETXD_B2CNT_SHIFT));
947 desc->p1 = cpu_to_be64(ioc3_map(skb->data, 1));
948 desc->p2 = cpu_to_be64(ioc3_map((void *) b2, 1));
950 @@ -1482,10 +1528,10 @@ static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev)
954 - ip->tx_skbs[produce] = skb; /* Remember skb */
955 - produce = (produce + 1) & 127;
956 + ip->tx_skbs[produce] = skb; /* Remember skb */
957 + produce = (produce + 1) & 0x7f;
959 - ioc3_w_etpir(produce << 7); /* Fire ... */
960 + ioc3_w_etpir(produce << 7); /* Fire! */
964 @@ -1497,7 +1543,8 @@ static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev)
968 -static void ioc3_timeout(struct net_device *dev)
970 +ioc3_timeout(struct net_device *dev)
972 struct ioc3_private *ip = netdev_priv(dev);
974 @@ -1520,15 +1567,16 @@ static void ioc3_timeout(struct net_device *dev)
975 * address's bit index in the logical address filter mask
978 -static inline unsigned int ioc3_hash(const unsigned char *addr)
980 +ioc3_hash(const u8 *addr)
982 - unsigned int temp = 0;
987 crc = ether_crc_le(ETH_ALEN, addr);
989 - crc &= 0x3f; /* bit reverse lowest 6 bits for hash index */
990 + crc &= 0x3f; /* bit reverse lowest 6 bits for hash index */
991 for (bits = 6; --bits >= 0; ) {
994 @@ -1538,8 +1586,8 @@ static inline unsigned int ioc3_hash(const unsigned char *addr)
998 -static void ioc3_get_drvinfo (struct net_device *dev,
999 - struct ethtool_drvinfo *info)
1001 +ioc3_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
1003 struct ioc3_private *ip = netdev_priv(dev);
1005 @@ -1548,8 +1596,9 @@ static void ioc3_get_drvinfo (struct net_device *dev,
1006 strlcpy(info->bus_info, pci_name(ip->pdev), sizeof(info->bus_info));
1009 -static int ioc3_get_link_ksettings(struct net_device *dev,
1010 - struct ethtool_link_ksettings *cmd)
1012 +ioc3_get_link_ksettings(struct net_device *dev,
1013 + struct ethtool_link_ksettings *cmd)
1015 struct ioc3_private *ip = netdev_priv(dev);
1017 @@ -1560,8 +1609,9 @@ static int ioc3_get_link_ksettings(struct net_device *dev,
1021 -static int ioc3_set_link_ksettings(struct net_device *dev,
1022 - const struct ethtool_link_ksettings *cmd)
1024 +ioc3_set_link_ksettings(struct net_device *dev,
1025 + const struct ethtool_link_ksettings *cmd)
1027 struct ioc3_private *ip = netdev_priv(dev);
1029 @@ -1573,7 +1623,8 @@ static int ioc3_set_link_ksettings(struct net_device *dev,
1033 -static int ioc3_nway_reset(struct net_device *dev)
1035 +ioc3_nway_reset(struct net_device *dev)
1037 struct ioc3_private *ip = netdev_priv(dev);
1039 @@ -1585,7 +1636,8 @@ static int ioc3_nway_reset(struct net_device *dev)
1043 -static u32 ioc3_get_link(struct net_device *dev)
1045 +ioc3_get_link(struct net_device *dev)
1047 struct ioc3_private *ip = netdev_priv(dev);
1049 @@ -1597,7 +1649,8 @@ static u32 ioc3_get_link(struct net_device *dev)
1053 -static const struct ethtool_ops ioc3_ethtool_ops = {
1054 +static const struct ethtool_ops
1055 +ioc3_ethtool_ops = {
1056 .get_drvinfo = ioc3_get_drvinfo,
1057 .nway_reset = ioc3_nway_reset,
1058 .get_link = ioc3_get_link,
1059 @@ -1605,7 +1658,8 @@ static const struct ethtool_ops ioc3_ethtool_ops = {
1060 .set_link_ksettings = ioc3_set_link_ksettings,
1063 -static int ioc3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1065 +ioc3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1067 struct ioc3_private *ip = netdev_priv(dev);
1069 @@ -1617,29 +1671,31 @@ static int ioc3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1073 -static void ioc3_set_multicast_list(struct net_device *dev)
1075 +ioc3_set_multicast_list(struct net_device *dev)
1077 struct netdev_hw_addr *ha;
1078 struct ioc3_private *ip = netdev_priv(dev);
1079 struct ioc3 *ioc3 = ip->regs;
1082 - netif_stop_queue(dev); /* Lock out others. */
1083 + netif_stop_queue(dev); /* Lock out others. */
1085 - if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
1086 + if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
1087 ip->emcr |= EMCR_PROMISC;
1088 ioc3_w_emcr(ip->emcr);
1089 (void) ioc3_r_emcr();
1091 ip->emcr &= ~EMCR_PROMISC;
1092 - ioc3_w_emcr(ip->emcr); /* Clear promiscuous. */
1093 + ioc3_w_emcr(ip->emcr); /* Clear promiscuous. */
1094 (void) ioc3_r_emcr();
1096 if ((dev->flags & IFF_ALLMULTI) ||
1097 (netdev_mc_count(dev) > 64)) {
1098 /* Too many for hashing to make sense or we want all
1099 - multicast packets anyway, so skip computing all the
1100 - hashes and just accept all packets. */
1101 + * multicast packets anyway, so skip computing all
1102 + * the hashes and just accept all packets.
1104 ip->ehar_h = 0xffffffff;
1105 ip->ehar_l = 0xffffffff;
1107 @@ -1653,7 +1709,7 @@ static void ioc3_set_multicast_list(struct net_device *dev)
1108 ioc3_w_ehar_l(ip->ehar_l);
1111 - netif_wake_queue(dev); /* Let us get going again. */
1112 + netif_wake_queue(dev); /* Let us get going again. */
1115 module_pci_driver(ioc3_driver);