.. | .. |
---|
1 | | -/* ne2k-pci.c: A NE2000 clone on PCI bus driver for Linux. */ |
---|
2 | | -/* |
---|
3 | | - A Linux device driver for PCI NE2000 clones. |
---|
4 | | - |
---|
5 | | - Authors and other copyright holders: |
---|
6 | | - 1992-2000 by Donald Becker, NE2000 core and various modifications. |
---|
7 | | - 1995-1998 by Paul Gortmaker, core modifications and PCI support. |
---|
8 | | - Copyright 1993 assigned to the United States Government as represented |
---|
9 | | - by the Director, National Security Agency. |
---|
10 | | - |
---|
11 | | - This software may be used and distributed according to the terms of |
---|
12 | | - the GNU General Public License (GPL), incorporated herein by reference. |
---|
13 | | - Drivers based on or derived from this code fall under the GPL and must |
---|
14 | | - retain the authorship, copyright and license notice. This file is not |
---|
15 | | - a complete program and may only be used when the entire operating |
---|
16 | | - system is licensed under the GPL. |
---|
17 | | - |
---|
18 | | - The author may be reached as becker@scyld.com, or C/O |
---|
19 | | - Scyld Computing Corporation |
---|
20 | | - 410 Severn Ave., Suite 210 |
---|
21 | | - Annapolis MD 21403 |
---|
22 | | - |
---|
23 | | - Issues remaining: |
---|
24 | | - People are making PCI ne2000 clones! Oh the horror, the horror... |
---|
25 | | - Limited full-duplex support. |
---|
26 | | -*/ |
---|
| 1 | +/* A Linux device driver for PCI NE2000 clones. |
---|
| 2 | + * |
---|
| 3 | + * Authors and other copyright holders: |
---|
| 4 | + * 1992-2000 by Donald Becker, NE2000 core and various modifications. |
---|
| 5 | + * 1995-1998 by Paul Gortmaker, core modifications and PCI support. |
---|
| 6 | + * Copyright 1993 assigned to the United States Government as represented |
---|
| 7 | + * by the Director, National Security Agency. |
---|
| 8 | + * |
---|
| 9 | + * This software may be used and distributed according to the terms of |
---|
| 10 | + * the GNU General Public License (GPL), incorporated herein by reference. |
---|
| 11 | + * Drivers based on or derived from this code fall under the GPL and must |
---|
| 12 | + * retain the authorship, copyright and license notice. This file is not |
---|
| 13 | + * a complete program and may only be used when the entire operating |
---|
| 14 | + * system is licensed under the GPL. |
---|
| 15 | + * |
---|
| 16 | + * The author may be reached as becker@scyld.com, or C/O |
---|
| 17 | + * Scyld Computing Corporation |
---|
| 18 | + * 410 Severn Ave., Suite 210 |
---|
| 19 | + * Annapolis MD 21403 |
---|
| 20 | + * |
---|
| 21 | + * Issues remaining: |
---|
| 22 | + * People are making PCI NE2000 clones! Oh the horror, the horror... |
---|
| 23 | + * Limited full-duplex support. |
---|
| 24 | + */ |
---|
27 | 25 | |
---|
28 | 26 | #define DRV_NAME "ne2k-pci" |
---|
| 27 | +#define DRV_DESCRIPTION "PCI NE2000 clone driver" |
---|
| 28 | +#define DRV_AUTHOR "Donald Becker / Paul Gortmaker" |
---|
29 | 29 | #define DRV_VERSION "1.03" |
---|
30 | 30 | #define DRV_RELDATE "9/22/2003" |
---|
31 | 31 | |
---|
| 32 | +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
32 | 33 | |
---|
33 | 34 | /* The user-configurable values. |
---|
34 | | - These may be modified when a driver module is loaded.*/ |
---|
| 35 | + * These may be modified when a driver module is loaded. |
---|
| 36 | + */ |
---|
35 | 37 | |
---|
36 | | -#define MAX_UNITS 8 /* More are supported, limit only on options */ |
---|
| 38 | +/* More are supported, limit only on options */ |
---|
| 39 | +#define MAX_UNITS 8 |
---|
| 40 | + |
---|
37 | 41 | /* Used to pass the full-duplex flag, etc. */ |
---|
38 | 42 | static int full_duplex[MAX_UNITS]; |
---|
39 | 43 | static int options[MAX_UNITS]; |
---|
.. | .. |
---|
52 | 56 | #include <linux/netdevice.h> |
---|
53 | 57 | #include <linux/etherdevice.h> |
---|
54 | 58 | |
---|
55 | | -#include <asm/io.h> |
---|
| 59 | +#include <linux/io.h> |
---|
56 | 60 | #include <asm/irq.h> |
---|
57 | 61 | #include <linux/uaccess.h> |
---|
58 | 62 | |
---|
59 | 63 | #include "8390.h" |
---|
60 | 64 | |
---|
61 | | -static u32 ne2k_msg_enable; |
---|
| 65 | +static int ne2k_msg_enable; |
---|
62 | 66 | |
---|
63 | | -/* These identify the driver base version and may not be removed. */ |
---|
64 | | -static const char version[] = |
---|
65 | | - KERN_INFO DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE |
---|
66 | | - " D. Becker/P. Gortmaker\n"; |
---|
| 67 | +static const int default_msg_level = (NETIF_MSG_DRV | NETIF_MSG_PROBE | |
---|
| 68 | + NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR); |
---|
67 | 69 | |
---|
68 | 70 | #if defined(__powerpc__) |
---|
69 | 71 | #define inl_le(addr) le32_to_cpu(inl(addr)) |
---|
70 | 72 | #define inw_le(addr) le16_to_cpu(inw(addr)) |
---|
71 | 73 | #endif |
---|
72 | 74 | |
---|
73 | | -#define PFX DRV_NAME ": " |
---|
74 | | - |
---|
75 | | -MODULE_AUTHOR("Donald Becker / Paul Gortmaker"); |
---|
76 | | -MODULE_DESCRIPTION("PCI NE2000 clone driver"); |
---|
| 75 | +MODULE_AUTHOR(DRV_AUTHOR); |
---|
| 76 | +MODULE_DESCRIPTION(DRV_DESCRIPTION); |
---|
| 77 | +MODULE_VERSION(DRV_VERSION); |
---|
77 | 78 | MODULE_LICENSE("GPL"); |
---|
78 | 79 | |
---|
79 | | -module_param_named(msg_enable, ne2k_msg_enable, uint, 0444); |
---|
| 80 | +module_param_named(msg_enable, ne2k_msg_enable, int, 0444); |
---|
80 | 81 | module_param_array(options, int, NULL, 0); |
---|
81 | 82 | module_param_array(full_duplex, int, NULL, 0); |
---|
82 | 83 | MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)"); |
---|
83 | 84 | MODULE_PARM_DESC(options, "Bit 5: full duplex"); |
---|
84 | 85 | MODULE_PARM_DESC(full_duplex, "full duplex setting(s) (1)"); |
---|
85 | 86 | |
---|
86 | | -/* Some defines that people can play with if so inclined. */ |
---|
| 87 | +/* Some defines that people can play with if so inclined. |
---|
| 88 | + */ |
---|
87 | 89 | |
---|
88 | 90 | /* Use 32 bit data-movement operations instead of 16 bit. */ |
---|
89 | 91 | #define USE_LONGIO |
---|
.. | .. |
---|
91 | 93 | /* Do we implement the read before write bugfix ? */ |
---|
92 | 94 | /* #define NE_RW_BUGFIX */ |
---|
93 | 95 | |
---|
94 | | -/* Flags. We rename an existing ei_status field to store flags! */ |
---|
95 | | -/* Thus only the low 8 bits are usable for non-init-time flags. */ |
---|
| 96 | +/* Flags. We rename an existing ei_status field to store flags! |
---|
| 97 | + * Thus only the low 8 bits are usable for non-init-time flags. |
---|
| 98 | + */ |
---|
96 | 99 | #define ne2k_flags reg0 |
---|
| 100 | + |
---|
97 | 101 | enum { |
---|
98 | | - ONLY_16BIT_IO=8, ONLY_32BIT_IO=4, /* Chip can do only 16/32-bit xfers. */ |
---|
99 | | - FORCE_FDX=0x20, /* User override. */ |
---|
100 | | - REALTEK_FDX=0x40, HOLTEK_FDX=0x80, |
---|
101 | | - STOP_PG_0x60=0x100, |
---|
| 102 | + /* Chip can do only 16/32-bit xfers. */ |
---|
| 103 | + ONLY_16BIT_IO = 8, ONLY_32BIT_IO = 4, |
---|
| 104 | + /* User override. */ |
---|
| 105 | + FORCE_FDX = 0x20, |
---|
| 106 | + REALTEK_FDX = 0x40, HOLTEK_FDX = 0x80, |
---|
| 107 | + STOP_PG_0x60 = 0x100, |
---|
102 | 108 | }; |
---|
103 | 109 | |
---|
104 | 110 | enum ne2k_pci_chipsets { |
---|
.. | .. |
---|
120 | 126 | char *name; |
---|
121 | 127 | int flags; |
---|
122 | 128 | } pci_clone_list[] = { |
---|
123 | | - {"RealTek RTL-8029", REALTEK_FDX}, |
---|
| 129 | + {"RealTek RTL-8029(AS)", REALTEK_FDX}, |
---|
124 | 130 | {"Winbond 89C940", 0}, |
---|
125 | 131 | {"Compex RL2000", 0}, |
---|
126 | 132 | {"KTI ET32P2", 0}, |
---|
.. | .. |
---|
149 | 155 | { 0x8c4a, 0x1980, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_Winbond_89C940_8c4a }, |
---|
150 | 156 | { 0, } |
---|
151 | 157 | }; |
---|
| 158 | + |
---|
152 | 159 | MODULE_DEVICE_TABLE(pci, ne2k_pci_tbl); |
---|
153 | 160 | |
---|
154 | 161 | |
---|
155 | 162 | /* ---- No user-serviceable parts below ---- */ |
---|
156 | 163 | |
---|
157 | 164 | #define NE_BASE (dev->base_addr) |
---|
158 | | -#define NE_CMD 0x00 |
---|
| 165 | +#define NE_CMD 0x00 |
---|
159 | 166 | #define NE_DATAPORT 0x10 /* NatSemi-defined port window offset. */ |
---|
160 | 167 | #define NE_RESET 0x1f /* Issue a read to reset, a write to clear. */ |
---|
161 | 168 | #define NE_IO_EXTENT 0x20 |
---|
.. | .. |
---|
168 | 175 | static int ne2k_pci_close(struct net_device *dev); |
---|
169 | 176 | |
---|
170 | 177 | static void ne2k_pci_reset_8390(struct net_device *dev); |
---|
171 | | -static void ne2k_pci_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, |
---|
172 | | - int ring_page); |
---|
| 178 | +static void ne2k_pci_get_8390_hdr(struct net_device *dev, |
---|
| 179 | + struct e8390_pkt_hdr *hdr, int ring_page); |
---|
173 | 180 | static void ne2k_pci_block_input(struct net_device *dev, int count, |
---|
174 | | - struct sk_buff *skb, int ring_offset); |
---|
| 181 | + struct sk_buff *skb, int ring_offset); |
---|
175 | 182 | static void ne2k_pci_block_output(struct net_device *dev, const int count, |
---|
176 | | - const unsigned char *buf, const int start_page); |
---|
| 183 | + const unsigned char *buf, |
---|
| 184 | + const int start_page); |
---|
177 | 185 | static const struct ethtool_ops ne2k_pci_ethtool_ops; |
---|
178 | 186 | |
---|
179 | 187 | |
---|
180 | 188 | |
---|
181 | 189 | /* There is no room in the standard 8390 structure for extra info we need, |
---|
182 | | - so we build a meta/outer-wrapper structure.. */ |
---|
| 190 | + * so we build a meta/outer-wrapper structure.. |
---|
| 191 | + */ |
---|
183 | 192 | struct ne2k_pci_card { |
---|
184 | 193 | struct net_device *dev; |
---|
185 | 194 | struct pci_dev *pci_dev; |
---|
.. | .. |
---|
187 | 196 | |
---|
188 | 197 | |
---|
189 | 198 | |
---|
190 | | -/* |
---|
191 | | - NEx000-clone boards have a Station Address (SA) PROM (SAPROM) in the packet |
---|
192 | | - buffer memory space. By-the-spec NE2000 clones have 0x57,0x57 in bytes |
---|
193 | | - 0x0e,0x0f of the SAPROM, while other supposed NE2000 clones must be |
---|
194 | | - detected by their SA prefix. |
---|
195 | | - |
---|
196 | | - Reading the SAPROM from a word-wide card with the 8390 set in byte-wide |
---|
197 | | - mode results in doubled values, which can be detected and compensated for. |
---|
198 | | - |
---|
199 | | - The probe is also responsible for initializing the card and filling |
---|
200 | | - in the 'dev' and 'ei_status' structures. |
---|
201 | | -*/ |
---|
| 199 | +/* NEx000-clone boards have a Station Address (SA) PROM (SAPROM) in the packet |
---|
| 200 | + * buffer memory space. By-the-spec NE2000 clones have 0x57,0x57 in bytes |
---|
| 201 | + * 0x0e,0x0f of the SAPROM, while other supposed NE2000 clones must be |
---|
| 202 | + * detected by their SA prefix. |
---|
| 203 | + * |
---|
| 204 | + * Reading the SAPROM from a word-wide card with the 8390 set in byte-wide |
---|
| 205 | + * mode results in doubled values, which can be detected and compensated for. |
---|
| 206 | + * |
---|
| 207 | + * The probe is also responsible for initializing the card and filling |
---|
| 208 | + * in the 'dev' and 'ei_status' structures. |
---|
| 209 | + */ |
---|
202 | 210 | |
---|
203 | 211 | static const struct net_device_ops ne2k_netdev_ops = { |
---|
204 | 212 | .ndo_open = ne2k_pci_open, |
---|
.. | .. |
---|
208 | 216 | .ndo_get_stats = ei_get_stats, |
---|
209 | 217 | .ndo_set_rx_mode = ei_set_multicast_list, |
---|
210 | 218 | .ndo_validate_addr = eth_validate_addr, |
---|
211 | | - .ndo_set_mac_address = eth_mac_addr, |
---|
| 219 | + .ndo_set_mac_address = eth_mac_addr, |
---|
212 | 220 | #ifdef CONFIG_NET_POLL_CONTROLLER |
---|
213 | 221 | .ndo_poll_controller = ei_poll, |
---|
214 | 222 | #endif |
---|
.. | .. |
---|
227 | 235 | int flags = pci_clone_list[chip_idx].flags; |
---|
228 | 236 | struct ei_device *ei_local; |
---|
229 | 237 | |
---|
230 | | -/* when built into the kernel, we only print version if device is found */ |
---|
231 | | -#ifndef MODULE |
---|
232 | | - static int printed_version; |
---|
233 | | - if (!printed_version++) |
---|
234 | | - printk(version); |
---|
235 | | -#endif |
---|
236 | | - |
---|
237 | 238 | fnd_cnt++; |
---|
238 | 239 | |
---|
239 | | - i = pci_enable_device (pdev); |
---|
| 240 | + i = pci_enable_device(pdev); |
---|
240 | 241 | if (i) |
---|
241 | 242 | return i; |
---|
242 | 243 | |
---|
243 | | - ioaddr = pci_resource_start (pdev, 0); |
---|
| 244 | + ioaddr = pci_resource_start(pdev, 0); |
---|
244 | 245 | irq = pdev->irq; |
---|
245 | 246 | |
---|
246 | | - if (!ioaddr || ((pci_resource_flags (pdev, 0) & IORESOURCE_IO) == 0)) { |
---|
| 247 | + if (!ioaddr || ((pci_resource_flags(pdev, 0) & IORESOURCE_IO) == 0)) { |
---|
247 | 248 | dev_err(&pdev->dev, "no I/O resource at PCI BAR #0\n"); |
---|
248 | 249 | goto err_out; |
---|
249 | 250 | } |
---|
250 | 251 | |
---|
251 | | - if (request_region (ioaddr, NE_IO_EXTENT, DRV_NAME) == NULL) { |
---|
| 252 | + if (!request_region(ioaddr, NE_IO_EXTENT, DRV_NAME)) { |
---|
252 | 253 | dev_err(&pdev->dev, "I/O resource 0x%x @ 0x%lx busy\n", |
---|
253 | 254 | NE_IO_EXTENT, ioaddr); |
---|
254 | 255 | goto err_out; |
---|
.. | .. |
---|
261 | 262 | /* Do a preliminary verification that we have a 8390. */ |
---|
262 | 263 | { |
---|
263 | 264 | int regd; |
---|
264 | | - outb(E8390_NODMA+E8390_PAGE1+E8390_STOP, ioaddr + E8390_CMD); |
---|
| 265 | + |
---|
| 266 | + outb(E8390_NODMA + E8390_PAGE1 + E8390_STOP, ioaddr + E8390_CMD); |
---|
265 | 267 | regd = inb(ioaddr + 0x0d); |
---|
266 | 268 | outb(0xff, ioaddr + 0x0d); |
---|
267 | | - outb(E8390_NODMA+E8390_PAGE0, ioaddr + E8390_CMD); |
---|
268 | | - inb(ioaddr + EN0_COUNTER0); /* Clear the counter by reading. */ |
---|
| 269 | + outb(E8390_NODMA + E8390_PAGE0, ioaddr + E8390_CMD); |
---|
| 270 | + /* Clear the counter by reading. */ |
---|
| 271 | + inb(ioaddr + EN0_COUNTER0); |
---|
269 | 272 | if (inb(ioaddr + EN0_COUNTER0) != 0) { |
---|
270 | 273 | outb(reg0, ioaddr); |
---|
271 | | - outb(regd, ioaddr + 0x0d); /* Restore the old values. */ |
---|
| 274 | + /* Restore the old values. */ |
---|
| 275 | + outb(regd, ioaddr + 0x0d); |
---|
272 | 276 | goto err_out_free_res; |
---|
273 | 277 | } |
---|
274 | 278 | } |
---|
.. | .. |
---|
281 | 285 | } |
---|
282 | 286 | dev->netdev_ops = &ne2k_netdev_ops; |
---|
283 | 287 | ei_local = netdev_priv(dev); |
---|
284 | | - ei_local->msg_enable = ne2k_msg_enable; |
---|
| 288 | + ei_local->msg_enable = netif_msg_init(ne2k_msg_enable, default_msg_level); |
---|
285 | 289 | |
---|
286 | 290 | SET_NETDEV_DEV(dev, &pdev->dev); |
---|
287 | 291 | |
---|
.. | .. |
---|
291 | 295 | |
---|
292 | 296 | outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET); |
---|
293 | 297 | |
---|
294 | | - /* This looks like a horrible timing loop, but it should never take |
---|
295 | | - more than a few cycles. |
---|
296 | | - */ |
---|
| 298 | + /* This looks like a horrible timing loop, but it should never |
---|
| 299 | + * take more than a few cycles. |
---|
| 300 | + */ |
---|
297 | 301 | while ((inb(ioaddr + EN0_ISR) & ENISR_RESET) == 0) |
---|
298 | 302 | /* Limit wait: '2' avoids jiffy roll-over. */ |
---|
299 | 303 | if (jiffies - reset_start_time > 2) { |
---|
.. | .. |
---|
301 | 305 | "Card failure (no reset ack).\n"); |
---|
302 | 306 | goto err_out_free_netdev; |
---|
303 | 307 | } |
---|
304 | | - |
---|
305 | | - outb(0xff, ioaddr + EN0_ISR); /* Ack all intr. */ |
---|
| 308 | + /* Ack all intr. */ |
---|
| 309 | + outb(0xff, ioaddr + EN0_ISR); |
---|
306 | 310 | } |
---|
307 | 311 | |
---|
308 | 312 | /* Read the 16 bytes of station address PROM. |
---|
309 | | - We must first initialize registers, similar to NS8390_init(eifdev, 0). |
---|
310 | | - We can't reliably read the SAPROM address without this. |
---|
311 | | - (I learned the hard way!). */ |
---|
| 313 | + * We must first initialize registers, similar |
---|
| 314 | + * to NS8390_init(eifdev, 0). |
---|
| 315 | + * We can't reliably read the SAPROM address without this. |
---|
| 316 | + * (I learned the hard way!). |
---|
| 317 | + */ |
---|
312 | 318 | { |
---|
313 | 319 | struct {unsigned char value, offset; } program_seq[] = { |
---|
314 | | - {E8390_NODMA+E8390_PAGE0+E8390_STOP, E8390_CMD}, /* Select page 0*/ |
---|
315 | | - {0x49, EN0_DCFG}, /* Set word-wide access. */ |
---|
316 | | - {0x00, EN0_RCNTLO}, /* Clear the count regs. */ |
---|
| 320 | + /* Select page 0 */ |
---|
| 321 | + {E8390_NODMA + E8390_PAGE0 + E8390_STOP, E8390_CMD}, |
---|
| 322 | + /* Set word-wide access */ |
---|
| 323 | + {0x49, EN0_DCFG}, |
---|
| 324 | + /* Clear the count regs. */ |
---|
| 325 | + {0x00, EN0_RCNTLO}, |
---|
| 326 | + /* Mask completion IRQ */ |
---|
317 | 327 | {0x00, EN0_RCNTHI}, |
---|
318 | | - {0x00, EN0_IMR}, /* Mask completion irq. */ |
---|
| 328 | + {0x00, EN0_IMR}, |
---|
319 | 329 | {0xFF, EN0_ISR}, |
---|
320 | | - {E8390_RXOFF, EN0_RXCR}, /* 0x20 Set to monitor */ |
---|
321 | | - {E8390_TXOFF, EN0_TXCR}, /* 0x02 and loopback mode. */ |
---|
| 330 | + /* 0x20 Set to monitor */ |
---|
| 331 | + {E8390_RXOFF, EN0_RXCR}, |
---|
| 332 | + /* 0x02 and loopback mode */ |
---|
| 333 | + {E8390_TXOFF, EN0_TXCR}, |
---|
322 | 334 | {32, EN0_RCNTLO}, |
---|
323 | 335 | {0x00, EN0_RCNTHI}, |
---|
324 | | - {0x00, EN0_RSARLO}, /* DMA starting at 0x0000. */ |
---|
| 336 | + /* DMA starting at 0x0000 */ |
---|
| 337 | + {0x00, EN0_RSARLO}, |
---|
325 | 338 | {0x00, EN0_RSARHI}, |
---|
326 | 339 | {E8390_RREAD+E8390_START, E8390_CMD}, |
---|
327 | 340 | }; |
---|
328 | 341 | for (i = 0; i < ARRAY_SIZE(program_seq); i++) |
---|
329 | | - outb(program_seq[i].value, ioaddr + program_seq[i].offset); |
---|
| 342 | + outb(program_seq[i].value, |
---|
| 343 | + ioaddr + program_seq[i].offset); |
---|
330 | 344 | |
---|
331 | 345 | } |
---|
332 | 346 | |
---|
333 | 347 | /* Note: all PCI cards have at least 16 bit access, so we don't have |
---|
334 | | - to check for 8 bit cards. Most cards permit 32 bit access. */ |
---|
| 348 | + * to check for 8 bit cards. Most cards permit 32 bit access. |
---|
| 349 | + */ |
---|
335 | 350 | if (flags & ONLY_32BIT_IO) { |
---|
336 | 351 | for (i = 0; i < 4 ; i++) |
---|
337 | 352 | ((u32 *)SA_prom)[i] = le32_to_cpu(inl(ioaddr + NE_DATAPORT)); |
---|
338 | 353 | } else |
---|
339 | | - for(i = 0; i < 32 /*sizeof(SA_prom)*/; i++) |
---|
| 354 | + for (i = 0; i < 32 /* sizeof(SA_prom )*/; i++) |
---|
340 | 355 | SA_prom[i] = inb(ioaddr + NE_DATAPORT); |
---|
341 | 356 | |
---|
342 | 357 | /* We always set the 8390 registers for word mode. */ |
---|
.. | .. |
---|
356 | 371 | ei_status.word16 = 1; |
---|
357 | 372 | ei_status.ne2k_flags = flags; |
---|
358 | 373 | if (fnd_cnt < MAX_UNITS) { |
---|
359 | | - if (full_duplex[fnd_cnt] > 0 || (options[fnd_cnt] & FORCE_FDX)) |
---|
| 374 | + if (full_duplex[fnd_cnt] > 0 || (options[fnd_cnt] & FORCE_FDX)) |
---|
360 | 375 | ei_status.ne2k_flags |= FORCE_FDX; |
---|
361 | 376 | } |
---|
362 | 377 | |
---|
.. | .. |
---|
388 | 403 | return 0; |
---|
389 | 404 | |
---|
390 | 405 | err_out_free_netdev: |
---|
391 | | - free_netdev (dev); |
---|
| 406 | + free_netdev(dev); |
---|
392 | 407 | err_out_free_res: |
---|
393 | | - release_region (ioaddr, NE_IO_EXTENT); |
---|
| 408 | + release_region(ioaddr, NE_IO_EXTENT); |
---|
394 | 409 | err_out: |
---|
395 | 410 | pci_disable_device(pdev); |
---|
396 | 411 | return -ENODEV; |
---|
397 | 412 | } |
---|
398 | 413 | |
---|
399 | | -/* |
---|
400 | | - * Magic incantation sequence for full duplex on the supported cards. |
---|
| 414 | +/* Magic incantation sequence for full duplex on the supported cards. |
---|
401 | 415 | */ |
---|
402 | 416 | static inline int set_realtek_fdx(struct net_device *dev) |
---|
403 | 417 | { |
---|
.. | .. |
---|
431 | 445 | |
---|
432 | 446 | static int ne2k_pci_open(struct net_device *dev) |
---|
433 | 447 | { |
---|
434 | | - int ret = request_irq(dev->irq, ei_interrupt, IRQF_SHARED, dev->name, dev); |
---|
| 448 | + int ret = request_irq(dev->irq, ei_interrupt, IRQF_SHARED, |
---|
| 449 | + dev->name, dev); |
---|
| 450 | + |
---|
435 | 451 | if (ret) |
---|
436 | 452 | return ret; |
---|
437 | 453 | |
---|
.. | .. |
---|
450 | 466 | } |
---|
451 | 467 | |
---|
452 | 468 | /* Hard reset the card. This used to pause for the same period that a |
---|
453 | | - 8390 reset command required, but that shouldn't be necessary. */ |
---|
| 469 | + * 8390 reset command required, but that shouldn't be necessary. |
---|
| 470 | + */ |
---|
454 | 471 | static void ne2k_pci_reset_8390(struct net_device *dev) |
---|
455 | 472 | { |
---|
456 | 473 | unsigned long reset_start_time = jiffies; |
---|
.. | .. |
---|
467 | 484 | /* This check _should_not_ be necessary, omit eventually. */ |
---|
468 | 485 | while ((inb(NE_BASE+EN0_ISR) & ENISR_RESET) == 0) |
---|
469 | 486 | if (jiffies - reset_start_time > 2) { |
---|
470 | | - netdev_err(dev, "ne2k_pci_reset_8390() did not complete.\n"); |
---|
| 487 | + netdev_err(dev, "%s did not complete.\n", __func__); |
---|
471 | 488 | break; |
---|
472 | 489 | } |
---|
473 | | - outb(ENISR_RESET, NE_BASE + EN0_ISR); /* Ack intr. */ |
---|
| 490 | + /* Ack intr. */ |
---|
| 491 | + outb(ENISR_RESET, NE_BASE + EN0_ISR); |
---|
474 | 492 | } |
---|
475 | 493 | |
---|
476 | 494 | /* Grab the 8390 specific header. Similar to the block_input routine, but |
---|
477 | | - we don't need to be concerned with ring wrap as the header will be at |
---|
478 | | - the start of a page, so we optimize accordingly. */ |
---|
| 495 | + * we don't need to be concerned with ring wrap as the header will be at |
---|
| 496 | + * the start of a page, so we optimize accordingly. |
---|
| 497 | + */ |
---|
479 | 498 | |
---|
480 | | -static void ne2k_pci_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_page) |
---|
| 499 | +static void ne2k_pci_get_8390_hdr(struct net_device *dev, |
---|
| 500 | + struct e8390_pkt_hdr *hdr, int ring_page) |
---|
481 | 501 | { |
---|
482 | 502 | |
---|
483 | 503 | long nic_base = dev->base_addr; |
---|
484 | 504 | |
---|
485 | | - /* This *shouldn't* happen. If it does, it's the last thing you'll see */ |
---|
| 505 | + /* This *shouldn't* happen. If it does, it's the last thing you'll see |
---|
| 506 | + */ |
---|
486 | 507 | if (ei_status.dmaing) { |
---|
487 | | - netdev_err(dev, "DMAing conflict in ne2k_pci_get_8390_hdr " |
---|
488 | | - "[DMAstat:%d][irqlock:%d].\n", |
---|
489 | | - ei_status.dmaing, ei_status.irqlock); |
---|
| 508 | + netdev_err(dev, "DMAing conflict in %s [DMAstat:%d][irqlock:%d].\n", |
---|
| 509 | + __func__, ei_status.dmaing, ei_status.irqlock); |
---|
490 | 510 | return; |
---|
491 | 511 | } |
---|
492 | 512 | |
---|
493 | 513 | ei_status.dmaing |= 0x01; |
---|
494 | | - outb(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD); |
---|
| 514 | + outb(E8390_NODMA + E8390_PAGE0 + E8390_START, nic_base + NE_CMD); |
---|
495 | 515 | outb(sizeof(struct e8390_pkt_hdr), nic_base + EN0_RCNTLO); |
---|
496 | 516 | outb(0, nic_base + EN0_RCNTHI); |
---|
497 | 517 | outb(0, nic_base + EN0_RSARLO); /* On page boundary */ |
---|
.. | .. |
---|
499 | 519 | outb(E8390_RREAD+E8390_START, nic_base + NE_CMD); |
---|
500 | 520 | |
---|
501 | 521 | if (ei_status.ne2k_flags & ONLY_16BIT_IO) { |
---|
502 | | - insw(NE_BASE + NE_DATAPORT, hdr, sizeof(struct e8390_pkt_hdr)>>1); |
---|
| 522 | + insw(NE_BASE + NE_DATAPORT, hdr, |
---|
| 523 | + sizeof(struct e8390_pkt_hdr) >> 1); |
---|
503 | 524 | } else { |
---|
504 | | - *(u32*)hdr = le32_to_cpu(inl(NE_BASE + NE_DATAPORT)); |
---|
| 525 | + *(u32 *)hdr = le32_to_cpu(inl(NE_BASE + NE_DATAPORT)); |
---|
505 | 526 | le16_to_cpus(&hdr->count); |
---|
506 | 527 | } |
---|
507 | | - |
---|
508 | | - outb(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */ |
---|
| 528 | + /* Ack intr. */ |
---|
| 529 | + outb(ENISR_RDC, nic_base + EN0_ISR); |
---|
509 | 530 | ei_status.dmaing &= ~0x01; |
---|
510 | 531 | } |
---|
511 | 532 | |
---|
512 | 533 | /* Block input and output, similar to the Crynwr packet driver. If you |
---|
513 | | - are porting to a new ethercard, look at the packet driver source for hints. |
---|
514 | | - The NEx000 doesn't share the on-board packet memory -- you have to put |
---|
515 | | - the packet out through the "remote DMA" dataport using outb. */ |
---|
| 534 | + *are porting to a new ethercard, look at the packet driver source for hints. |
---|
| 535 | + *The NEx000 doesn't share the on-board packet memory -- you have to put |
---|
| 536 | + *the packet out through the "remote DMA" dataport using outb. |
---|
| 537 | + */ |
---|
516 | 538 | |
---|
517 | 539 | static void ne2k_pci_block_input(struct net_device *dev, int count, |
---|
518 | 540 | struct sk_buff *skb, int ring_offset) |
---|
.. | .. |
---|
520 | 542 | long nic_base = dev->base_addr; |
---|
521 | 543 | char *buf = skb->data; |
---|
522 | 544 | |
---|
523 | | - /* This *shouldn't* happen. If it does, it's the last thing you'll see */ |
---|
| 545 | + /* This *shouldn't* happen. |
---|
| 546 | + * If it does, it's the last thing you'll see. |
---|
| 547 | + */ |
---|
524 | 548 | if (ei_status.dmaing) { |
---|
525 | | - netdev_err(dev, "DMAing conflict in ne2k_pci_block_input " |
---|
526 | | - "[DMAstat:%d][irqlock:%d].\n", |
---|
527 | | - ei_status.dmaing, ei_status.irqlock); |
---|
| 549 | + netdev_err(dev, "DMAing conflict in %s [DMAstat:%d][irqlock:%d]\n", |
---|
| 550 | + __func__, ei_status.dmaing, ei_status.irqlock); |
---|
528 | 551 | return; |
---|
529 | 552 | } |
---|
530 | 553 | ei_status.dmaing |= 0x01; |
---|
531 | 554 | if (ei_status.ne2k_flags & ONLY_32BIT_IO) |
---|
532 | 555 | count = (count + 3) & 0xFFFC; |
---|
533 | | - outb(E8390_NODMA+E8390_PAGE0+E8390_START, nic_base+ NE_CMD); |
---|
| 556 | + outb(E8390_NODMA + E8390_PAGE0 + E8390_START, nic_base + NE_CMD); |
---|
534 | 557 | outb(count & 0xff, nic_base + EN0_RCNTLO); |
---|
535 | 558 | outb(count >> 8, nic_base + EN0_RCNTHI); |
---|
536 | 559 | outb(ring_offset & 0xff, nic_base + EN0_RSARLO); |
---|
537 | 560 | outb(ring_offset >> 8, nic_base + EN0_RSARHI); |
---|
538 | | - outb(E8390_RREAD+E8390_START, nic_base + NE_CMD); |
---|
| 561 | + outb(E8390_RREAD + E8390_START, nic_base + NE_CMD); |
---|
539 | 562 | |
---|
540 | 563 | if (ei_status.ne2k_flags & ONLY_16BIT_IO) { |
---|
541 | | - insw(NE_BASE + NE_DATAPORT,buf,count>>1); |
---|
542 | | - if (count & 0x01) { |
---|
| 564 | + insw(NE_BASE + NE_DATAPORT, buf, count >> 1); |
---|
| 565 | + if (count & 0x01) |
---|
543 | 566 | buf[count-1] = inb(NE_BASE + NE_DATAPORT); |
---|
544 | | - } |
---|
545 | 567 | } else { |
---|
546 | | - insl(NE_BASE + NE_DATAPORT, buf, count>>2); |
---|
| 568 | + insl(NE_BASE + NE_DATAPORT, buf, count >> 2); |
---|
547 | 569 | if (count & 3) { |
---|
548 | 570 | buf += count & ~3; |
---|
549 | 571 | if (count & 2) { |
---|
.. | .. |
---|
556 | 578 | *buf = inb(NE_BASE + NE_DATAPORT); |
---|
557 | 579 | } |
---|
558 | 580 | } |
---|
559 | | - |
---|
560 | | - outb(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */ |
---|
| 581 | + /* Ack intr. */ |
---|
| 582 | + outb(ENISR_RDC, nic_base + EN0_ISR); |
---|
561 | 583 | ei_status.dmaing &= ~0x01; |
---|
562 | 584 | } |
---|
563 | 585 | |
---|
564 | 586 | static void ne2k_pci_block_output(struct net_device *dev, int count, |
---|
565 | | - const unsigned char *buf, const int start_page) |
---|
| 587 | + const unsigned char *buf, const int start_page) |
---|
566 | 588 | { |
---|
567 | 589 | long nic_base = NE_BASE; |
---|
568 | 590 | unsigned long dma_start; |
---|
569 | 591 | |
---|
570 | 592 | /* On little-endian it's always safe to round the count up for |
---|
571 | | - word writes. */ |
---|
| 593 | + * word writes. |
---|
| 594 | + */ |
---|
572 | 595 | if (ei_status.ne2k_flags & ONLY_32BIT_IO) |
---|
573 | 596 | count = (count + 3) & 0xFFFC; |
---|
574 | 597 | else |
---|
575 | 598 | if (count & 0x01) |
---|
576 | 599 | count++; |
---|
577 | 600 | |
---|
578 | | - /* This *shouldn't* happen. If it does, it's the last thing you'll see */ |
---|
| 601 | + /* This *shouldn't* happen. |
---|
| 602 | + * If it does, it's the last thing you'll see. |
---|
| 603 | + */ |
---|
579 | 604 | if (ei_status.dmaing) { |
---|
580 | | - netdev_err(dev, "DMAing conflict in ne2k_pci_block_output." |
---|
581 | | - "[DMAstat:%d][irqlock:%d]\n", |
---|
582 | | - ei_status.dmaing, ei_status.irqlock); |
---|
| 605 | + netdev_err(dev, "DMAing conflict in %s [DMAstat:%d][irqlock:%d]\n", |
---|
| 606 | + __func__, ei_status.dmaing, ei_status.irqlock); |
---|
583 | 607 | return; |
---|
584 | 608 | } |
---|
585 | 609 | ei_status.dmaing |= 0x01; |
---|
.. | .. |
---|
588 | 612 | |
---|
589 | 613 | #ifdef NE8390_RW_BUGFIX |
---|
590 | 614 | /* Handle the read-before-write bug the same way as the |
---|
591 | | - Crynwr packet driver -- the NatSemi method doesn't work. |
---|
592 | | - Actually this doesn't always work either, but if you have |
---|
593 | | - problems with your NEx000 this is better than nothing! */ |
---|
| 615 | + * Crynwr packet driver -- the NatSemi method doesn't work. |
---|
| 616 | + * Actually this doesn't always work either, but if you have |
---|
| 617 | + * problems with your NEx000 this is better than nothing! |
---|
| 618 | + */ |
---|
594 | 619 | outb(0x42, nic_base + EN0_RCNTLO); |
---|
595 | 620 | outb(0x00, nic_base + EN0_RCNTHI); |
---|
596 | 621 | outb(0x42, nic_base + EN0_RSARLO); |
---|
.. | .. |
---|
599 | 624 | #endif |
---|
600 | 625 | outb(ENISR_RDC, nic_base + EN0_ISR); |
---|
601 | 626 | |
---|
602 | | - /* Now the normal output. */ |
---|
| 627 | + /* Now the normal output. */ |
---|
603 | 628 | outb(count & 0xff, nic_base + EN0_RCNTLO); |
---|
604 | 629 | outb(count >> 8, nic_base + EN0_RCNTHI); |
---|
605 | 630 | outb(0x00, nic_base + EN0_RSARLO); |
---|
606 | 631 | outb(start_page, nic_base + EN0_RSARHI); |
---|
607 | 632 | outb(E8390_RWRITE+E8390_START, nic_base + NE_CMD); |
---|
608 | 633 | if (ei_status.ne2k_flags & ONLY_16BIT_IO) { |
---|
609 | | - outsw(NE_BASE + NE_DATAPORT, buf, count>>1); |
---|
| 634 | + outsw(NE_BASE + NE_DATAPORT, buf, count >> 1); |
---|
610 | 635 | } else { |
---|
611 | | - outsl(NE_BASE + NE_DATAPORT, buf, count>>2); |
---|
| 636 | + outsl(NE_BASE + NE_DATAPORT, buf, count >> 2); |
---|
612 | 637 | if (count & 3) { |
---|
613 | 638 | buf += count & ~3; |
---|
614 | 639 | if (count & 2) { |
---|
.. | .. |
---|
623 | 648 | dma_start = jiffies; |
---|
624 | 649 | |
---|
625 | 650 | while ((inb(nic_base + EN0_ISR) & ENISR_RDC) == 0) |
---|
626 | | - if (jiffies - dma_start > 2) { /* Avoid clock roll-over. */ |
---|
| 651 | + /* Avoid clock roll-over. */ |
---|
| 652 | + if (jiffies - dma_start > 2) { |
---|
627 | 653 | netdev_warn(dev, "timeout waiting for Tx RDC.\n"); |
---|
628 | 654 | ne2k_pci_reset_8390(dev); |
---|
629 | | - NS8390_init(dev,1); |
---|
| 655 | + NS8390_init(dev, 1); |
---|
630 | 656 | break; |
---|
631 | 657 | } |
---|
632 | | - |
---|
633 | | - outb(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */ |
---|
| 658 | + /* Ack intr. */ |
---|
| 659 | + outb(ENISR_RDC, nic_base + EN0_ISR); |
---|
634 | 660 | ei_status.dmaing &= ~0x01; |
---|
635 | 661 | } |
---|
636 | 662 | |
---|
.. | .. |
---|
640 | 666 | struct ei_device *ei = netdev_priv(dev); |
---|
641 | 667 | struct pci_dev *pci_dev = (struct pci_dev *) ei->priv; |
---|
642 | 668 | |
---|
643 | | - strlcpy(info->driver, DRV_NAME, sizeof(info->driver)); |
---|
644 | | - strlcpy(info->version, DRV_VERSION, sizeof(info->version)); |
---|
645 | | - strlcpy(info->bus_info, pci_name(pci_dev), sizeof(info->bus_info)); |
---|
| 669 | + strscpy(info->driver, DRV_NAME, sizeof(info->driver)); |
---|
| 670 | + strscpy(info->version, DRV_VERSION, sizeof(info->version)); |
---|
| 671 | + strscpy(info->bus_info, pci_name(pci_dev), sizeof(info->bus_info)); |
---|
646 | 672 | } |
---|
647 | 673 | |
---|
648 | 674 | static u32 ne2k_pci_get_msglevel(struct net_device *dev) |
---|
.. | .. |
---|
676 | 702 | pci_disable_device(pdev); |
---|
677 | 703 | } |
---|
678 | 704 | |
---|
679 | | -#ifdef CONFIG_PM |
---|
680 | | -static int ne2k_pci_suspend (struct pci_dev *pdev, pm_message_t state) |
---|
| 705 | +static int __maybe_unused ne2k_pci_suspend(struct device *dev_d) |
---|
681 | 706 | { |
---|
682 | | - struct net_device *dev = pci_get_drvdata (pdev); |
---|
| 707 | + struct net_device *dev = dev_get_drvdata(dev_d); |
---|
683 | 708 | |
---|
684 | 709 | netif_device_detach(dev); |
---|
685 | | - pci_save_state(pdev); |
---|
686 | | - pci_disable_device(pdev); |
---|
687 | | - pci_set_power_state(pdev, pci_choose_state(pdev, state)); |
---|
688 | 710 | |
---|
689 | 711 | return 0; |
---|
690 | 712 | } |
---|
691 | 713 | |
---|
692 | | -static int ne2k_pci_resume (struct pci_dev *pdev) |
---|
| 714 | +static int __maybe_unused ne2k_pci_resume(struct device *dev_d) |
---|
693 | 715 | { |
---|
694 | | - struct net_device *dev = pci_get_drvdata (pdev); |
---|
695 | | - int rc; |
---|
696 | | - |
---|
697 | | - pci_set_power_state(pdev, PCI_D0); |
---|
698 | | - pci_restore_state(pdev); |
---|
699 | | - |
---|
700 | | - rc = pci_enable_device(pdev); |
---|
701 | | - if (rc) |
---|
702 | | - return rc; |
---|
| 716 | + struct net_device *dev = dev_get_drvdata(dev_d); |
---|
703 | 717 | |
---|
704 | 718 | NS8390_init(dev, 1); |
---|
705 | 719 | netif_device_attach(dev); |
---|
.. | .. |
---|
707 | 721 | return 0; |
---|
708 | 722 | } |
---|
709 | 723 | |
---|
710 | | -#endif /* CONFIG_PM */ |
---|
711 | | - |
---|
| 724 | +static SIMPLE_DEV_PM_OPS(ne2k_pci_pm_ops, ne2k_pci_suspend, ne2k_pci_resume); |
---|
712 | 725 | |
---|
713 | 726 | static struct pci_driver ne2k_driver = { |
---|
714 | 727 | .name = DRV_NAME, |
---|
715 | 728 | .probe = ne2k_pci_init_one, |
---|
716 | 729 | .remove = ne2k_pci_remove_one, |
---|
717 | 730 | .id_table = ne2k_pci_tbl, |
---|
718 | | -#ifdef CONFIG_PM |
---|
719 | | - .suspend = ne2k_pci_suspend, |
---|
720 | | - .resume = ne2k_pci_resume, |
---|
721 | | -#endif /* CONFIG_PM */ |
---|
722 | | - |
---|
| 731 | + .driver.pm = &ne2k_pci_pm_ops, |
---|
723 | 732 | }; |
---|
724 | 733 | |
---|
725 | 734 | |
---|
726 | 735 | static int __init ne2k_pci_init(void) |
---|
727 | 736 | { |
---|
728 | | -/* when a module, this is printed whether or not devices are found in probe */ |
---|
729 | | -#ifdef MODULE |
---|
730 | | - printk(version); |
---|
731 | | -#endif |
---|
732 | 737 | return pci_register_driver(&ne2k_driver); |
---|
733 | 738 | } |
---|
734 | 739 | |
---|
735 | 740 | |
---|
736 | 741 | static void __exit ne2k_pci_cleanup(void) |
---|
737 | 742 | { |
---|
738 | | - pci_unregister_driver (&ne2k_driver); |
---|
| 743 | + pci_unregister_driver(&ne2k_driver); |
---|
739 | 744 | } |
---|
740 | 745 | |
---|
741 | 746 | module_init(ne2k_pci_init); |
---|