aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@iki.fi>2011-01-21 05:59:30 -0500
committerDavid S. Miller <davem@davemloft.net>2011-01-24 18:07:06 -0500
commitc659c38b2796578638548b77ef626d93609ec8ac (patch)
treea013399d0e7f6c6fb2e3dff7ff322d98584a491e
parentc445477d74ab3779d1386ab797fbb9b628eb9f64 (diff)
tlan: Code cleanup: checkpatch.pl is relatively happy now.
- Remove CamelCase. - Convert hexadecimals to lower case. - Remove useless comments. Tlan driver contained a name of the function at the end of it in a comment. Remove those comments. - Remove local typedefs. Use real types instead of typedefs in code. - Resolve space issues and reindent. - One warning remain, it's a case where printing a single line involves a number of printk()s. Signed-off-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/tlan.c3703
-rw-r--r--drivers/net/tlan.h192
2 files changed, 1967 insertions, 1928 deletions
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c
index f8e463cd8ecc..57380b1b3b60 100644
--- a/drivers/net/tlan.c
+++ b/drivers/net/tlan.c
@@ -63,45 +63,45 @@
63 * - Other minor stuff 63 * - Other minor stuff
64 * 64 *
65 * v1.4 Feb 10, 2000 - Updated with more changes required after Dave's 65 * v1.4 Feb 10, 2000 - Updated with more changes required after Dave's
66 * network cleanup in 2.3.43pre7 (Tigran & myself) 66 * network cleanup in 2.3.43pre7 (Tigran & myself)
67 * - Minor stuff. 67 * - Minor stuff.
68 * 68 *
69 * v1.5 March 22, 2000 - Fixed another timer bug that would hang the driver 69 * v1.5 March 22, 2000 - Fixed another timer bug that would hang the
70 * if no cable/link were present. 70 * driver if no cable/link were present.
71 * - Cosmetic changes. 71 * - Cosmetic changes.
72 * - TODO: Port completely to new PCI/DMA API 72 * - TODO: Port completely to new PCI/DMA API
73 * Auto-Neg fallback. 73 * Auto-Neg fallback.
74 * 74 *
75 * v1.6 April 04, 2000 - Fixed driver support for kernel-parameters. Haven't 75 * v1.6 April 04, 2000 - Fixed driver support for kernel-parameters.
76 * tested it though, as the kernel support is currently 76 * Haven't tested it though, as the kernel support
77 * broken (2.3.99p4p3). 77 * is currently broken (2.3.99p4p3).
78 * - Updated tlan.txt accordingly. 78 * - Updated tlan.txt accordingly.
79 * - Adjusted minimum/maximum frame length. 79 * - Adjusted minimum/maximum frame length.
80 * - There is now a TLAN website up at 80 * - There is now a TLAN website up at
81 * http://hp.sourceforge.net/ 81 * http://hp.sourceforge.net/
82 * 82 *
83 * v1.7 April 07, 2000 - Started to implement custom ioctls. Driver now 83 * v1.7 April 07, 2000 - Started to implement custom ioctls. Driver now
84 * reports PHY information when used with Donald 84 * reports PHY information when used with Donald
85 * Beckers userspace MII diagnostics utility. 85 * Beckers userspace MII diagnostics utility.
86 * 86 *
87 * v1.8 April 23, 2000 - Fixed support for forced speed/duplex settings. 87 * v1.8 April 23, 2000 - Fixed support for forced speed/duplex settings.
88 * - Added link information to Auto-Neg and forced 88 * - Added link information to Auto-Neg and forced
89 * modes. When NIC operates with auto-neg the driver 89 * modes. When NIC operates with auto-neg the driver
90 * will report Link speed & duplex modes as well as 90 * will report Link speed & duplex modes as well as
91 * link partner abilities. When forced link is used, 91 * link partner abilities. When forced link is used,
92 * the driver will report status of the established 92 * the driver will report status of the established
93 * link. 93 * link.
94 * Please read tlan.txt for additional information. 94 * Please read tlan.txt for additional information.
95 * - Removed call to check_region(), and used 95 * - Removed call to check_region(), and used
96 * return value of request_region() instead. 96 * return value of request_region() instead.
97 * 97 *
98 * v1.8a May 28, 2000 - Minor updates. 98 * v1.8a May 28, 2000 - Minor updates.
99 * 99 *
100 * v1.9 July 25, 2000 - Fixed a few remaining Full-Duplex issues. 100 * v1.9 July 25, 2000 - Fixed a few remaining Full-Duplex issues.
101 * - Updated with timer fixes from Andrew Morton. 101 * - Updated with timer fixes from Andrew Morton.
102 * - Fixed module race in TLan_Open. 102 * - Fixed module race in TLan_Open.
103 * - Added routine to monitor PHY status. 103 * - Added routine to monitor PHY status.
104 * - Added activity led support for Proliant devices. 104 * - Added activity led support for Proliant devices.
105 * 105 *
106 * v1.10 Aug 30, 2000 - Added support for EISA based tlan controllers 106 * v1.10 Aug 30, 2000 - Added support for EISA based tlan controllers
107 * like the Compaq NetFlex3/E. 107 * like the Compaq NetFlex3/E.
@@ -111,8 +111,8 @@
111 * hardware probe is done with kernel API and 111 * hardware probe is done with kernel API and
112 * TLan_EisaProbe. 112 * TLan_EisaProbe.
113 * - Adjusted debug information for probing. 113 * - Adjusted debug information for probing.
114 * - Fixed bug that would cause general debug information 114 * - Fixed bug that would cause general debug
115 * to be printed after driver removal. 115 * information to be printed after driver removal.
116 * - Added transmit timeout handling. 116 * - Added transmit timeout handling.
117 * - Fixed OOM return values in tlan_probe. 117 * - Fixed OOM return values in tlan_probe.
118 * - Fixed possible mem leak in tlan_exit 118 * - Fixed possible mem leak in tlan_exit
@@ -136,8 +136,8 @@
136 * 136 *
137 * v1.12 Oct 12, 2000 - Minor fixes (memleak, init, etc.) 137 * v1.12 Oct 12, 2000 - Minor fixes (memleak, init, etc.)
138 * 138 *
139 * v1.13 Nov 28, 2000 - Stop flooding console with auto-neg issues 139 * v1.13 Nov 28, 2000 - Stop flooding console with auto-neg issues
140 * when link can't be established. 140 * when link can't be established.
141 * - Added the bbuf option as a kernel parameter. 141 * - Added the bbuf option as a kernel parameter.
142 * - Fixed ioaddr probe bug. 142 * - Fixed ioaddr probe bug.
143 * - Fixed stupid deadlock with MII interrupts. 143 * - Fixed stupid deadlock with MII interrupts.
@@ -147,28 +147,29 @@
147 * TLAN v1.0 silicon. This needs to be investigated 147 * TLAN v1.0 silicon. This needs to be investigated
148 * further. 148 * further.
149 * 149 *
150 * v1.14 Dec 16, 2000 - Added support for servicing multiple frames per. 150 * v1.14 Dec 16, 2000 - Added support for servicing multiple frames per.
151 * interrupt. Thanks goes to 151 * interrupt. Thanks goes to
152 * Adam Keys <adam@ti.com> 152 * Adam Keys <adam@ti.com>
153 * Denis Beaudoin <dbeaudoin@ti.com> 153 * Denis Beaudoin <dbeaudoin@ti.com>
154 * for providing the patch. 154 * for providing the patch.
155 * - Fixed auto-neg output when using multiple 155 * - Fixed auto-neg output when using multiple
156 * adapters. 156 * adapters.
157 * - Converted to use new taskq interface. 157 * - Converted to use new taskq interface.
158 * 158 *
159 * v1.14a Jan 6, 2001 - Minor adjustments (spinlocks, etc.) 159 * v1.14a Jan 6, 2001 - Minor adjustments (spinlocks, etc.)
160 * 160 *
161 * Samuel Chessman <chessman@tux.org> New Maintainer! 161 * Samuel Chessman <chessman@tux.org> New Maintainer!
162 * 162 *
163 * v1.15 Apr 4, 2002 - Correct operation when aui=1 to be 163 * v1.15 Apr 4, 2002 - Correct operation when aui=1 to be
164 * 10T half duplex no loopback 164 * 10T half duplex no loopback
165 * Thanks to Gunnar Eikman 165 * Thanks to Gunnar Eikman
166 * 166 *
167 * Sakari Ailus <sakari.ailus@iki.fi>: 167 * Sakari Ailus <sakari.ailus@iki.fi>:
168 * 168 *
169 * v1.15a Dec 15 2008 - Remove bbuf support, it doesn't work anyway. 169 * v1.15a Dec 15 2008 - Remove bbuf support, it doesn't work anyway.
170 * v1.16 Jan 6 2011 - Make checkpatch.pl happy.
170 * 171 *
171 *******************************************************************************/ 172 ******************************************************************************/
172 173
173#include <linux/module.h> 174#include <linux/module.h>
174#include <linux/init.h> 175#include <linux/init.h>
@@ -185,13 +186,11 @@
185 186
186#include "tlan.h" 187#include "tlan.h"
187 188
188typedef u32 (TLanIntVectorFunc)( struct net_device *, u16 );
189
190 189
191/* For removing EISA devices */ 190/* For removing EISA devices */
192static struct net_device *TLan_Eisa_Devices; 191static struct net_device *tlan_eisa_devices;
193 192
194static int TLanDevicesInstalled; 193static int tlan_devices_installed;
195 194
196/* Set speed, duplex and aui settings */ 195/* Set speed, duplex and aui settings */
197static int aui[MAX_TLAN_BOARDS]; 196static int aui[MAX_TLAN_BOARDS];
@@ -202,7 +201,8 @@ module_param_array(aui, int, NULL, 0);
202module_param_array(duplex, int, NULL, 0); 201module_param_array(duplex, int, NULL, 0);
203module_param_array(speed, int, NULL, 0); 202module_param_array(speed, int, NULL, 0);
204MODULE_PARM_DESC(aui, "ThunderLAN use AUI port(s) (0-1)"); 203MODULE_PARM_DESC(aui, "ThunderLAN use AUI port(s) (0-1)");
205MODULE_PARM_DESC(duplex, "ThunderLAN duplex setting(s) (0-default, 1-half, 2-full)"); 204MODULE_PARM_DESC(duplex,
205 "ThunderLAN duplex setting(s) (0-default, 1-half, 2-full)");
206MODULE_PARM_DESC(speed, "ThunderLAN port speen setting(s) (0,10,100)"); 206MODULE_PARM_DESC(speed, "ThunderLAN port speen setting(s) (0,10,100)");
207 207
208MODULE_AUTHOR("Maintainer: Samuel Chessman <chessman@tux.org>"); 208MODULE_AUTHOR("Maintainer: Samuel Chessman <chessman@tux.org>");
@@ -218,139 +218,144 @@ static int debug;
218module_param(debug, int, 0); 218module_param(debug, int, 0);
219MODULE_PARM_DESC(debug, "ThunderLAN debug mask"); 219MODULE_PARM_DESC(debug, "ThunderLAN debug mask");
220 220
221static const char TLanSignature[] = "TLAN"; 221static const char tlan_signature[] = "TLAN";
222static const char tlan_banner[] = "ThunderLAN driver v1.15a\n"; 222static const char tlan_banner[] = "ThunderLAN driver v1.16\n";
223static int tlan_have_pci; 223static int tlan_have_pci;
224static int tlan_have_eisa; 224static int tlan_have_eisa;
225 225
226static const char *media[] = { 226static const char * const media[] = {
227 "10BaseT-HD ", "10BaseT-FD ","100baseTx-HD ", 227 "10BaseT-HD", "10BaseT-FD", "100baseTx-HD",
228 "100baseTx-FD", "100baseT4", NULL 228 "100BaseTx-FD", "100BaseT4", NULL
229}; 229};
230 230
231static struct board { 231static struct board {
232 const char *deviceLabel; 232 const char *device_label;
233 u32 flags; 233 u32 flags;
234 u16 addrOfs; 234 u16 addr_ofs;
235} board_info[] = { 235} board_info[] = {
236 { "Compaq Netelligent 10 T PCI UTP", TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, 236 { "Compaq Netelligent 10 T PCI UTP", TLAN_ADAPTER_ACTIVITY_LED, 0x83 },
237 { "Compaq Netelligent 10/100 TX PCI UTP", TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, 237 { "Compaq Netelligent 10/100 TX PCI UTP",
238 TLAN_ADAPTER_ACTIVITY_LED, 0x83 },
238 { "Compaq Integrated NetFlex-3/P", TLAN_ADAPTER_NONE, 0x83 }, 239 { "Compaq Integrated NetFlex-3/P", TLAN_ADAPTER_NONE, 0x83 },
239 { "Compaq NetFlex-3/P", 240 { "Compaq NetFlex-3/P",
240 TLAN_ADAPTER_UNMANAGED_PHY | TLAN_ADAPTER_BIT_RATE_PHY, 0x83 }, 241 TLAN_ADAPTER_UNMANAGED_PHY | TLAN_ADAPTER_BIT_RATE_PHY, 0x83 },
241 { "Compaq NetFlex-3/P", TLAN_ADAPTER_NONE, 0x83 }, 242 { "Compaq NetFlex-3/P", TLAN_ADAPTER_NONE, 0x83 },
242 { "Compaq Netelligent Integrated 10/100 TX UTP", 243 { "Compaq Netelligent Integrated 10/100 TX UTP",
243 TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, 244 TLAN_ADAPTER_ACTIVITY_LED, 0x83 },
244 { "Compaq Netelligent Dual 10/100 TX PCI UTP", TLAN_ADAPTER_NONE, 0x83 }, 245 { "Compaq Netelligent Dual 10/100 TX PCI UTP",
245 { "Compaq Netelligent 10/100 TX Embedded UTP", TLAN_ADAPTER_NONE, 0x83 }, 246 TLAN_ADAPTER_NONE, 0x83 },
247 { "Compaq Netelligent 10/100 TX Embedded UTP",
248 TLAN_ADAPTER_NONE, 0x83 },
246 { "Olicom OC-2183/2185", TLAN_ADAPTER_USE_INTERN_10, 0x83 }, 249 { "Olicom OC-2183/2185", TLAN_ADAPTER_USE_INTERN_10, 0x83 },
247 { "Olicom OC-2325", TLAN_ADAPTER_UNMANAGED_PHY, 0xF8 }, 250 { "Olicom OC-2325", TLAN_ADAPTER_UNMANAGED_PHY, 0xf8 },
248 { "Olicom OC-2326", TLAN_ADAPTER_USE_INTERN_10, 0xF8 }, 251 { "Olicom OC-2326", TLAN_ADAPTER_USE_INTERN_10, 0xf8 },
249 { "Compaq Netelligent 10/100 TX UTP", TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, 252 { "Compaq Netelligent 10/100 TX UTP", TLAN_ADAPTER_ACTIVITY_LED, 0x83 },
250 { "Compaq Netelligent 10 T/2 PCI UTP/Coax", TLAN_ADAPTER_NONE, 0x83 }, 253 { "Compaq Netelligent 10 T/2 PCI UTP/coax", TLAN_ADAPTER_NONE, 0x83 },
251 { "Compaq NetFlex-3/E", 254 { "Compaq NetFlex-3/E",
252 TLAN_ADAPTER_ACTIVITY_LED | /* EISA card */ 255 TLAN_ADAPTER_ACTIVITY_LED | /* EISA card */
253 TLAN_ADAPTER_UNMANAGED_PHY | TLAN_ADAPTER_BIT_RATE_PHY, 0x83 }, 256 TLAN_ADAPTER_UNMANAGED_PHY | TLAN_ADAPTER_BIT_RATE_PHY, 0x83 },
254 { "Compaq NetFlex-3/E", TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, /* EISA card */ 257 { "Compaq NetFlex-3/E",
258 TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, /* EISA card */
255}; 259};
256 260
257static DEFINE_PCI_DEVICE_TABLE(tlan_pci_tbl) = { 261static DEFINE_PCI_DEVICE_TABLE(tlan_pci_tbl) = {
258 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL10, 262 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL10,
259 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 263 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
260 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100, 264 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100,
261 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, 265 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
262 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETFLEX3I, 266 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETFLEX3I,
263 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 }, 267 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 },
264 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_THUNDER, 268 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_THUNDER,
265 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 }, 269 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 3 },
266 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETFLEX3B, 270 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETFLEX3B,
267 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 }, 271 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 4 },
268 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100PI, 272 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100PI,
269 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5 }, 273 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 5 },
270 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100D, 274 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100D,
271 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6 }, 275 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 6 },
272 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100I, 276 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100I,
273 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7 }, 277 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 7 },
274 { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2183, 278 { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2183,
275 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8 }, 279 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 8 },
276 { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2325, 280 { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2325,
277 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9 }, 281 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 9 },
278 { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2326, 282 { PCI_VENDOR_ID_OLICOM, PCI_DEVICE_ID_OLICOM_OC2326,
279 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10 }, 283 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 10 },
280 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_NETELLIGENT_10_100_WS_5100, 284 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_NETELLIGENT_10_100_WS_5100,
281 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11 }, 285 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 11 },
282 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_NETELLIGENT_10_T2, 286 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_NETELLIGENT_10_T2,
283 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12 }, 287 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 12 },
284 { 0,} 288 { 0,}
285}; 289};
286MODULE_DEVICE_TABLE(pci, tlan_pci_tbl); 290MODULE_DEVICE_TABLE(pci, tlan_pci_tbl);
287 291
288static void TLan_EisaProbe( void ); 292static void tlan_eisa_probe(void);
289static void TLan_Eisa_Cleanup( void ); 293static void tlan_eisa_cleanup(void);
290static int TLan_Init( struct net_device * ); 294static int tlan_init(struct net_device *);
291static int TLan_Open( struct net_device *dev ); 295static int tlan_open(struct net_device *dev);
292static netdev_tx_t TLan_StartTx( struct sk_buff *, struct net_device *); 296static netdev_tx_t tlan_start_tx(struct sk_buff *, struct net_device *);
293static irqreturn_t TLan_HandleInterrupt( int, void *); 297static irqreturn_t tlan_handle_interrupt(int, void *);
294static int TLan_Close( struct net_device *); 298static int tlan_close(struct net_device *);
295static struct net_device_stats *TLan_GetStats( struct net_device *); 299static struct net_device_stats *tlan_get_stats(struct net_device *);
296static void TLan_SetMulticastList( struct net_device *); 300static void tlan_set_multicast_list(struct net_device *);
297static int TLan_ioctl( struct net_device *dev, struct ifreq *rq, int cmd); 301static int tlan_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
298static int TLan_probe1( struct pci_dev *pdev, long ioaddr, 302static int tlan_probe1(struct pci_dev *pdev, long ioaddr,
299 int irq, int rev, const struct pci_device_id *ent); 303 int irq, int rev, const struct pci_device_id *ent);
300static void TLan_tx_timeout( struct net_device *dev); 304static void tlan_tx_timeout(struct net_device *dev);
301static void TLan_tx_timeout_work(struct work_struct *work); 305static void tlan_tx_timeout_work(struct work_struct *work);
302static int tlan_init_one( struct pci_dev *pdev, const struct pci_device_id *ent); 306static int tlan_init_one(struct pci_dev *pdev,
303 307 const struct pci_device_id *ent);
304static u32 TLan_HandleTxEOF( struct net_device *, u16 ); 308
305static u32 TLan_HandleStatOverflow( struct net_device *, u16 ); 309static u32 tlan_handle_tx_eof(struct net_device *, u16);
306static u32 TLan_HandleRxEOF( struct net_device *, u16 ); 310static u32 tlan_handle_stat_overflow(struct net_device *, u16);
307static u32 TLan_HandleDummy( struct net_device *, u16 ); 311static u32 tlan_handle_rx_eof(struct net_device *, u16);
308static u32 TLan_HandleTxEOC( struct net_device *, u16 ); 312static u32 tlan_handle_dummy(struct net_device *, u16);
309static u32 TLan_HandleStatusCheck( struct net_device *, u16 ); 313static u32 tlan_handle_tx_eoc(struct net_device *, u16);
310static u32 TLan_HandleRxEOC( struct net_device *, u16 ); 314static u32 tlan_handle_status_check(struct net_device *, u16);
311 315static u32 tlan_handle_rx_eoc(struct net_device *, u16);
312static void TLan_Timer( unsigned long ); 316
313 317static void tlan_timer(unsigned long);
314static void TLan_ResetLists( struct net_device * ); 318
315static void TLan_FreeLists( struct net_device * ); 319static void tlan_reset_lists(struct net_device *);
316static void TLan_PrintDio( u16 ); 320static void tlan_free_lists(struct net_device *);
317static void TLan_PrintList( TLanList *, char *, int ); 321static void tlan_print_dio(u16);
318static void TLan_ReadAndClearStats( struct net_device *, int ); 322static void tlan_print_list(struct tlan_list *, char *, int);
319static void TLan_ResetAdapter( struct net_device * ); 323static void tlan_read_and_clear_stats(struct net_device *, int);
320static void TLan_FinishReset( struct net_device * ); 324static void tlan_reset_adapter(struct net_device *);
321static void TLan_SetMac( struct net_device *, int areg, char *mac ); 325static void tlan_finish_reset(struct net_device *);
322 326static void tlan_set_mac(struct net_device *, int areg, char *mac);
323static void TLan_PhyPrint( struct net_device * ); 327
324static void TLan_PhyDetect( struct net_device * ); 328static void tlan_phy_print(struct net_device *);
325static void TLan_PhyPowerDown( struct net_device * ); 329static void tlan_phy_detect(struct net_device *);
326static void TLan_PhyPowerUp( struct net_device * ); 330static void tlan_phy_power_down(struct net_device *);
327static void TLan_PhyReset( struct net_device * ); 331static void tlan_phy_power_up(struct net_device *);
328static void TLan_PhyStartLink( struct net_device * ); 332static void tlan_phy_reset(struct net_device *);
329static void TLan_PhyFinishAutoNeg( struct net_device * ); 333static void tlan_phy_start_link(struct net_device *);
334static void tlan_phy_finish_auto_neg(struct net_device *);
330#ifdef MONITOR 335#ifdef MONITOR
331static void TLan_PhyMonitor( struct net_device * ); 336static void tlan_phy_monitor(struct net_device *);
332#endif 337#endif
333 338
334/* 339/*
335static int TLan_PhyNop( struct net_device * ); 340 static int tlan_phy_nop(struct net_device *);
336static int TLan_PhyInternalCheck( struct net_device * ); 341 static int tlan_phy_internal_check(struct net_device *);
337static int TLan_PhyInternalService( struct net_device * ); 342 static int tlan_phy_internal_service(struct net_device *);
338static int TLan_PhyDp83840aCheck( struct net_device * ); 343 static int tlan_phy_dp83840a_check(struct net_device *);
339*/ 344*/
340 345
341static bool TLan_MiiReadReg( struct net_device *, u16, u16, u16 * ); 346static bool tlan_mii_read_reg(struct net_device *, u16, u16, u16 *);
342static void TLan_MiiSendData( u16, u32, unsigned ); 347static void tlan_mii_send_data(u16, u32, unsigned);
343static void TLan_MiiSync( u16 ); 348static void tlan_mii_sync(u16);
344static void TLan_MiiWriteReg( struct net_device *, u16, u16, u16 ); 349static void tlan_mii_write_reg(struct net_device *, u16, u16, u16);
345 350
346static void TLan_EeSendStart( u16 ); 351static void tlan_ee_send_start(u16);
347static int TLan_EeSendByte( u16, u8, int ); 352static int tlan_ee_send_byte(u16, u8, int);
348static void TLan_EeReceiveByte( u16, u8 *, int ); 353static void tlan_ee_receive_byte(u16, u8 *, int);
349static int TLan_EeReadByte( struct net_device *, u8, u8 * ); 354static int tlan_ee_read_byte(struct net_device *, u8, u8 *);
350 355
351 356
352static inline void 357static inline void
353TLan_StoreSKB( struct tlan_list_tag *tag, struct sk_buff *skb) 358tlan_store_skb(struct tlan_list *tag, struct sk_buff *skb)
354{ 359{
355 unsigned long addr = (unsigned long)skb; 360 unsigned long addr = (unsigned long)skb;
356 tag->buffer[9].address = addr; 361 tag->buffer[9].address = addr;
@@ -358,7 +363,7 @@ TLan_StoreSKB( struct tlan_list_tag *tag, struct sk_buff *skb)
358} 363}
359 364
360static inline struct sk_buff * 365static inline struct sk_buff *
361TLan_GetSKB( const struct tlan_list_tag *tag) 366tlan_get_skb(const struct tlan_list *tag)
362{ 367{
363 unsigned long addr; 368 unsigned long addr;
364 369
@@ -367,50 +372,50 @@ TLan_GetSKB( const struct tlan_list_tag *tag)
367 return (struct sk_buff *) addr; 372 return (struct sk_buff *) addr;
368} 373}
369 374
370 375static u32
371static TLanIntVectorFunc *TLanIntVector[TLAN_INT_NUMBER_OF_INTS] = { 376(*tlan_int_vector[TLAN_INT_NUMBER_OF_INTS])(struct net_device *, u16) = {
372 NULL, 377 NULL,
373 TLan_HandleTxEOF, 378 tlan_handle_tx_eof,
374 TLan_HandleStatOverflow, 379 tlan_handle_stat_overflow,
375 TLan_HandleRxEOF, 380 tlan_handle_rx_eof,
376 TLan_HandleDummy, 381 tlan_handle_dummy,
377 TLan_HandleTxEOC, 382 tlan_handle_tx_eoc,
378 TLan_HandleStatusCheck, 383 tlan_handle_status_check,
379 TLan_HandleRxEOC 384 tlan_handle_rx_eoc
380}; 385};
381 386
382static inline void 387static inline void
383TLan_SetTimer( struct net_device *dev, u32 ticks, u32 type ) 388tlan_set_timer(struct net_device *dev, u32 ticks, u32 type)
384{ 389{
385 TLanPrivateInfo *priv = netdev_priv(dev); 390 struct tlan_priv *priv = netdev_priv(dev);
386 unsigned long flags = 0; 391 unsigned long flags = 0;
387 392
388 if (!in_irq()) 393 if (!in_irq())
389 spin_lock_irqsave(&priv->lock, flags); 394 spin_lock_irqsave(&priv->lock, flags);
390 if ( priv->timer.function != NULL && 395 if (priv->timer.function != NULL &&
391 priv->timerType != TLAN_TIMER_ACTIVITY ) { 396 priv->timer_type != TLAN_TIMER_ACTIVITY) {
392 if (!in_irq()) 397 if (!in_irq())
393 spin_unlock_irqrestore(&priv->lock, flags); 398 spin_unlock_irqrestore(&priv->lock, flags);
394 return; 399 return;
395 } 400 }
396 priv->timer.function = TLan_Timer; 401 priv->timer.function = tlan_timer;
397 if (!in_irq()) 402 if (!in_irq())
398 spin_unlock_irqrestore(&priv->lock, flags); 403 spin_unlock_irqrestore(&priv->lock, flags);
399 404
400 priv->timer.data = (unsigned long) dev; 405 priv->timer.data = (unsigned long) dev;
401 priv->timerSetAt = jiffies; 406 priv->timer_set_at = jiffies;
402 priv->timerType = type; 407 priv->timer_type = type;
403 mod_timer(&priv->timer, jiffies + ticks); 408 mod_timer(&priv->timer, jiffies + ticks);
404 409
405} /* TLan_SetTimer */ 410}
406 411
407 412
408/***************************************************************************** 413/*****************************************************************************
409****************************************************************************** 414******************************************************************************
410 415
411 ThunderLAN Driver Primary Functions 416ThunderLAN driver primary functions
412 417
413 These functions are more or less common to all Linux network drivers. 418these functions are more or less common to all linux network drivers.
414 419
415****************************************************************************** 420******************************************************************************
416*****************************************************************************/ 421*****************************************************************************/
@@ -419,42 +424,42 @@ TLan_SetTimer( struct net_device *dev, u32 ticks, u32 type )
419 424
420 425
421 426
422 /*************************************************************** 427/***************************************************************
423 * tlan_remove_one 428 * tlan_remove_one
424 * 429 *
425 * Returns: 430 * Returns:
426 * Nothing 431 * Nothing
427 * Parms: 432 * Parms:
428 * None 433 * None
429 * 434 *
430 * Goes through the TLanDevices list and frees the device 435 * Goes through the TLanDevices list and frees the device
431 * structs and memory associated with each device (lists 436 * structs and memory associated with each device (lists
432 * and buffers). It also ureserves the IO port regions 437 * and buffers). It also ureserves the IO port regions
433 * associated with this device. 438 * associated with this device.
434 * 439 *
435 **************************************************************/ 440 **************************************************************/
436 441
437 442
438static void __devexit tlan_remove_one( struct pci_dev *pdev) 443static void __devexit tlan_remove_one(struct pci_dev *pdev)
439{ 444{
440 struct net_device *dev = pci_get_drvdata( pdev ); 445 struct net_device *dev = pci_get_drvdata(pdev);
441 TLanPrivateInfo *priv = netdev_priv(dev); 446 struct tlan_priv *priv = netdev_priv(dev);
442 447
443 unregister_netdev( dev ); 448 unregister_netdev(dev);
444 449
445 if ( priv->dmaStorage ) { 450 if (priv->dma_storage) {
446 pci_free_consistent(priv->pciDev, 451 pci_free_consistent(priv->pci_dev,
447 priv->dmaSize, priv->dmaStorage, 452 priv->dma_size, priv->dma_storage,
448 priv->dmaStorageDMA ); 453 priv->dma_storage_dma);
449 } 454 }
450 455
451#ifdef CONFIG_PCI 456#ifdef CONFIG_PCI
452 pci_release_regions(pdev); 457 pci_release_regions(pdev);
453#endif 458#endif
454 459
455 free_netdev( dev ); 460 free_netdev(dev);
456 461
457 pci_set_drvdata( pdev, NULL ); 462 pci_set_drvdata(pdev, NULL);
458} 463}
459 464
460static struct pci_driver tlan_driver = { 465static struct pci_driver tlan_driver = {
@@ -482,13 +487,13 @@ static int __init tlan_probe(void)
482 } 487 }
483 488
484 TLAN_DBG(TLAN_DEBUG_PROBE, "Starting EISA Probe....\n"); 489 TLAN_DBG(TLAN_DEBUG_PROBE, "Starting EISA Probe....\n");
485 TLan_EisaProbe(); 490 tlan_eisa_probe();
486 491
487 printk(KERN_INFO "TLAN: %d device%s installed, PCI: %d EISA: %d\n", 492 printk(KERN_INFO "TLAN: %d device%s installed, PCI: %d EISA: %d\n",
488 TLanDevicesInstalled, TLanDevicesInstalled == 1 ? "" : "s", 493 tlan_devices_installed, tlan_devices_installed == 1 ? "" : "s",
489 tlan_have_pci, tlan_have_eisa); 494 tlan_have_pci, tlan_have_eisa);
490 495
491 if (TLanDevicesInstalled == 0) { 496 if (tlan_devices_installed == 0) {
492 rc = -ENODEV; 497 rc = -ENODEV;
493 goto err_out_pci_unreg; 498 goto err_out_pci_unreg;
494 } 499 }
@@ -501,39 +506,39 @@ err_out_pci_free:
501} 506}
502 507
503 508
504static int __devinit tlan_init_one( struct pci_dev *pdev, 509static int __devinit tlan_init_one(struct pci_dev *pdev,
505 const struct pci_device_id *ent) 510 const struct pci_device_id *ent)
506{ 511{
507 return TLan_probe1( pdev, -1, -1, 0, ent); 512 return tlan_probe1(pdev, -1, -1, 0, ent);
508} 513}
509 514
510 515
511/* 516/*
512 *************************************************************** 517***************************************************************
513 * tlan_probe1 518* tlan_probe1
514 * 519*
515 * Returns: 520* Returns:
516 * 0 on success, error code on error 521* 0 on success, error code on error
517 * Parms: 522* Parms:
518 * none 523* none
519 * 524*
520 * The name is lower case to fit in with all the rest of 525* The name is lower case to fit in with all the rest of
521 * the netcard_probe names. This function looks for 526* the netcard_probe names. This function looks for
522 * another TLan based adapter, setting it up with the 527* another TLan based adapter, setting it up with the
523 * allocated device struct if one is found. 528* allocated device struct if one is found.
524 * tlan_probe has been ported to the new net API and 529* tlan_probe has been ported to the new net API and
525 * now allocates its own device structure. This function 530* now allocates its own device structure. This function
526 * is also used by modules. 531* is also used by modules.
527 * 532*
528 **************************************************************/ 533**************************************************************/
529 534
530static int __devinit TLan_probe1(struct pci_dev *pdev, 535static int __devinit tlan_probe1(struct pci_dev *pdev,
531 long ioaddr, int irq, int rev, 536 long ioaddr, int irq, int rev,
532 const struct pci_device_id *ent ) 537 const struct pci_device_id *ent)
533{ 538{
534 539
535 struct net_device *dev; 540 struct net_device *dev;
536 TLanPrivateInfo *priv; 541 struct tlan_priv *priv;
537 u16 device_id; 542 u16 device_id;
538 int reg, rc = -ENODEV; 543 int reg, rc = -ENODEV;
539 544
@@ -543,7 +548,7 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
543 if (rc) 548 if (rc)
544 return rc; 549 return rc;
545 550
546 rc = pci_request_regions(pdev, TLanSignature); 551 rc = pci_request_regions(pdev, tlan_signature);
547 if (rc) { 552 if (rc) {
548 printk(KERN_ERR "TLAN: Could not reserve IO regions\n"); 553 printk(KERN_ERR "TLAN: Could not reserve IO regions\n");
549 goto err_out; 554 goto err_out;
@@ -551,7 +556,7 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
551 } 556 }
552#endif /* CONFIG_PCI */ 557#endif /* CONFIG_PCI */
553 558
554 dev = alloc_etherdev(sizeof(TLanPrivateInfo)); 559 dev = alloc_etherdev(sizeof(struct tlan_priv));
555 if (dev == NULL) { 560 if (dev == NULL) {
556 printk(KERN_ERR "TLAN: Could not allocate memory for device.\n"); 561 printk(KERN_ERR "TLAN: Could not allocate memory for device.\n");
557 rc = -ENOMEM; 562 rc = -ENOMEM;
@@ -561,26 +566,28 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
561 566
562 priv = netdev_priv(dev); 567 priv = netdev_priv(dev);
563 568
564 priv->pciDev = pdev; 569 priv->pci_dev = pdev;
565 priv->dev = dev; 570 priv->dev = dev;
566 571
567 /* Is this a PCI device? */ 572 /* Is this a PCI device? */
568 if (pdev) { 573 if (pdev) {
569 u32 pci_io_base = 0; 574 u32 pci_io_base = 0;
570 575
571 priv->adapter = &board_info[ent->driver_data]; 576 priv->adapter = &board_info[ent->driver_data];
572 577
573 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 578 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
574 if (rc) { 579 if (rc) {
575 printk(KERN_ERR "TLAN: No suitable PCI mapping available.\n"); 580 printk(KERN_ERR
581 "TLAN: No suitable PCI mapping available.\n");
576 goto err_out_free_dev; 582 goto err_out_free_dev;
577 } 583 }
578 584
579 for ( reg= 0; reg <= 5; reg ++ ) { 585 for (reg = 0; reg <= 5; reg++) {
580 if (pci_resource_flags(pdev, reg) & IORESOURCE_IO) { 586 if (pci_resource_flags(pdev, reg) & IORESOURCE_IO) {
581 pci_io_base = pci_resource_start(pdev, reg); 587 pci_io_base = pci_resource_start(pdev, reg);
582 TLAN_DBG( TLAN_DEBUG_GNRL, "IO mapping is available at %x.\n", 588 TLAN_DBG(TLAN_DEBUG_GNRL,
583 pci_io_base); 589 "IO mapping is available at %x.\n",
590 pci_io_base);
584 break; 591 break;
585 } 592 }
586 } 593 }
@@ -592,7 +599,7 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
592 599
593 dev->base_addr = pci_io_base; 600 dev->base_addr = pci_io_base;
594 dev->irq = pdev->irq; 601 dev->irq = pdev->irq;
595 priv->adapterRev = pdev->revision; 602 priv->adapter_rev = pdev->revision;
596 pci_set_master(pdev); 603 pci_set_master(pdev);
597 pci_set_drvdata(pdev, dev); 604 pci_set_drvdata(pdev, dev);
598 605
@@ -602,11 +609,11 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
602 device_id = inw(ioaddr + EISA_ID2); 609 device_id = inw(ioaddr + EISA_ID2);
603 priv->is_eisa = 1; 610 priv->is_eisa = 1;
604 if (device_id == 0x20F1) { 611 if (device_id == 0x20F1) {
605 priv->adapter = &board_info[13]; /* NetFlex-3/E */ 612 priv->adapter = &board_info[13]; /* NetFlex-3/E */
606 priv->adapterRev = 23; /* TLAN 2.3 */ 613 priv->adapter_rev = 23; /* TLAN 2.3 */
607 } else { 614 } else {
608 priv->adapter = &board_info[14]; 615 priv->adapter = &board_info[14];
609 priv->adapterRev = 10; /* TLAN 1.0 */ 616 priv->adapter_rev = 10; /* TLAN 1.0 */
610 } 617 }
611 dev->base_addr = ioaddr; 618 dev->base_addr = ioaddr;
612 dev->irq = irq; 619 dev->irq = irq;
@@ -620,11 +627,11 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
620 priv->speed = ((dev->mem_start & 0x18) == 0x18) ? 0 627 priv->speed = ((dev->mem_start & 0x18) == 0x18) ? 0
621 : (dev->mem_start & 0x18) >> 3; 628 : (dev->mem_start & 0x18) >> 3;
622 629
623 if (priv->speed == 0x1) { 630 if (priv->speed == 0x1)
624 priv->speed = TLAN_SPEED_10; 631 priv->speed = TLAN_SPEED_10;
625 } else if (priv->speed == 0x2) { 632 else if (priv->speed == 0x2)
626 priv->speed = TLAN_SPEED_100; 633 priv->speed = TLAN_SPEED_100;
627 } 634
628 debug = priv->debug = dev->mem_end; 635 debug = priv->debug = dev->mem_end;
629 } else { 636 } else {
630 priv->aui = aui[boards_found]; 637 priv->aui = aui[boards_found];
@@ -635,11 +642,11 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
635 642
636 /* This will be used when we get an adapter error from 643 /* This will be used when we get an adapter error from
637 * within our irq handler */ 644 * within our irq handler */
638 INIT_WORK(&priv->tlan_tqueue, TLan_tx_timeout_work); 645 INIT_WORK(&priv->tlan_tqueue, tlan_tx_timeout_work);
639 646
640 spin_lock_init(&priv->lock); 647 spin_lock_init(&priv->lock);
641 648
642 rc = TLan_Init(dev); 649 rc = tlan_init(dev);
643 if (rc) { 650 if (rc) {
644 printk(KERN_ERR "TLAN: Could not set up device.\n"); 651 printk(KERN_ERR "TLAN: Could not set up device.\n");
645 goto err_out_free_dev; 652 goto err_out_free_dev;
@@ -652,29 +659,29 @@ static int __devinit TLan_probe1(struct pci_dev *pdev,
652 } 659 }
653 660
654 661
655 TLanDevicesInstalled++; 662 tlan_devices_installed++;
656 boards_found++; 663 boards_found++;
657 664
658 /* pdev is NULL if this is an EISA device */ 665 /* pdev is NULL if this is an EISA device */
659 if (pdev) 666 if (pdev)
660 tlan_have_pci++; 667 tlan_have_pci++;
661 else { 668 else {
662 priv->nextDevice = TLan_Eisa_Devices; 669 priv->next_device = tlan_eisa_devices;
663 TLan_Eisa_Devices = dev; 670 tlan_eisa_devices = dev;
664 tlan_have_eisa++; 671 tlan_have_eisa++;
665 } 672 }
666 673
667 printk(KERN_INFO "TLAN: %s irq=%2d, io=%04x, %s, Rev. %d\n", 674 printk(KERN_INFO "TLAN: %s irq=%2d, io=%04x, %s, Rev. %d\n",
668 dev->name, 675 dev->name,
669 (int) dev->irq, 676 (int) dev->irq,
670 (int) dev->base_addr, 677 (int) dev->base_addr,
671 priv->adapter->deviceLabel, 678 priv->adapter->device_label,
672 priv->adapterRev); 679 priv->adapter_rev);
673 return 0; 680 return 0;
674 681
675err_out_uninit: 682err_out_uninit:
676 pci_free_consistent(priv->pciDev, priv->dmaSize, priv->dmaStorage, 683 pci_free_consistent(priv->pci_dev, priv->dma_size, priv->dma_storage,
677 priv->dmaStorageDMA ); 684 priv->dma_storage_dma);
678err_out_free_dev: 685err_out_free_dev:
679 free_netdev(dev); 686 free_netdev(dev);
680err_out_regions: 687err_out_regions:
@@ -689,22 +696,23 @@ err_out:
689} 696}
690 697
691 698
692static void TLan_Eisa_Cleanup(void) 699static void tlan_eisa_cleanup(void)
693{ 700{
694 struct net_device *dev; 701 struct net_device *dev;
695 TLanPrivateInfo *priv; 702 struct tlan_priv *priv;
696 703
697 while( tlan_have_eisa ) { 704 while (tlan_have_eisa) {
698 dev = TLan_Eisa_Devices; 705 dev = tlan_eisa_devices;
699 priv = netdev_priv(dev); 706 priv = netdev_priv(dev);
700 if (priv->dmaStorage) { 707 if (priv->dma_storage) {
701 pci_free_consistent(priv->pciDev, priv->dmaSize, 708 pci_free_consistent(priv->pci_dev, priv->dma_size,
702 priv->dmaStorage, priv->dmaStorageDMA ); 709 priv->dma_storage,
710 priv->dma_storage_dma);
703 } 711 }
704 release_region( dev->base_addr, 0x10); 712 release_region(dev->base_addr, 0x10);
705 unregister_netdev( dev ); 713 unregister_netdev(dev);
706 TLan_Eisa_Devices = priv->nextDevice; 714 tlan_eisa_devices = priv->next_device;
707 free_netdev( dev ); 715 free_netdev(dev);
708 tlan_have_eisa--; 716 tlan_have_eisa--;
709 } 717 }
710} 718}
@@ -715,7 +723,7 @@ static void __exit tlan_exit(void)
715 pci_unregister_driver(&tlan_driver); 723 pci_unregister_driver(&tlan_driver);
716 724
717 if (tlan_have_eisa) 725 if (tlan_have_eisa)
718 TLan_Eisa_Cleanup(); 726 tlan_eisa_cleanup();
719 727
720} 728}
721 729
@@ -726,24 +734,24 @@ module_exit(tlan_exit);
726 734
727 735
728 736
729 /************************************************************** 737/**************************************************************
730 * TLan_EisaProbe 738 * tlan_eisa_probe
731 * 739 *
732 * Returns: 0 on success, 1 otherwise 740 * Returns: 0 on success, 1 otherwise
733 * 741 *
734 * Parms: None 742 * Parms: None
735 * 743 *
736 * 744 *
737 * This functions probes for EISA devices and calls 745 * This functions probes for EISA devices and calls
738 * TLan_probe1 when one is found. 746 * TLan_probe1 when one is found.
739 * 747 *
740 *************************************************************/ 748 *************************************************************/
741 749
742static void __init TLan_EisaProbe (void) 750static void __init tlan_eisa_probe(void)
743{ 751{
744 long ioaddr; 752 long ioaddr;
745 int rc = -ENODEV; 753 int rc = -ENODEV;
746 int irq; 754 int irq;
747 u16 device_id; 755 u16 device_id;
748 756
749 if (!EISA_bus) { 757 if (!EISA_bus) {
@@ -754,15 +762,16 @@ static void __init TLan_EisaProbe (void)
754 /* Loop through all slots of the EISA bus */ 762 /* Loop through all slots of the EISA bus */
755 for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000) { 763 for (ioaddr = 0x1000; ioaddr < 0x9000; ioaddr += 0x1000) {
756 764
757 TLAN_DBG(TLAN_DEBUG_PROBE,"EISA_ID 0x%4x: 0x%4x\n", 765 TLAN_DBG(TLAN_DEBUG_PROBE, "EISA_ID 0x%4x: 0x%4x\n",
758 (int) ioaddr + 0xC80, inw(ioaddr + EISA_ID)); 766 (int) ioaddr + 0xc80, inw(ioaddr + EISA_ID));
759 TLAN_DBG(TLAN_DEBUG_PROBE,"EISA_ID 0x%4x: 0x%4x\n", 767 TLAN_DBG(TLAN_DEBUG_PROBE, "EISA_ID 0x%4x: 0x%4x\n",
760 (int) ioaddr + 0xC82, inw(ioaddr + EISA_ID2)); 768 (int) ioaddr + 0xc82, inw(ioaddr + EISA_ID2));
761 769
762 770
763 TLAN_DBG(TLAN_DEBUG_PROBE, "Probing for EISA adapter at IO: 0x%4x : ", 771 TLAN_DBG(TLAN_DEBUG_PROBE,
764 (int) ioaddr); 772 "Probing for EISA adapter at IO: 0x%4x : ",
765 if (request_region(ioaddr, 0x10, TLanSignature) == NULL) 773 (int) ioaddr);
774 if (request_region(ioaddr, 0x10, tlan_signature) == NULL)
766 goto out; 775 goto out;
767 776
768 if (inw(ioaddr + EISA_ID) != 0x110E) { 777 if (inw(ioaddr + EISA_ID) != 0x110E) {
@@ -772,180 +781,186 @@ static void __init TLan_EisaProbe (void)
772 781
773 device_id = inw(ioaddr + EISA_ID2); 782 device_id = inw(ioaddr + EISA_ID2);
774 if (device_id != 0x20F1 && device_id != 0x40F1) { 783 if (device_id != 0x20F1 && device_id != 0x40F1) {
775 release_region (ioaddr, 0x10); 784 release_region(ioaddr, 0x10);
776 goto out; 785 goto out;
777 } 786 }
778 787
779 if (inb(ioaddr + EISA_CR) != 0x1) { /* Check if adapter is enabled */ 788 /* check if adapter is enabled */
780 release_region (ioaddr, 0x10); 789 if (inb(ioaddr + EISA_CR) != 0x1) {
790 release_region(ioaddr, 0x10);
781 goto out2; 791 goto out2;
782 } 792 }
783 793
784 if (debug == 0x10) 794 if (debug == 0x10)
785 printk("Found one\n"); 795 printk(KERN_INFO "Found one\n");
786 796
787 797
788 /* Get irq from board */ 798 /* Get irq from board */
789 switch (inb(ioaddr + 0xCC0)) { 799 switch (inb(ioaddr + 0xcc0)) {
790 case(0x10): 800 case(0x10):
791 irq=5; 801 irq = 5;
792 break; 802 break;
793 case(0x20): 803 case(0x20):
794 irq=9; 804 irq = 9;
795 break; 805 break;
796 case(0x40): 806 case(0x40):
797 irq=10; 807 irq = 10;
798 break; 808 break;
799 case(0x80): 809 case(0x80):
800 irq=11; 810 irq = 11;
801 break; 811 break;
802 default: 812 default:
803 goto out; 813 goto out;
804 } 814 }
805 815
806 816
807 /* Setup the newly found eisa adapter */ 817 /* Setup the newly found eisa adapter */
808 rc = TLan_probe1( NULL, ioaddr, irq, 818 rc = tlan_probe1(NULL, ioaddr, irq,
809 12, NULL); 819 12, NULL);
810 continue; 820 continue;
811 821
812 out: 822out:
813 if (debug == 0x10) 823 if (debug == 0x10)
814 printk("None found\n"); 824 printk(KERN_INFO "None found\n");
815 continue; 825 continue;
816 826
817 out2: if (debug == 0x10) 827out2:
818 printk("Card found but it is not enabled, skipping\n"); 828 if (debug == 0x10)
819 continue; 829 printk(KERN_INFO "Card found but it is not enabled, skipping\n");
830 continue;
820 831
821 } 832 }
822 833
823} /* TLan_EisaProbe */ 834}
824 835
825#ifdef CONFIG_NET_POLL_CONTROLLER 836#ifdef CONFIG_NET_POLL_CONTROLLER
826static void TLan_Poll(struct net_device *dev) 837static void tlan_poll(struct net_device *dev)
827{ 838{
828 disable_irq(dev->irq); 839 disable_irq(dev->irq);
829 TLan_HandleInterrupt(dev->irq, dev); 840 tlan_handle_interrupt(dev->irq, dev);
830 enable_irq(dev->irq); 841 enable_irq(dev->irq);
831} 842}
832#endif 843#endif
833 844
834static const struct net_device_ops TLan_netdev_ops = { 845static const struct net_device_ops tlan_netdev_ops = {
835 .ndo_open = TLan_Open, 846 .ndo_open = tlan_open,
836 .ndo_stop = TLan_Close, 847 .ndo_stop = tlan_close,
837 .ndo_start_xmit = TLan_StartTx, 848 .ndo_start_xmit = tlan_start_tx,
838 .ndo_tx_timeout = TLan_tx_timeout, 849 .ndo_tx_timeout = tlan_tx_timeout,
839 .ndo_get_stats = TLan_GetStats, 850 .ndo_get_stats = tlan_get_stats,
840 .ndo_set_multicast_list = TLan_SetMulticastList, 851 .ndo_set_multicast_list = tlan_set_multicast_list,
841 .ndo_do_ioctl = TLan_ioctl, 852 .ndo_do_ioctl = tlan_ioctl,
842 .ndo_change_mtu = eth_change_mtu, 853 .ndo_change_mtu = eth_change_mtu,
843 .ndo_set_mac_address = eth_mac_addr, 854 .ndo_set_mac_address = eth_mac_addr,
844 .ndo_validate_addr = eth_validate_addr, 855 .ndo_validate_addr = eth_validate_addr,
845#ifdef CONFIG_NET_POLL_CONTROLLER 856#ifdef CONFIG_NET_POLL_CONTROLLER
846 .ndo_poll_controller = TLan_Poll, 857 .ndo_poll_controller = tlan_poll,
847#endif 858#endif
848}; 859};
849 860
850 861
851 862
852 /*************************************************************** 863/***************************************************************
853 * TLan_Init 864 * tlan_init
854 * 865 *
855 * Returns: 866 * Returns:
856 * 0 on success, error code otherwise. 867 * 0 on success, error code otherwise.
857 * Parms: 868 * Parms:
858 * dev The structure of the device to be 869 * dev The structure of the device to be
859 * init'ed. 870 * init'ed.
860 * 871 *
861 * This function completes the initialization of the 872 * This function completes the initialization of the
862 * device structure and driver. It reserves the IO 873 * device structure and driver. It reserves the IO
863 * addresses, allocates memory for the lists and bounce 874 * addresses, allocates memory for the lists and bounce
864 * buffers, retrieves the MAC address from the eeprom 875 * buffers, retrieves the MAC address from the eeprom
865 * and assignes the device's methods. 876 * and assignes the device's methods.
866 * 877 *
867 **************************************************************/ 878 **************************************************************/
868 879
869static int TLan_Init( struct net_device *dev ) 880static int tlan_init(struct net_device *dev)
870{ 881{
871 int dma_size; 882 int dma_size;
872 int err; 883 int err;
873 int i; 884 int i;
874 TLanPrivateInfo *priv; 885 struct tlan_priv *priv;
875 886
876 priv = netdev_priv(dev); 887 priv = netdev_priv(dev);
877 888
878 dma_size = ( TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS ) 889 dma_size = (TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS)
879 * ( sizeof(TLanList) ); 890 * (sizeof(struct tlan_list));
880 priv->dmaStorage = pci_alloc_consistent(priv->pciDev, 891 priv->dma_storage = pci_alloc_consistent(priv->pci_dev,
881 dma_size, &priv->dmaStorageDMA); 892 dma_size,
882 priv->dmaSize = dma_size; 893 &priv->dma_storage_dma);
883 894 priv->dma_size = dma_size;
884 if ( priv->dmaStorage == NULL ) { 895
885 printk(KERN_ERR "TLAN: Could not allocate lists and buffers for %s.\n", 896 if (priv->dma_storage == NULL) {
886 dev->name ); 897 printk(KERN_ERR
898 "TLAN: Could not allocate lists and buffers for %s.\n",
899 dev->name);
887 return -ENOMEM; 900 return -ENOMEM;
888 } 901 }
889 memset( priv->dmaStorage, 0, dma_size ); 902 memset(priv->dma_storage, 0, dma_size);
890 priv->rxList = (TLanList *) ALIGN((unsigned long)priv->dmaStorage, 8); 903 priv->rx_list = (struct tlan_list *)
891 priv->rxListDMA = ALIGN(priv->dmaStorageDMA, 8); 904 ALIGN((unsigned long)priv->dma_storage, 8);
892 priv->txList = priv->rxList + TLAN_NUM_RX_LISTS; 905 priv->rx_list_dma = ALIGN(priv->dma_storage_dma, 8);
893 priv->txListDMA = priv->rxListDMA + sizeof(TLanList) * TLAN_NUM_RX_LISTS; 906 priv->tx_list = priv->rx_list + TLAN_NUM_RX_LISTS;
907 priv->tx_list_dma =
908 priv->rx_list_dma + sizeof(struct tlan_list)*TLAN_NUM_RX_LISTS;
894 909
895 err = 0; 910 err = 0;
896 for ( i = 0; i < 6 ; i++ ) 911 for (i = 0; i < 6 ; i++)
897 err |= TLan_EeReadByte( dev, 912 err |= tlan_ee_read_byte(dev,
898 (u8) priv->adapter->addrOfs + i, 913 (u8) priv->adapter->addr_ofs + i,
899 (u8 *) &dev->dev_addr[i] ); 914 (u8 *) &dev->dev_addr[i]);
900 if ( err ) { 915 if (err) {
901 printk(KERN_ERR "TLAN: %s: Error reading MAC from eeprom: %d\n", 916 printk(KERN_ERR "TLAN: %s: Error reading MAC from eeprom: %d\n",
902 dev->name, 917 dev->name,
903 err ); 918 err);
904 } 919 }
905 dev->addr_len = 6; 920 dev->addr_len = 6;
906 921
907 netif_carrier_off(dev); 922 netif_carrier_off(dev);
908 923
909 /* Device methods */ 924 /* Device methods */
910 dev->netdev_ops = &TLan_netdev_ops; 925 dev->netdev_ops = &tlan_netdev_ops;
911 dev->watchdog_timeo = TX_TIMEOUT; 926 dev->watchdog_timeo = TX_TIMEOUT;
912 927
913 return 0; 928 return 0;
914 929
915} /* TLan_Init */ 930}
916 931
917 932
918 933
919 934
920 /*************************************************************** 935/***************************************************************
921 * TLan_Open 936 * tlan_open
922 * 937 *
923 * Returns: 938 * Returns:
924 * 0 on success, error code otherwise. 939 * 0 on success, error code otherwise.
925 * Parms: 940 * Parms:
926 * dev Structure of device to be opened. 941 * dev Structure of device to be opened.
927 * 942 *
928 * This routine puts the driver and TLAN adapter in a 943 * This routine puts the driver and TLAN adapter in a
929 * state where it is ready to send and receive packets. 944 * state where it is ready to send and receive packets.
930 * It allocates the IRQ, resets and brings the adapter 945 * It allocates the IRQ, resets and brings the adapter
931 * out of reset, and allows interrupts. It also delays 946 * out of reset, and allows interrupts. It also delays
932 * the startup for autonegotiation or sends a Rx GO 947 * the startup for autonegotiation or sends a Rx GO
933 * command to the adapter, as appropriate. 948 * command to the adapter, as appropriate.
934 * 949 *
935 **************************************************************/ 950 **************************************************************/
936 951
937static int TLan_Open( struct net_device *dev ) 952static int tlan_open(struct net_device *dev)
938{ 953{
939 TLanPrivateInfo *priv = netdev_priv(dev); 954 struct tlan_priv *priv = netdev_priv(dev);
940 int err; 955 int err;
941 956
942 priv->tlanRev = TLan_DioRead8( dev->base_addr, TLAN_DEF_REVISION ); 957 priv->tlan_rev = tlan_dio_read8(dev->base_addr, TLAN_DEF_REVISION);
943 err = request_irq( dev->irq, TLan_HandleInterrupt, IRQF_SHARED, 958 err = request_irq(dev->irq, tlan_handle_interrupt, IRQF_SHARED,
944 dev->name, dev ); 959 dev->name, dev);
945 960
946 if ( err ) { 961 if (err) {
947 pr_err("TLAN: Cannot open %s because IRQ %d is already in use.\n", 962 pr_err("TLAN: Cannot open %s because IRQ %d is already in use.\n",
948 dev->name, dev->irq ); 963 dev->name, dev->irq);
949 return err; 964 return err;
950 } 965 }
951 966
@@ -953,145 +968,145 @@ static int TLan_Open( struct net_device *dev )
953 netif_start_queue(dev); 968 netif_start_queue(dev);
954 969
955 /* NOTE: It might not be necessary to read the stats before a 970 /* NOTE: It might not be necessary to read the stats before a
956 reset if you don't care what the values are. 971 reset if you don't care what the values are.
957 */ 972 */
958 TLan_ResetLists( dev ); 973 tlan_reset_lists(dev);
959 TLan_ReadAndClearStats( dev, TLAN_IGNORE ); 974 tlan_read_and_clear_stats(dev, TLAN_IGNORE);
960 TLan_ResetAdapter( dev ); 975 tlan_reset_adapter(dev);
961 976
962 TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Opened. TLAN Chip Rev: %x\n", 977 TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Opened. TLAN Chip Rev: %x\n",
963 dev->name, priv->tlanRev ); 978 dev->name, priv->tlan_rev);
964 979
965 return 0; 980 return 0;
966 981
967} /* TLan_Open */ 982}
968 983
969 984
970 985
971 /************************************************************** 986/**************************************************************
972 * TLan_ioctl 987 * tlan_ioctl
973 * 988 *
974 * Returns: 989 * Returns:
975 * 0 on success, error code otherwise 990 * 0 on success, error code otherwise
976 * Params: 991 * Params:
977 * dev structure of device to receive ioctl. 992 * dev structure of device to receive ioctl.
978 * 993 *
979 * rq ifreq structure to hold userspace data. 994 * rq ifreq structure to hold userspace data.
980 * 995 *
981 * cmd ioctl command. 996 * cmd ioctl command.
982 * 997 *
983 * 998 *
984 *************************************************************/ 999 *************************************************************/
985 1000
986static int TLan_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1001static int tlan_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
987{ 1002{
988 TLanPrivateInfo *priv = netdev_priv(dev); 1003 struct tlan_priv *priv = netdev_priv(dev);
989 struct mii_ioctl_data *data = if_mii(rq); 1004 struct mii_ioctl_data *data = if_mii(rq);
990 u32 phy = priv->phy[priv->phyNum]; 1005 u32 phy = priv->phy[priv->phy_num];
991 1006
992 if (!priv->phyOnline) 1007 if (!priv->phy_online)
993 return -EAGAIN; 1008 return -EAGAIN;
994 1009
995 switch(cmd) { 1010 switch (cmd) {
996 case SIOCGMIIPHY: /* Get address of MII PHY in use. */ 1011 case SIOCGMIIPHY: /* get address of MII PHY in use. */
997 data->phy_id = phy; 1012 data->phy_id = phy;
998 1013
999 1014
1000 case SIOCGMIIREG: /* Read MII PHY register. */ 1015 case SIOCGMIIREG: /* read MII PHY register. */
1001 TLan_MiiReadReg(dev, data->phy_id & 0x1f, 1016 tlan_mii_read_reg(dev, data->phy_id & 0x1f,
1002 data->reg_num & 0x1f, &data->val_out); 1017 data->reg_num & 0x1f, &data->val_out);
1003 return 0; 1018 return 0;
1004 1019
1005 1020
1006 case SIOCSMIIREG: /* Write MII PHY register. */ 1021 case SIOCSMIIREG: /* write MII PHY register. */
1007 TLan_MiiWriteReg(dev, data->phy_id & 0x1f, 1022 tlan_mii_write_reg(dev, data->phy_id & 0x1f,
1008 data->reg_num & 0x1f, data->val_in); 1023 data->reg_num & 0x1f, data->val_in);
1009 return 0; 1024 return 0;
1010 default: 1025 default:
1011 return -EOPNOTSUPP; 1026 return -EOPNOTSUPP;
1012 } 1027 }
1013} /* tlan_ioctl */ 1028}
1014 1029
1015 1030
1016 /*************************************************************** 1031/***************************************************************
1017 * TLan_tx_timeout 1032 * tlan_tx_timeout
1018 * 1033 *
1019 * Returns: nothing 1034 * Returns: nothing
1020 * 1035 *
1021 * Params: 1036 * Params:
1022 * dev structure of device which timed out 1037 * dev structure of device which timed out
1023 * during transmit. 1038 * during transmit.
1024 * 1039 *
1025 **************************************************************/ 1040 **************************************************************/
1026 1041
1027static void TLan_tx_timeout(struct net_device *dev) 1042static void tlan_tx_timeout(struct net_device *dev)
1028{ 1043{
1029 1044
1030 TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Transmit timed out.\n", dev->name); 1045 TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Transmit timed out.\n", dev->name);
1031 1046
1032 /* Ok so we timed out, lets see what we can do about it...*/ 1047 /* Ok so we timed out, lets see what we can do about it...*/
1033 TLan_FreeLists( dev ); 1048 tlan_free_lists(dev);
1034 TLan_ResetLists( dev ); 1049 tlan_reset_lists(dev);
1035 TLan_ReadAndClearStats( dev, TLAN_IGNORE ); 1050 tlan_read_and_clear_stats(dev, TLAN_IGNORE);
1036 TLan_ResetAdapter( dev ); 1051 tlan_reset_adapter(dev);
1037 dev->trans_start = jiffies; /* prevent tx timeout */ 1052 dev->trans_start = jiffies; /* prevent tx timeout */
1038 netif_wake_queue( dev ); 1053 netif_wake_queue(dev);
1039 1054
1040} 1055}
1041 1056
1042 1057
1043 /*************************************************************** 1058/***************************************************************
1044 * TLan_tx_timeout_work 1059 * tlan_tx_timeout_work
1045 * 1060 *
1046 * Returns: nothing 1061 * Returns: nothing
1047 * 1062 *
1048 * Params: 1063 * Params:
1049 * work work item of device which timed out 1064 * work work item of device which timed out
1050 * 1065 *
1051 **************************************************************/ 1066 **************************************************************/
1052 1067
1053static void TLan_tx_timeout_work(struct work_struct *work) 1068static void tlan_tx_timeout_work(struct work_struct *work)
1054{ 1069{
1055 TLanPrivateInfo *priv = 1070 struct tlan_priv *priv =
1056 container_of(work, TLanPrivateInfo, tlan_tqueue); 1071 container_of(work, struct tlan_priv, tlan_tqueue);
1057 1072
1058 TLan_tx_timeout(priv->dev); 1073 tlan_tx_timeout(priv->dev);
1059} 1074}
1060 1075
1061 1076
1062 1077
1063 /*************************************************************** 1078/***************************************************************
1064 * TLan_StartTx 1079 * tlan_start_tx
1065 * 1080 *
1066 * Returns: 1081 * Returns:
1067 * 0 on success, non-zero on failure. 1082 * 0 on success, non-zero on failure.
1068 * Parms: 1083 * Parms:
1069 * skb A pointer to the sk_buff containing the 1084 * skb A pointer to the sk_buff containing the
1070 * frame to be sent. 1085 * frame to be sent.
1071 * dev The device to send the data on. 1086 * dev The device to send the data on.
1072 * 1087 *
1073 * This function adds a frame to the Tx list to be sent 1088 * This function adds a frame to the Tx list to be sent
1074 * ASAP. First it verifies that the adapter is ready and 1089 * ASAP. First it verifies that the adapter is ready and
1075 * there is room in the queue. Then it sets up the next 1090 * there is room in the queue. Then it sets up the next
1076 * available list, copies the frame to the corresponding 1091 * available list, copies the frame to the corresponding
1077 * buffer. If the adapter Tx channel is idle, it gives 1092 * buffer. If the adapter Tx channel is idle, it gives
1078 * the adapter a Tx Go command on the list, otherwise it 1093 * the adapter a Tx Go command on the list, otherwise it
1079 * sets the forward address of the previous list to point 1094 * sets the forward address of the previous list to point
1080 * to this one. Then it frees the sk_buff. 1095 * to this one. Then it frees the sk_buff.
1081 * 1096 *
1082 **************************************************************/ 1097 **************************************************************/
1083 1098
1084static netdev_tx_t TLan_StartTx( struct sk_buff *skb, struct net_device *dev ) 1099static netdev_tx_t tlan_start_tx(struct sk_buff *skb, struct net_device *dev)
1085{ 1100{
1086 TLanPrivateInfo *priv = netdev_priv(dev); 1101 struct tlan_priv *priv = netdev_priv(dev);
1087 dma_addr_t tail_list_phys; 1102 dma_addr_t tail_list_phys;
1088 TLanList *tail_list; 1103 struct tlan_list *tail_list;
1089 unsigned long flags; 1104 unsigned long flags;
1090 unsigned int txlen; 1105 unsigned int txlen;
1091 1106
1092 if ( ! priv->phyOnline ) { 1107 if (!priv->phy_online) {
1093 TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: %s PHY is not ready\n", 1108 TLAN_DBG(TLAN_DEBUG_TX, "TRANSMIT: %s PHY is not ready\n",
1094 dev->name ); 1109 dev->name);
1095 dev_kfree_skb_any(skb); 1110 dev_kfree_skb_any(skb);
1096 return NETDEV_TX_OK; 1111 return NETDEV_TX_OK;
1097 } 1112 }
@@ -1100,218 +1115,221 @@ static netdev_tx_t TLan_StartTx( struct sk_buff *skb, struct net_device *dev )
1100 return NETDEV_TX_OK; 1115 return NETDEV_TX_OK;
1101 txlen = max(skb->len, (unsigned int)TLAN_MIN_FRAME_SIZE); 1116 txlen = max(skb->len, (unsigned int)TLAN_MIN_FRAME_SIZE);
1102 1117
1103 tail_list = priv->txList + priv->txTail; 1118 tail_list = priv->tx_list + priv->tx_tail;
1104 tail_list_phys = priv->txListDMA + sizeof(TLanList) * priv->txTail; 1119 tail_list_phys =
1120 priv->tx_list_dma + sizeof(struct tlan_list)*priv->tx_tail;
1105 1121
1106 if ( tail_list->cStat != TLAN_CSTAT_UNUSED ) { 1122 if (tail_list->c_stat != TLAN_CSTAT_UNUSED) {
1107 TLAN_DBG( TLAN_DEBUG_TX, 1123 TLAN_DBG(TLAN_DEBUG_TX,
1108 "TRANSMIT: %s is busy (Head=%d Tail=%d)\n", 1124 "TRANSMIT: %s is busy (Head=%d Tail=%d)\n",
1109 dev->name, priv->txHead, priv->txTail ); 1125 dev->name, priv->tx_head, priv->tx_tail);
1110 netif_stop_queue(dev); 1126 netif_stop_queue(dev);
1111 priv->txBusyCount++; 1127 priv->tx_busy_count++;
1112 return NETDEV_TX_BUSY; 1128 return NETDEV_TX_BUSY;
1113 } 1129 }
1114 1130
1115 tail_list->forward = 0; 1131 tail_list->forward = 0;
1116 1132
1117 tail_list->buffer[0].address = pci_map_single(priv->pciDev, 1133 tail_list->buffer[0].address = pci_map_single(priv->pci_dev,
1118 skb->data, txlen, 1134 skb->data, txlen,
1119 PCI_DMA_TODEVICE); 1135 PCI_DMA_TODEVICE);
1120 TLan_StoreSKB(tail_list, skb); 1136 tlan_store_skb(tail_list, skb);
1121 1137
1122 tail_list->frameSize = (u16) txlen; 1138 tail_list->frame_size = (u16) txlen;
1123 tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) txlen; 1139 tail_list->buffer[0].count = TLAN_LAST_BUFFER | (u32) txlen;
1124 tail_list->buffer[1].count = 0; 1140 tail_list->buffer[1].count = 0;
1125 tail_list->buffer[1].address = 0; 1141 tail_list->buffer[1].address = 0;
1126 1142
1127 spin_lock_irqsave(&priv->lock, flags); 1143 spin_lock_irqsave(&priv->lock, flags);
1128 tail_list->cStat = TLAN_CSTAT_READY; 1144 tail_list->c_stat = TLAN_CSTAT_READY;
1129 if ( ! priv->txInProgress ) { 1145 if (!priv->tx_in_progress) {
1130 priv->txInProgress = 1; 1146 priv->tx_in_progress = 1;
1131 TLAN_DBG( TLAN_DEBUG_TX, 1147 TLAN_DBG(TLAN_DEBUG_TX,
1132 "TRANSMIT: Starting TX on buffer %d\n", priv->txTail ); 1148 "TRANSMIT: Starting TX on buffer %d\n",
1133 outl( tail_list_phys, dev->base_addr + TLAN_CH_PARM ); 1149 priv->tx_tail);
1134 outl( TLAN_HC_GO, dev->base_addr + TLAN_HOST_CMD ); 1150 outl(tail_list_phys, dev->base_addr + TLAN_CH_PARM);
1151 outl(TLAN_HC_GO, dev->base_addr + TLAN_HOST_CMD);
1135 } else { 1152 } else {
1136 TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: Adding buffer %d to TX channel\n", 1153 TLAN_DBG(TLAN_DEBUG_TX,
1137 priv->txTail ); 1154 "TRANSMIT: Adding buffer %d to TX channel\n",
1138 if ( priv->txTail == 0 ) { 1155 priv->tx_tail);
1139 ( priv->txList + ( TLAN_NUM_TX_LISTS - 1 ) )->forward 1156 if (priv->tx_tail == 0) {
1157 (priv->tx_list + (TLAN_NUM_TX_LISTS - 1))->forward
1140 = tail_list_phys; 1158 = tail_list_phys;
1141 } else { 1159 } else {
1142 ( priv->txList + ( priv->txTail - 1 ) )->forward 1160 (priv->tx_list + (priv->tx_tail - 1))->forward
1143 = tail_list_phys; 1161 = tail_list_phys;
1144 } 1162 }
1145 } 1163 }
1146 spin_unlock_irqrestore(&priv->lock, flags); 1164 spin_unlock_irqrestore(&priv->lock, flags);
1147 1165
1148 CIRC_INC( priv->txTail, TLAN_NUM_TX_LISTS ); 1166 CIRC_INC(priv->tx_tail, TLAN_NUM_TX_LISTS);
1149 1167
1150 return NETDEV_TX_OK; 1168 return NETDEV_TX_OK;
1151 1169
1152} /* TLan_StartTx */ 1170}
1153 1171
1154 1172
1155 1173
1156 1174
1157 /*************************************************************** 1175/***************************************************************
1158 * TLan_HandleInterrupt 1176 * tlan_handle_interrupt
1159 * 1177 *
1160 * Returns: 1178 * Returns:
1161 * Nothing 1179 * Nothing
1162 * Parms: 1180 * Parms:
1163 * irq The line on which the interrupt 1181 * irq The line on which the interrupt
1164 * occurred. 1182 * occurred.
1165 * dev_id A pointer to the device assigned to 1183 * dev_id A pointer to the device assigned to
1166 * this irq line. 1184 * this irq line.
1167 * 1185 *
1168 * This function handles an interrupt generated by its 1186 * This function handles an interrupt generated by its
1169 * assigned TLAN adapter. The function deactivates 1187 * assigned TLAN adapter. The function deactivates
1170 * interrupts on its adapter, records the type of 1188 * interrupts on its adapter, records the type of
1171 * interrupt, executes the appropriate subhandler, and 1189 * interrupt, executes the appropriate subhandler, and
1172 * acknowdges the interrupt to the adapter (thus 1190 * acknowdges the interrupt to the adapter (thus
1173 * re-enabling adapter interrupts. 1191 * re-enabling adapter interrupts.
1174 * 1192 *
1175 **************************************************************/ 1193 **************************************************************/
1176 1194
1177static irqreturn_t TLan_HandleInterrupt(int irq, void *dev_id) 1195static irqreturn_t tlan_handle_interrupt(int irq, void *dev_id)
1178{ 1196{
1179 struct net_device *dev = dev_id; 1197 struct net_device *dev = dev_id;
1180 TLanPrivateInfo *priv = netdev_priv(dev); 1198 struct tlan_priv *priv = netdev_priv(dev);
1181 u16 host_int; 1199 u16 host_int;
1182 u16 type; 1200 u16 type;
1183 1201
1184 spin_lock(&priv->lock); 1202 spin_lock(&priv->lock);
1185 1203
1186 host_int = inw( dev->base_addr + TLAN_HOST_INT ); 1204 host_int = inw(dev->base_addr + TLAN_HOST_INT);
1187 type = ( host_int & TLAN_HI_IT_MASK ) >> 2; 1205 type = (host_int & TLAN_HI_IT_MASK) >> 2;
1188 if ( type ) { 1206 if (type) {
1189 u32 ack; 1207 u32 ack;
1190 u32 host_cmd; 1208 u32 host_cmd;
1191 1209
1192 outw( host_int, dev->base_addr + TLAN_HOST_INT ); 1210 outw(host_int, dev->base_addr + TLAN_HOST_INT);
1193 ack = TLanIntVector[type]( dev, host_int ); 1211 ack = tlan_int_vector[type](dev, host_int);
1194 1212
1195 if ( ack ) { 1213 if (ack) {
1196 host_cmd = TLAN_HC_ACK | ack | ( type << 18 ); 1214 host_cmd = TLAN_HC_ACK | ack | (type << 18);
1197 outl( host_cmd, dev->base_addr + TLAN_HOST_CMD ); 1215 outl(host_cmd, dev->base_addr + TLAN_HOST_CMD);
1198 } 1216 }
1199 } 1217 }
1200 1218
1201 spin_unlock(&priv->lock); 1219 spin_unlock(&priv->lock);
1202 1220
1203 return IRQ_RETVAL(type); 1221 return IRQ_RETVAL(type);
1204} /* TLan_HandleInterrupts */ 1222}
1205 1223
1206 1224
1207 1225
1208 1226
1209 /*************************************************************** 1227/***************************************************************
1210 * TLan_Close 1228 * tlan_close
1211 * 1229 *
1212 * Returns: 1230 * Returns:
1213 * An error code. 1231 * An error code.
1214 * Parms: 1232 * Parms:
1215 * dev The device structure of the device to 1233 * dev The device structure of the device to
1216 * close. 1234 * close.
1217 * 1235 *
1218 * This function shuts down the adapter. It records any 1236 * This function shuts down the adapter. It records any
1219 * stats, puts the adapter into reset state, deactivates 1237 * stats, puts the adapter into reset state, deactivates
1220 * its time as needed, and frees the irq it is using. 1238 * its time as needed, and frees the irq it is using.
1221 * 1239 *
1222 **************************************************************/ 1240 **************************************************************/
1223 1241
1224static int TLan_Close(struct net_device *dev) 1242static int tlan_close(struct net_device *dev)
1225{ 1243{
1226 TLanPrivateInfo *priv = netdev_priv(dev); 1244 struct tlan_priv *priv = netdev_priv(dev);
1227 1245
1228 netif_stop_queue(dev); 1246 netif_stop_queue(dev);
1229 priv->neg_be_verbose = 0; 1247 priv->neg_be_verbose = 0;
1230 1248
1231 TLan_ReadAndClearStats( dev, TLAN_RECORD ); 1249 tlan_read_and_clear_stats(dev, TLAN_RECORD);
1232 outl( TLAN_HC_AD_RST, dev->base_addr + TLAN_HOST_CMD ); 1250 outl(TLAN_HC_AD_RST, dev->base_addr + TLAN_HOST_CMD);
1233 if ( priv->timer.function != NULL ) { 1251 if (priv->timer.function != NULL) {
1234 del_timer_sync( &priv->timer ); 1252 del_timer_sync(&priv->timer);
1235 priv->timer.function = NULL; 1253 priv->timer.function = NULL;
1236 } 1254 }
1237 1255
1238 free_irq( dev->irq, dev ); 1256 free_irq(dev->irq, dev);
1239 TLan_FreeLists( dev ); 1257 tlan_free_lists(dev);
1240 TLAN_DBG( TLAN_DEBUG_GNRL, "Device %s closed.\n", dev->name ); 1258 TLAN_DBG(TLAN_DEBUG_GNRL, "Device %s closed.\n", dev->name);
1241 1259
1242 return 0; 1260 return 0;
1243 1261
1244} /* TLan_Close */ 1262}
1245 1263
1246 1264
1247 1265
1248 1266
1249 /*************************************************************** 1267/***************************************************************
1250 * TLan_GetStats 1268 * tlan_get_stats
1251 * 1269 *
1252 * Returns: 1270 * Returns:
1253 * A pointer to the device's statistics structure. 1271 * A pointer to the device's statistics structure.
1254 * Parms: 1272 * Parms:
1255 * dev The device structure to return the 1273 * dev The device structure to return the
1256 * stats for. 1274 * stats for.
1257 * 1275 *
1258 * This function updates the devices statistics by reading 1276 * This function updates the devices statistics by reading
1259 * the TLAN chip's onboard registers. Then it returns the 1277 * the TLAN chip's onboard registers. Then it returns the
1260 * address of the statistics structure. 1278 * address of the statistics structure.
1261 * 1279 *
1262 **************************************************************/ 1280 **************************************************************/
1263 1281
1264static struct net_device_stats *TLan_GetStats( struct net_device *dev ) 1282static struct net_device_stats *tlan_get_stats(struct net_device *dev)
1265{ 1283{
1266 TLanPrivateInfo *priv = netdev_priv(dev); 1284 struct tlan_priv *priv = netdev_priv(dev);
1267 int i; 1285 int i;
1268 1286
1269 /* Should only read stats if open ? */ 1287 /* Should only read stats if open ? */
1270 TLan_ReadAndClearStats( dev, TLAN_RECORD ); 1288 tlan_read_and_clear_stats(dev, TLAN_RECORD);
1271 1289
1272 TLAN_DBG( TLAN_DEBUG_RX, "RECEIVE: %s EOC count = %d\n", dev->name, 1290 TLAN_DBG(TLAN_DEBUG_RX, "RECEIVE: %s EOC count = %d\n", dev->name,
1273 priv->rxEocCount ); 1291 priv->rx_eoc_count);
1274 TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: %s Busy count = %d\n", dev->name, 1292 TLAN_DBG(TLAN_DEBUG_TX, "TRANSMIT: %s Busy count = %d\n", dev->name,
1275 priv->txBusyCount ); 1293 priv->tx_busy_count);
1276 if ( debug & TLAN_DEBUG_GNRL ) { 1294 if (debug & TLAN_DEBUG_GNRL) {
1277 TLan_PrintDio( dev->base_addr ); 1295 tlan_print_dio(dev->base_addr);
1278 TLan_PhyPrint( dev ); 1296 tlan_phy_print(dev);
1279 } 1297 }
1280 if ( debug & TLAN_DEBUG_LIST ) { 1298 if (debug & TLAN_DEBUG_LIST) {
1281 for ( i = 0; i < TLAN_NUM_RX_LISTS; i++ ) 1299 for (i = 0; i < TLAN_NUM_RX_LISTS; i++)
1282 TLan_PrintList( priv->rxList + i, "RX", i ); 1300 tlan_print_list(priv->rx_list + i, "RX", i);
1283 for ( i = 0; i < TLAN_NUM_TX_LISTS; i++ ) 1301 for (i = 0; i < TLAN_NUM_TX_LISTS; i++)
1284 TLan_PrintList( priv->txList + i, "TX", i ); 1302 tlan_print_list(priv->tx_list + i, "TX", i);
1285 } 1303 }
1286 1304
1287 return &dev->stats; 1305 return &dev->stats;
1288 1306
1289} /* TLan_GetStats */ 1307}
1290 1308
1291 1309
1292 1310
1293 1311
1294 /*************************************************************** 1312/***************************************************************
1295 * TLan_SetMulticastList 1313 * tlan_set_multicast_list
1296 * 1314 *
1297 * Returns: 1315 * Returns:
1298 * Nothing 1316 * Nothing
1299 * Parms: 1317 * Parms:
1300 * dev The device structure to set the 1318 * dev The device structure to set the
1301 * multicast list for. 1319 * multicast list for.
1302 * 1320 *
1303 * This function sets the TLAN adaptor to various receive 1321 * This function sets the TLAN adaptor to various receive
1304 * modes. If the IFF_PROMISC flag is set, promiscuous 1322 * modes. If the IFF_PROMISC flag is set, promiscuous
1305 * mode is acitviated. Otherwise, promiscuous mode is 1323 * mode is acitviated. Otherwise, promiscuous mode is
1306 * turned off. If the IFF_ALLMULTI flag is set, then 1324 * turned off. If the IFF_ALLMULTI flag is set, then
1307 * the hash table is set to receive all group addresses. 1325 * the hash table is set to receive all group addresses.
1308 * Otherwise, the first three multicast addresses are 1326 * Otherwise, the first three multicast addresses are
1309 * stored in AREG_1-3, and the rest are selected via the 1327 * stored in AREG_1-3, and the rest are selected via the
1310 * hash table, as necessary. 1328 * hash table, as necessary.
1311 * 1329 *
1312 **************************************************************/ 1330 **************************************************************/
1313 1331
1314static void TLan_SetMulticastList( struct net_device *dev ) 1332static void tlan_set_multicast_list(struct net_device *dev)
1315{ 1333{
1316 struct netdev_hw_addr *ha; 1334 struct netdev_hw_addr *ha;
1317 u32 hash1 = 0; 1335 u32 hash1 = 0;
@@ -1320,53 +1338,56 @@ static void TLan_SetMulticastList( struct net_device *dev )
1320 u32 offset; 1338 u32 offset;
1321 u8 tmp; 1339 u8 tmp;
1322 1340
1323 if ( dev->flags & IFF_PROMISC ) { 1341 if (dev->flags & IFF_PROMISC) {
1324 tmp = TLan_DioRead8( dev->base_addr, TLAN_NET_CMD ); 1342 tmp = tlan_dio_read8(dev->base_addr, TLAN_NET_CMD);
1325 TLan_DioWrite8( dev->base_addr, 1343 tlan_dio_write8(dev->base_addr,
1326 TLAN_NET_CMD, tmp | TLAN_NET_CMD_CAF ); 1344 TLAN_NET_CMD, tmp | TLAN_NET_CMD_CAF);
1327 } else { 1345 } else {
1328 tmp = TLan_DioRead8( dev->base_addr, TLAN_NET_CMD ); 1346 tmp = tlan_dio_read8(dev->base_addr, TLAN_NET_CMD);
1329 TLan_DioWrite8( dev->base_addr, 1347 tlan_dio_write8(dev->base_addr,
1330 TLAN_NET_CMD, tmp & ~TLAN_NET_CMD_CAF ); 1348 TLAN_NET_CMD, tmp & ~TLAN_NET_CMD_CAF);
1331 if ( dev->flags & IFF_ALLMULTI ) { 1349 if (dev->flags & IFF_ALLMULTI) {
1332 for ( i = 0; i < 3; i++ ) 1350 for (i = 0; i < 3; i++)
1333 TLan_SetMac( dev, i + 1, NULL ); 1351 tlan_set_mac(dev, i + 1, NULL);
1334 TLan_DioWrite32( dev->base_addr, TLAN_HASH_1, 0xFFFFFFFF ); 1352 tlan_dio_write32(dev->base_addr, TLAN_HASH_1,
1335 TLan_DioWrite32( dev->base_addr, TLAN_HASH_2, 0xFFFFFFFF ); 1353 0xffffffff);
1354 tlan_dio_write32(dev->base_addr, TLAN_HASH_2,
1355 0xffffffff);
1336 } else { 1356 } else {
1337 i = 0; 1357 i = 0;
1338 netdev_for_each_mc_addr(ha, dev) { 1358 netdev_for_each_mc_addr(ha, dev) {
1339 if ( i < 3 ) { 1359 if (i < 3) {
1340 TLan_SetMac( dev, i + 1, 1360 tlan_set_mac(dev, i + 1,
1341 (char *) &ha->addr); 1361 (char *) &ha->addr);
1342 } else { 1362 } else {
1343 offset = TLan_HashFunc((u8 *)&ha->addr); 1363 offset =
1344 if ( offset < 32 ) 1364 tlan_hash_func((u8 *)&ha->addr);
1345 hash1 |= ( 1 << offset ); 1365 if (offset < 32)
1366 hash1 |= (1 << offset);
1346 else 1367 else
1347 hash2 |= ( 1 << ( offset - 32 ) ); 1368 hash2 |= (1 << (offset - 32));
1348 } 1369 }
1349 i++; 1370 i++;
1350 } 1371 }
1351 for ( ; i < 3; i++ ) 1372 for ( ; i < 3; i++)
1352 TLan_SetMac( dev, i + 1, NULL ); 1373 tlan_set_mac(dev, i + 1, NULL);
1353 TLan_DioWrite32( dev->base_addr, TLAN_HASH_1, hash1 ); 1374 tlan_dio_write32(dev->base_addr, TLAN_HASH_1, hash1);
1354 TLan_DioWrite32( dev->base_addr, TLAN_HASH_2, hash2 ); 1375 tlan_dio_write32(dev->base_addr, TLAN_HASH_2, hash2);
1355 } 1376 }
1356 } 1377 }
1357 1378
1358} /* TLan_SetMulticastList */ 1379}
1359 1380
1360 1381
1361 1382
1362/***************************************************************************** 1383/*****************************************************************************
1363****************************************************************************** 1384******************************************************************************
1364 1385
1365 ThunderLAN Driver Interrupt Vectors and Table 1386ThunderLAN driver interrupt vectors and table
1366 1387
1367 Please see Chap. 4, "Interrupt Handling" of the "ThunderLAN 1388please see chap. 4, "Interrupt Handling" of the "ThunderLAN
1368 Programmer's Guide" for more informations on handling interrupts 1389Programmer's Guide" for more informations on handling interrupts
1369 generated by TLAN based adapters. 1390generated by TLAN based adapters.
1370 1391
1371****************************************************************************** 1392******************************************************************************
1372*****************************************************************************/ 1393*****************************************************************************/
@@ -1374,46 +1395,48 @@ static void TLan_SetMulticastList( struct net_device *dev )
1374 1395
1375 1396
1376 1397
1377 /*************************************************************** 1398/***************************************************************
1378 * TLan_HandleTxEOF 1399 * tlan_handle_tx_eof
1379 * 1400 *
1380 * Returns: 1401 * Returns:
1381 * 1 1402 * 1
1382 * Parms: 1403 * Parms:
1383 * dev Device assigned the IRQ that was 1404 * dev Device assigned the IRQ that was
1384 * raised. 1405 * raised.
1385 * host_int The contents of the HOST_INT 1406 * host_int The contents of the HOST_INT
1386 * port. 1407 * port.
1387 * 1408 *
1388 * This function handles Tx EOF interrupts which are raised 1409 * This function handles Tx EOF interrupts which are raised
1389 * by the adapter when it has completed sending the 1410 * by the adapter when it has completed sending the
1390 * contents of a buffer. If detemines which list/buffer 1411 * contents of a buffer. If detemines which list/buffer
1391 * was completed and resets it. If the buffer was the last 1412 * was completed and resets it. If the buffer was the last
1392 * in the channel (EOC), then the function checks to see if 1413 * in the channel (EOC), then the function checks to see if
1393 * another buffer is ready to send, and if so, sends a Tx 1414 * another buffer is ready to send, and if so, sends a Tx
1394 * Go command. Finally, the driver activates/continues the 1415 * Go command. Finally, the driver activates/continues the
1395 * activity LED. 1416 * activity LED.
1396 * 1417 *
1397 **************************************************************/ 1418 **************************************************************/
1398 1419
1399static u32 TLan_HandleTxEOF( struct net_device *dev, u16 host_int ) 1420static u32 tlan_handle_tx_eof(struct net_device *dev, u16 host_int)
1400{ 1421{
1401 TLanPrivateInfo *priv = netdev_priv(dev); 1422 struct tlan_priv *priv = netdev_priv(dev);
1402 int eoc = 0; 1423 int eoc = 0;
1403 TLanList *head_list; 1424 struct tlan_list *head_list;
1404 dma_addr_t head_list_phys; 1425 dma_addr_t head_list_phys;
1405 u32 ack = 0; 1426 u32 ack = 0;
1406 u16 tmpCStat; 1427 u16 tmp_c_stat;
1407 1428
1408 TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: Handling TX EOF (Head=%d Tail=%d)\n", 1429 TLAN_DBG(TLAN_DEBUG_TX,
1409 priv->txHead, priv->txTail ); 1430 "TRANSMIT: Handling TX EOF (Head=%d Tail=%d)\n",
1410 head_list = priv->txList + priv->txHead; 1431 priv->tx_head, priv->tx_tail);
1432 head_list = priv->tx_list + priv->tx_head;
1411 1433
1412 while (((tmpCStat = head_list->cStat ) & TLAN_CSTAT_FRM_CMP) && (ack < 255)) { 1434 while (((tmp_c_stat = head_list->c_stat) & TLAN_CSTAT_FRM_CMP)
1413 struct sk_buff *skb = TLan_GetSKB(head_list); 1435 && (ack < 255)) {
1436 struct sk_buff *skb = tlan_get_skb(head_list);
1414 1437
1415 ack++; 1438 ack++;
1416 pci_unmap_single(priv->pciDev, head_list->buffer[0].address, 1439 pci_unmap_single(priv->pci_dev, head_list->buffer[0].address,
1417 max(skb->len, 1440 max(skb->len,
1418 (unsigned int)TLAN_MIN_FRAME_SIZE), 1441 (unsigned int)TLAN_MIN_FRAME_SIZE),
1419 PCI_DMA_TODEVICE); 1442 PCI_DMA_TODEVICE);
@@ -1421,304 +1444,311 @@ static u32 TLan_HandleTxEOF( struct net_device *dev, u16 host_int )
1421 head_list->buffer[8].address = 0; 1444 head_list->buffer[8].address = 0;
1422 head_list->buffer[9].address = 0; 1445 head_list->buffer[9].address = 0;
1423 1446
1424 if ( tmpCStat & TLAN_CSTAT_EOC ) 1447 if (tmp_c_stat & TLAN_CSTAT_EOC)
1425 eoc = 1; 1448 eoc = 1;
1426 1449
1427 dev->stats.tx_bytes += head_list->frameSize; 1450 dev->stats.tx_bytes += head_list->frame_size;
1428 1451
1429 head_list->cStat = TLAN_CSTAT_UNUSED; 1452 head_list->c_stat = TLAN_CSTAT_UNUSED;
1430 netif_start_queue(dev); 1453 netif_start_queue(dev);
1431 CIRC_INC( priv->txHead, TLAN_NUM_TX_LISTS ); 1454 CIRC_INC(priv->tx_head, TLAN_NUM_TX_LISTS);
1432 head_list = priv->txList + priv->txHead; 1455 head_list = priv->tx_list + priv->tx_head;
1433 } 1456 }
1434 1457
1435 if (!ack) 1458 if (!ack)
1436 printk(KERN_INFO "TLAN: Received interrupt for uncompleted TX frame.\n"); 1459 printk(KERN_INFO
1437 1460 "TLAN: Received interrupt for uncompleted TX frame.\n");
1438 if ( eoc ) { 1461
1439 TLAN_DBG( TLAN_DEBUG_TX, 1462 if (eoc) {
1440 "TRANSMIT: Handling TX EOC (Head=%d Tail=%d)\n", 1463 TLAN_DBG(TLAN_DEBUG_TX,
1441 priv->txHead, priv->txTail ); 1464 "TRANSMIT: handling TX EOC (Head=%d Tail=%d)\n",
1442 head_list = priv->txList + priv->txHead; 1465 priv->tx_head, priv->tx_tail);
1443 head_list_phys = priv->txListDMA + sizeof(TLanList) * priv->txHead; 1466 head_list = priv->tx_list + priv->tx_head;
1444 if ( ( head_list->cStat & TLAN_CSTAT_READY ) == TLAN_CSTAT_READY ) { 1467 head_list_phys = priv->tx_list_dma
1445 outl(head_list_phys, dev->base_addr + TLAN_CH_PARM ); 1468 + sizeof(struct tlan_list)*priv->tx_head;
1469 if (head_list->c_stat & TLAN_CSTAT_READY) {
1470 outl(head_list_phys, dev->base_addr + TLAN_CH_PARM);
1446 ack |= TLAN_HC_GO; 1471 ack |= TLAN_HC_GO;
1447 } else { 1472 } else {
1448 priv->txInProgress = 0; 1473 priv->tx_in_progress = 0;
1449 } 1474 }
1450 } 1475 }
1451 1476
1452 if ( priv->adapter->flags & TLAN_ADAPTER_ACTIVITY_LED ) { 1477 if (priv->adapter->flags & TLAN_ADAPTER_ACTIVITY_LED) {
1453 TLan_DioWrite8( dev->base_addr, 1478 tlan_dio_write8(dev->base_addr,
1454 TLAN_LED_REG, TLAN_LED_LINK | TLAN_LED_ACT ); 1479 TLAN_LED_REG, TLAN_LED_LINK | TLAN_LED_ACT);
1455 if ( priv->timer.function == NULL ) { 1480 if (priv->timer.function == NULL) {
1456 priv->timer.function = TLan_Timer; 1481 priv->timer.function = tlan_timer;
1457 priv->timer.data = (unsigned long) dev; 1482 priv->timer.data = (unsigned long) dev;
1458 priv->timer.expires = jiffies + TLAN_TIMER_ACT_DELAY; 1483 priv->timer.expires = jiffies + TLAN_TIMER_ACT_DELAY;
1459 priv->timerSetAt = jiffies; 1484 priv->timer_set_at = jiffies;
1460 priv->timerType = TLAN_TIMER_ACTIVITY; 1485 priv->timer_type = TLAN_TIMER_ACTIVITY;
1461 add_timer(&priv->timer); 1486 add_timer(&priv->timer);
1462 } else if ( priv->timerType == TLAN_TIMER_ACTIVITY ) { 1487 } else if (priv->timer_type == TLAN_TIMER_ACTIVITY) {
1463 priv->timerSetAt = jiffies; 1488 priv->timer_set_at = jiffies;
1464 } 1489 }
1465 } 1490 }
1466 1491
1467 return ack; 1492 return ack;
1468 1493
1469} /* TLan_HandleTxEOF */ 1494}
1470 1495
1471 1496
1472 1497
1473 1498
1474 /*************************************************************** 1499/***************************************************************
1475 * TLan_HandleStatOverflow 1500 * TLan_HandleStatOverflow
1476 * 1501 *
1477 * Returns: 1502 * Returns:
1478 * 1 1503 * 1
1479 * Parms: 1504 * Parms:
1480 * dev Device assigned the IRQ that was 1505 * dev Device assigned the IRQ that was
1481 * raised. 1506 * raised.
1482 * host_int The contents of the HOST_INT 1507 * host_int The contents of the HOST_INT
1483 * port. 1508 * port.
1484 * 1509 *
1485 * This function handles the Statistics Overflow interrupt 1510 * This function handles the Statistics Overflow interrupt
1486 * which means that one or more of the TLAN statistics 1511 * which means that one or more of the TLAN statistics
1487 * registers has reached 1/2 capacity and needs to be read. 1512 * registers has reached 1/2 capacity and needs to be read.
1488 * 1513 *
1489 **************************************************************/ 1514 **************************************************************/
1490 1515
1491static u32 TLan_HandleStatOverflow( struct net_device *dev, u16 host_int ) 1516static u32 tlan_handle_stat_overflow(struct net_device *dev, u16 host_int)
1492{ 1517{
1493 TLan_ReadAndClearStats( dev, TLAN_RECORD ); 1518 tlan_read_and_clear_stats(dev, TLAN_RECORD);
1494 1519
1495 return 1; 1520 return 1;
1496 1521
1497} /* TLan_HandleStatOverflow */ 1522}
1498 1523
1499 1524
1500 1525
1501 1526
1502 /*************************************************************** 1527/***************************************************************
1503 * TLan_HandleRxEOF 1528 * TLan_HandleRxEOF
1504 * 1529 *
1505 * Returns: 1530 * Returns:
1506 * 1 1531 * 1
1507 * Parms: 1532 * Parms:
1508 * dev Device assigned the IRQ that was 1533 * dev Device assigned the IRQ that was
1509 * raised. 1534 * raised.
1510 * host_int The contents of the HOST_INT 1535 * host_int The contents of the HOST_INT
1511 * port. 1536 * port.
1512 * 1537 *
1513 * This function handles the Rx EOF interrupt which 1538 * This function handles the Rx EOF interrupt which
1514 * indicates a frame has been received by the adapter from 1539 * indicates a frame has been received by the adapter from
1515 * the net and the frame has been transferred to memory. 1540 * the net and the frame has been transferred to memory.
1516 * The function determines the bounce buffer the frame has 1541 * The function determines the bounce buffer the frame has
1517 * been loaded into, creates a new sk_buff big enough to 1542 * been loaded into, creates a new sk_buff big enough to
1518 * hold the frame, and sends it to protocol stack. It 1543 * hold the frame, and sends it to protocol stack. It
1519 * then resets the used buffer and appends it to the end 1544 * then resets the used buffer and appends it to the end
1520 * of the list. If the frame was the last in the Rx 1545 * of the list. If the frame was the last in the Rx
1521 * channel (EOC), the function restarts the receive channel 1546 * channel (EOC), the function restarts the receive channel
1522 * by sending an Rx Go command to the adapter. Then it 1547 * by sending an Rx Go command to the adapter. Then it
1523 * activates/continues the activity LED. 1548 * activates/continues the activity LED.
1524 * 1549 *
1525 **************************************************************/ 1550 **************************************************************/
1526 1551
1527static u32 TLan_HandleRxEOF( struct net_device *dev, u16 host_int ) 1552static u32 tlan_handle_rx_eof(struct net_device *dev, u16 host_int)
1528{ 1553{
1529 TLanPrivateInfo *priv = netdev_priv(dev); 1554 struct tlan_priv *priv = netdev_priv(dev);
1530 u32 ack = 0; 1555 u32 ack = 0;
1531 int eoc = 0; 1556 int eoc = 0;
1532 TLanList *head_list; 1557 struct tlan_list *head_list;
1533 struct sk_buff *skb; 1558 struct sk_buff *skb;
1534 TLanList *tail_list; 1559 struct tlan_list *tail_list;
1535 u16 tmpCStat; 1560 u16 tmp_c_stat;
1536 dma_addr_t head_list_phys; 1561 dma_addr_t head_list_phys;
1537 1562
1538 TLAN_DBG( TLAN_DEBUG_RX, "RECEIVE: Handling RX EOF (Head=%d Tail=%d)\n", 1563 TLAN_DBG(TLAN_DEBUG_RX, "RECEIVE: handling RX EOF (Head=%d Tail=%d)\n",
1539 priv->rxHead, priv->rxTail ); 1564 priv->rx_head, priv->rx_tail);
1540 head_list = priv->rxList + priv->rxHead; 1565 head_list = priv->rx_list + priv->rx_head;
1541 head_list_phys = priv->rxListDMA + sizeof(TLanList) * priv->rxHead; 1566 head_list_phys =
1567 priv->rx_list_dma + sizeof(struct tlan_list)*priv->rx_head;
1542 1568
1543 while (((tmpCStat = head_list->cStat) & TLAN_CSTAT_FRM_CMP) && (ack < 255)) { 1569 while (((tmp_c_stat = head_list->c_stat) & TLAN_CSTAT_FRM_CMP)
1544 dma_addr_t frameDma = head_list->buffer[0].address; 1570 && (ack < 255)) {
1545 u32 frameSize = head_list->frameSize; 1571 dma_addr_t frame_dma = head_list->buffer[0].address;
1572 u32 frame_size = head_list->frame_size;
1546 struct sk_buff *new_skb; 1573 struct sk_buff *new_skb;
1547 1574
1548 ack++; 1575 ack++;
1549 if (tmpCStat & TLAN_CSTAT_EOC) 1576 if (tmp_c_stat & TLAN_CSTAT_EOC)
1550 eoc = 1; 1577 eoc = 1;
1551 1578
1552 new_skb = netdev_alloc_skb_ip_align(dev, 1579 new_skb = netdev_alloc_skb_ip_align(dev,
1553 TLAN_MAX_FRAME_SIZE + 5); 1580 TLAN_MAX_FRAME_SIZE + 5);
1554 if ( !new_skb ) 1581 if (!new_skb)
1555 goto drop_and_reuse; 1582 goto drop_and_reuse;
1556 1583
1557 skb = TLan_GetSKB(head_list); 1584 skb = tlan_get_skb(head_list);
1558 pci_unmap_single(priv->pciDev, frameDma, 1585 pci_unmap_single(priv->pci_dev, frame_dma,
1559 TLAN_MAX_FRAME_SIZE, PCI_DMA_FROMDEVICE); 1586 TLAN_MAX_FRAME_SIZE, PCI_DMA_FROMDEVICE);
1560 skb_put( skb, frameSize ); 1587 skb_put(skb, frame_size);
1561 1588
1562 dev->stats.rx_bytes += frameSize; 1589 dev->stats.rx_bytes += frame_size;
1563 1590
1564 skb->protocol = eth_type_trans( skb, dev ); 1591 skb->protocol = eth_type_trans(skb, dev);
1565 netif_rx( skb ); 1592 netif_rx(skb);
1566 1593
1567 head_list->buffer[0].address = pci_map_single(priv->pciDev, 1594 head_list->buffer[0].address =
1568 new_skb->data, 1595 pci_map_single(priv->pci_dev, new_skb->data,
1569 TLAN_MAX_FRAME_SIZE, 1596 TLAN_MAX_FRAME_SIZE, PCI_DMA_FROMDEVICE);
1570 PCI_DMA_FROMDEVICE);
1571 1597
1572 TLan_StoreSKB(head_list, new_skb); 1598 tlan_store_skb(head_list, new_skb);
1573drop_and_reuse: 1599drop_and_reuse:
1574 head_list->forward = 0; 1600 head_list->forward = 0;
1575 head_list->cStat = 0; 1601 head_list->c_stat = 0;
1576 tail_list = priv->rxList + priv->rxTail; 1602 tail_list = priv->rx_list + priv->rx_tail;
1577 tail_list->forward = head_list_phys; 1603 tail_list->forward = head_list_phys;
1578 1604
1579 CIRC_INC( priv->rxHead, TLAN_NUM_RX_LISTS ); 1605 CIRC_INC(priv->rx_head, TLAN_NUM_RX_LISTS);
1580 CIRC_INC( priv->rxTail, TLAN_NUM_RX_LISTS ); 1606 CIRC_INC(priv->rx_tail, TLAN_NUM_RX_LISTS);
1581 head_list = priv->rxList + priv->rxHead; 1607 head_list = priv->rx_list + priv->rx_head;
1582 head_list_phys = priv->rxListDMA + sizeof(TLanList) * priv->rxHead; 1608 head_list_phys = priv->rx_list_dma
1609 + sizeof(struct tlan_list)*priv->rx_head;
1583 } 1610 }
1584 1611
1585 if (!ack) 1612 if (!ack)
1586 printk(KERN_INFO "TLAN: Received interrupt for uncompleted RX frame.\n"); 1613 printk(KERN_INFO
1587 1614 "TLAN: Received interrupt for uncompleted RX frame.\n");
1588 1615
1589 if ( eoc ) { 1616
1590 TLAN_DBG( TLAN_DEBUG_RX, 1617 if (eoc) {
1591 "RECEIVE: Handling RX EOC (Head=%d Tail=%d)\n", 1618 TLAN_DBG(TLAN_DEBUG_RX,
1592 priv->rxHead, priv->rxTail ); 1619 "RECEIVE: handling RX EOC (Head=%d Tail=%d)\n",
1593 head_list = priv->rxList + priv->rxHead; 1620 priv->rx_head, priv->rx_tail);
1594 head_list_phys = priv->rxListDMA + sizeof(TLanList) * priv->rxHead; 1621 head_list = priv->rx_list + priv->rx_head;
1595 outl(head_list_phys, dev->base_addr + TLAN_CH_PARM ); 1622 head_list_phys = priv->rx_list_dma
1623 + sizeof(struct tlan_list)*priv->rx_head;
1624 outl(head_list_phys, dev->base_addr + TLAN_CH_PARM);
1596 ack |= TLAN_HC_GO | TLAN_HC_RT; 1625 ack |= TLAN_HC_GO | TLAN_HC_RT;
1597 priv->rxEocCount++; 1626 priv->rx_eoc_count++;
1598 } 1627 }
1599 1628
1600 if ( priv->adapter->flags & TLAN_ADAPTER_ACTIVITY_LED ) { 1629 if (priv->adapter->flags & TLAN_ADAPTER_ACTIVITY_LED) {
1601 TLan_DioWrite8( dev->base_addr, 1630 tlan_dio_write8(dev->base_addr,
1602 TLAN_LED_REG, TLAN_LED_LINK | TLAN_LED_ACT ); 1631 TLAN_LED_REG, TLAN_LED_LINK | TLAN_LED_ACT);
1603 if ( priv->timer.function == NULL ) { 1632 if (priv->timer.function == NULL) {
1604 priv->timer.function = TLan_Timer; 1633 priv->timer.function = tlan_timer;
1605 priv->timer.data = (unsigned long) dev; 1634 priv->timer.data = (unsigned long) dev;
1606 priv->timer.expires = jiffies + TLAN_TIMER_ACT_DELAY; 1635 priv->timer.expires = jiffies + TLAN_TIMER_ACT_DELAY;
1607 priv->timerSetAt = jiffies; 1636 priv->timer_set_at = jiffies;
1608 priv->timerType = TLAN_TIMER_ACTIVITY; 1637 priv->timer_type = TLAN_TIMER_ACTIVITY;
1609 add_timer(&priv->timer); 1638 add_timer(&priv->timer);
1610 } else if ( priv->timerType == TLAN_TIMER_ACTIVITY ) { 1639 } else if (priv->timer_type == TLAN_TIMER_ACTIVITY) {
1611 priv->timerSetAt = jiffies; 1640 priv->timer_set_at = jiffies;
1612 } 1641 }
1613 } 1642 }
1614 1643
1615 return ack; 1644 return ack;
1616 1645
1617} /* TLan_HandleRxEOF */ 1646}
1618 1647
1619 1648
1620 1649
1621 1650
1622 /*************************************************************** 1651/***************************************************************
1623 * TLan_HandleDummy 1652 * tlan_handle_dummy
1624 * 1653 *
1625 * Returns: 1654 * Returns:
1626 * 1 1655 * 1
1627 * Parms: 1656 * Parms:
1628 * dev Device assigned the IRQ that was 1657 * dev Device assigned the IRQ that was
1629 * raised. 1658 * raised.
1630 * host_int The contents of the HOST_INT 1659 * host_int The contents of the HOST_INT
1631 * port. 1660 * port.
1632 * 1661 *
1633 * This function handles the Dummy interrupt, which is 1662 * This function handles the Dummy interrupt, which is
1634 * raised whenever a test interrupt is generated by setting 1663 * raised whenever a test interrupt is generated by setting
1635 * the Req_Int bit of HOST_CMD to 1. 1664 * the Req_Int bit of HOST_CMD to 1.
1636 * 1665 *
1637 **************************************************************/ 1666 **************************************************************/
1638 1667
1639static u32 TLan_HandleDummy( struct net_device *dev, u16 host_int ) 1668static u32 tlan_handle_dummy(struct net_device *dev, u16 host_int)
1640{ 1669{
1641 printk( "TLAN: Test interrupt on %s.\n", dev->name ); 1670 pr_info("TLAN: Test interrupt on %s.\n", dev->name);
1642 return 1; 1671 return 1;
1643 1672
1644} /* TLan_HandleDummy */ 1673}
1645 1674
1646 1675
1647 1676
1648 1677
1649 /*************************************************************** 1678/***************************************************************
1650 * TLan_HandleTxEOC 1679 * tlan_handle_tx_eoc
1651 * 1680 *
1652 * Returns: 1681 * Returns:
1653 * 1 1682 * 1
1654 * Parms: 1683 * Parms:
1655 * dev Device assigned the IRQ that was 1684 * dev Device assigned the IRQ that was
1656 * raised. 1685 * raised.
1657 * host_int The contents of the HOST_INT 1686 * host_int The contents of the HOST_INT
1658 * port. 1687 * port.
1659 * 1688 *
1660 * This driver is structured to determine EOC occurrences by 1689 * This driver is structured to determine EOC occurrences by
1661 * reading the CSTAT member of the list structure. Tx EOC 1690 * reading the CSTAT member of the list structure. Tx EOC
1662 * interrupts are disabled via the DIO INTDIS register. 1691 * interrupts are disabled via the DIO INTDIS register.
1663 * However, TLAN chips before revision 3.0 didn't have this 1692 * However, TLAN chips before revision 3.0 didn't have this
1664 * functionality, so process EOC events if this is the 1693 * functionality, so process EOC events if this is the
1665 * case. 1694 * case.
1666 * 1695 *
1667 **************************************************************/ 1696 **************************************************************/
1668 1697
1669static u32 TLan_HandleTxEOC( struct net_device *dev, u16 host_int ) 1698static u32 tlan_handle_tx_eoc(struct net_device *dev, u16 host_int)
1670{ 1699{
1671 TLanPrivateInfo *priv = netdev_priv(dev); 1700 struct tlan_priv *priv = netdev_priv(dev);
1672 TLanList *head_list; 1701 struct tlan_list *head_list;
1673 dma_addr_t head_list_phys; 1702 dma_addr_t head_list_phys;
1674 u32 ack = 1; 1703 u32 ack = 1;
1675 1704
1676 host_int = 0; 1705 host_int = 0;
1677 if ( priv->tlanRev < 0x30 ) { 1706 if (priv->tlan_rev < 0x30) {
1678 TLAN_DBG( TLAN_DEBUG_TX, 1707 TLAN_DBG(TLAN_DEBUG_TX,
1679 "TRANSMIT: Handling TX EOC (Head=%d Tail=%d) -- IRQ\n", 1708 "TRANSMIT: handling TX EOC (Head=%d Tail=%d) -- IRQ\n",
1680 priv->txHead, priv->txTail ); 1709 priv->tx_head, priv->tx_tail);
1681 head_list = priv->txList + priv->txHead; 1710 head_list = priv->tx_list + priv->tx_head;
1682 head_list_phys = priv->txListDMA + sizeof(TLanList) * priv->txHead; 1711 head_list_phys = priv->tx_list_dma
1683 if ( ( head_list->cStat & TLAN_CSTAT_READY ) == TLAN_CSTAT_READY ) { 1712 + sizeof(struct tlan_list)*priv->tx_head;
1713 if (head_list->c_stat & TLAN_CSTAT_READY) {
1684 netif_stop_queue(dev); 1714 netif_stop_queue(dev);
1685 outl( head_list_phys, dev->base_addr + TLAN_CH_PARM ); 1715 outl(head_list_phys, dev->base_addr + TLAN_CH_PARM);
1686 ack |= TLAN_HC_GO; 1716 ack |= TLAN_HC_GO;
1687 } else { 1717 } else {
1688 priv->txInProgress = 0; 1718 priv->tx_in_progress = 0;
1689 } 1719 }
1690 } 1720 }
1691 1721
1692 return ack; 1722 return ack;
1693 1723
1694} /* TLan_HandleTxEOC */ 1724}
1695 1725
1696 1726
1697 1727
1698 1728
1699 /*************************************************************** 1729/***************************************************************
1700 * TLan_HandleStatusCheck 1730 * tlan_handle_status_check
1701 * 1731 *
1702 * Returns: 1732 * Returns:
1703 * 0 if Adapter check, 1 if Network Status check. 1733 * 0 if Adapter check, 1 if Network Status check.
1704 * Parms: 1734 * Parms:
1705 * dev Device assigned the IRQ that was 1735 * dev Device assigned the IRQ that was
1706 * raised. 1736 * raised.
1707 * host_int The contents of the HOST_INT 1737 * host_int The contents of the HOST_INT
1708 * port. 1738 * port.
1709 * 1739 *
1710 * This function handles Adapter Check/Network Status 1740 * This function handles Adapter Check/Network Status
1711 * interrupts generated by the adapter. It checks the 1741 * interrupts generated by the adapter. It checks the
1712 * vector in the HOST_INT register to determine if it is 1742 * vector in the HOST_INT register to determine if it is
1713 * an Adapter Check interrupt. If so, it resets the 1743 * an Adapter Check interrupt. If so, it resets the
1714 * adapter. Otherwise it clears the status registers 1744 * adapter. Otherwise it clears the status registers
1715 * and services the PHY. 1745 * and services the PHY.
1716 * 1746 *
1717 **************************************************************/ 1747 **************************************************************/
1718 1748
1719static u32 TLan_HandleStatusCheck( struct net_device *dev, u16 host_int ) 1749static u32 tlan_handle_status_check(struct net_device *dev, u16 host_int)
1720{ 1750{
1721 TLanPrivateInfo *priv = netdev_priv(dev); 1751 struct tlan_priv *priv = netdev_priv(dev);
1722 u32 ack; 1752 u32 ack;
1723 u32 error; 1753 u32 error;
1724 u8 net_sts; 1754 u8 net_sts;
@@ -1727,92 +1757,94 @@ static u32 TLan_HandleStatusCheck( struct net_device *dev, u16 host_int )
1727 u16 tlphy_sts; 1757 u16 tlphy_sts;
1728 1758
1729 ack = 1; 1759 ack = 1;
1730 if ( host_int & TLAN_HI_IV_MASK ) { 1760 if (host_int & TLAN_HI_IV_MASK) {
1731 netif_stop_queue( dev ); 1761 netif_stop_queue(dev);
1732 error = inl( dev->base_addr + TLAN_CH_PARM ); 1762 error = inl(dev->base_addr + TLAN_CH_PARM);
1733 printk( "TLAN: %s: Adaptor Error = 0x%x\n", dev->name, error ); 1763 pr_info("TLAN: %s: Adaptor Error = 0x%x\n", dev->name, error);
1734 TLan_ReadAndClearStats( dev, TLAN_RECORD ); 1764 tlan_read_and_clear_stats(dev, TLAN_RECORD);
1735 outl( TLAN_HC_AD_RST, dev->base_addr + TLAN_HOST_CMD ); 1765 outl(TLAN_HC_AD_RST, dev->base_addr + TLAN_HOST_CMD);
1736 1766
1737 schedule_work(&priv->tlan_tqueue); 1767 schedule_work(&priv->tlan_tqueue);
1738 1768
1739 netif_wake_queue(dev); 1769 netif_wake_queue(dev);
1740 ack = 0; 1770 ack = 0;
1741 } else { 1771 } else {
1742 TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Status Check\n", dev->name ); 1772 TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Status Check\n", dev->name);
1743 phy = priv->phy[priv->phyNum]; 1773 phy = priv->phy[priv->phy_num];
1744 1774
1745 net_sts = TLan_DioRead8( dev->base_addr, TLAN_NET_STS ); 1775 net_sts = tlan_dio_read8(dev->base_addr, TLAN_NET_STS);
1746 if ( net_sts ) { 1776 if (net_sts) {
1747 TLan_DioWrite8( dev->base_addr, TLAN_NET_STS, net_sts ); 1777 tlan_dio_write8(dev->base_addr, TLAN_NET_STS, net_sts);
1748 TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Net_Sts = %x\n", 1778 TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Net_Sts = %x\n",
1749 dev->name, (unsigned) net_sts ); 1779 dev->name, (unsigned) net_sts);
1750 } 1780 }
1751 if ( ( net_sts & TLAN_NET_STS_MIRQ ) && ( priv->phyNum == 0 ) ) { 1781 if ((net_sts & TLAN_NET_STS_MIRQ) && (priv->phy_num == 0)) {
1752 TLan_MiiReadReg( dev, phy, TLAN_TLPHY_STS, &tlphy_sts ); 1782 tlan_mii_read_reg(dev, phy, TLAN_TLPHY_STS, &tlphy_sts);
1753 TLan_MiiReadReg( dev, phy, TLAN_TLPHY_CTL, &tlphy_ctl ); 1783 tlan_mii_read_reg(dev, phy, TLAN_TLPHY_CTL, &tlphy_ctl);
1754 if ( ! ( tlphy_sts & TLAN_TS_POLOK ) && 1784 if (!(tlphy_sts & TLAN_TS_POLOK) &&
1755 ! ( tlphy_ctl & TLAN_TC_SWAPOL ) ) { 1785 !(tlphy_ctl & TLAN_TC_SWAPOL)) {
1756 tlphy_ctl |= TLAN_TC_SWAPOL; 1786 tlphy_ctl |= TLAN_TC_SWAPOL;
1757 TLan_MiiWriteReg( dev, phy, TLAN_TLPHY_CTL, tlphy_ctl); 1787 tlan_mii_write_reg(dev, phy, TLAN_TLPHY_CTL,
1758 } else if ( ( tlphy_sts & TLAN_TS_POLOK ) && 1788 tlphy_ctl);
1759 ( tlphy_ctl & TLAN_TC_SWAPOL ) ) { 1789 } else if ((tlphy_sts & TLAN_TS_POLOK) &&
1760 tlphy_ctl &= ~TLAN_TC_SWAPOL; 1790 (tlphy_ctl & TLAN_TC_SWAPOL)) {
1761 TLan_MiiWriteReg( dev, phy, TLAN_TLPHY_CTL, tlphy_ctl); 1791 tlphy_ctl &= ~TLAN_TC_SWAPOL;
1762 } 1792 tlan_mii_write_reg(dev, phy, TLAN_TLPHY_CTL,
1763 1793 tlphy_ctl);
1764 if (debug) {
1765 TLan_PhyPrint( dev );
1766 } 1794 }
1795
1796 if (debug)
1797 tlan_phy_print(dev);
1767 } 1798 }
1768 } 1799 }
1769 1800
1770 return ack; 1801 return ack;
1771 1802
1772} /* TLan_HandleStatusCheck */ 1803}
1773 1804
1774 1805
1775 1806
1776 1807
1777 /*************************************************************** 1808/***************************************************************
1778 * TLan_HandleRxEOC 1809 * tlan_handle_rx_eoc
1779 * 1810 *
1780 * Returns: 1811 * Returns:
1781 * 1 1812 * 1
1782 * Parms: 1813 * Parms:
1783 * dev Device assigned the IRQ that was 1814 * dev Device assigned the IRQ that was
1784 * raised. 1815 * raised.
1785 * host_int The contents of the HOST_INT 1816 * host_int The contents of the HOST_INT
1786 * port. 1817 * port.
1787 * 1818 *
1788 * This driver is structured to determine EOC occurrences by 1819 * This driver is structured to determine EOC occurrences by
1789 * reading the CSTAT member of the list structure. Rx EOC 1820 * reading the CSTAT member of the list structure. Rx EOC
1790 * interrupts are disabled via the DIO INTDIS register. 1821 * interrupts are disabled via the DIO INTDIS register.
1791 * However, TLAN chips before revision 3.0 didn't have this 1822 * However, TLAN chips before revision 3.0 didn't have this
1792 * CSTAT member or a INTDIS register, so if this chip is 1823 * CSTAT member or a INTDIS register, so if this chip is
1793 * pre-3.0, process EOC interrupts normally. 1824 * pre-3.0, process EOC interrupts normally.
1794 * 1825 *
1795 **************************************************************/ 1826 **************************************************************/
1796 1827
1797static u32 TLan_HandleRxEOC( struct net_device *dev, u16 host_int ) 1828static u32 tlan_handle_rx_eoc(struct net_device *dev, u16 host_int)
1798{ 1829{
1799 TLanPrivateInfo *priv = netdev_priv(dev); 1830 struct tlan_priv *priv = netdev_priv(dev);
1800 dma_addr_t head_list_phys; 1831 dma_addr_t head_list_phys;
1801 u32 ack = 1; 1832 u32 ack = 1;
1802 1833
1803 if ( priv->tlanRev < 0x30 ) { 1834 if (priv->tlan_rev < 0x30) {
1804 TLAN_DBG( TLAN_DEBUG_RX, 1835 TLAN_DBG(TLAN_DEBUG_RX,
1805 "RECEIVE: Handling RX EOC (Head=%d Tail=%d) -- IRQ\n", 1836 "RECEIVE: Handling RX EOC (head=%d tail=%d) -- IRQ\n",
1806 priv->rxHead, priv->rxTail ); 1837 priv->rx_head, priv->rx_tail);
1807 head_list_phys = priv->rxListDMA + sizeof(TLanList) * priv->rxHead; 1838 head_list_phys = priv->rx_list_dma
1808 outl( head_list_phys, dev->base_addr + TLAN_CH_PARM ); 1839 + sizeof(struct tlan_list)*priv->rx_head;
1840 outl(head_list_phys, dev->base_addr + TLAN_CH_PARM);
1809 ack |= TLAN_HC_GO | TLAN_HC_RT; 1841 ack |= TLAN_HC_GO | TLAN_HC_RT;
1810 priv->rxEocCount++; 1842 priv->rx_eoc_count++;
1811 } 1843 }
1812 1844
1813 return ack; 1845 return ack;
1814 1846
1815} /* TLan_HandleRxEOC */ 1847}
1816 1848
1817 1849
1818 1850
@@ -1820,98 +1852,98 @@ static u32 TLan_HandleRxEOC( struct net_device *dev, u16 host_int )
1820/***************************************************************************** 1852/*****************************************************************************
1821****************************************************************************** 1853******************************************************************************
1822 1854
1823 ThunderLAN Driver Timer Function 1855ThunderLAN driver timer function
1824 1856
1825****************************************************************************** 1857******************************************************************************
1826*****************************************************************************/ 1858*****************************************************************************/
1827 1859
1828 1860
1829 /*************************************************************** 1861/***************************************************************
1830 * TLan_Timer 1862 * tlan_timer
1831 * 1863 *
1832 * Returns: 1864 * Returns:
1833 * Nothing 1865 * Nothing
1834 * Parms: 1866 * Parms:
1835 * data A value given to add timer when 1867 * data A value given to add timer when
1836 * add_timer was called. 1868 * add_timer was called.
1837 * 1869 *
1838 * This function handles timed functionality for the 1870 * This function handles timed functionality for the
1839 * TLAN driver. The two current timer uses are for 1871 * TLAN driver. The two current timer uses are for
1840 * delaying for autonegotionation and driving the ACT LED. 1872 * delaying for autonegotionation and driving the ACT LED.
1841 * - Autonegotiation requires being allowed about 1873 * - Autonegotiation requires being allowed about
1842 * 2 1/2 seconds before attempting to transmit a 1874 * 2 1/2 seconds before attempting to transmit a
1843 * packet. It would be a very bad thing to hang 1875 * packet. It would be a very bad thing to hang
1844 * the kernel this long, so the driver doesn't 1876 * the kernel this long, so the driver doesn't
1845 * allow transmission 'til after this time, for 1877 * allow transmission 'til after this time, for
1846 * certain PHYs. It would be much nicer if all 1878 * certain PHYs. It would be much nicer if all
1847 * PHYs were interrupt-capable like the internal 1879 * PHYs were interrupt-capable like the internal
1848 * PHY. 1880 * PHY.
1849 * - The ACT LED, which shows adapter activity, is 1881 * - The ACT LED, which shows adapter activity, is
1850 * driven by the driver, and so must be left on 1882 * driven by the driver, and so must be left on
1851 * for a short period to power up the LED so it 1883 * for a short period to power up the LED so it
1852 * can be seen. This delay can be changed by 1884 * can be seen. This delay can be changed by
1853 * changing the TLAN_TIMER_ACT_DELAY in tlan.h, 1885 * changing the TLAN_TIMER_ACT_DELAY in tlan.h,
1854 * if desired. 100 ms produces a slightly 1886 * if desired. 100 ms produces a slightly
1855 * sluggish response. 1887 * sluggish response.
1856 * 1888 *
1857 **************************************************************/ 1889 **************************************************************/
1858 1890
1859static void TLan_Timer( unsigned long data ) 1891static void tlan_timer(unsigned long data)
1860{ 1892{
1861 struct net_device *dev = (struct net_device *) data; 1893 struct net_device *dev = (struct net_device *) data;
1862 TLanPrivateInfo *priv = netdev_priv(dev); 1894 struct tlan_priv *priv = netdev_priv(dev);
1863 u32 elapsed; 1895 u32 elapsed;
1864 unsigned long flags = 0; 1896 unsigned long flags = 0;
1865 1897
1866 priv->timer.function = NULL; 1898 priv->timer.function = NULL;
1867 1899
1868 switch ( priv->timerType ) { 1900 switch (priv->timer_type) {
1869#ifdef MONITOR 1901#ifdef MONITOR
1870 case TLAN_TIMER_LINK_BEAT: 1902 case TLAN_TIMER_LINK_BEAT:
1871 TLan_PhyMonitor( dev ); 1903 tlan_phy_monitor(dev);
1872 break; 1904 break;
1873#endif 1905#endif
1874 case TLAN_TIMER_PHY_PDOWN: 1906 case TLAN_TIMER_PHY_PDOWN:
1875 TLan_PhyPowerDown( dev ); 1907 tlan_phy_power_down(dev);
1876 break; 1908 break;
1877 case TLAN_TIMER_PHY_PUP: 1909 case TLAN_TIMER_PHY_PUP:
1878 TLan_PhyPowerUp( dev ); 1910 tlan_phy_power_up(dev);
1879 break; 1911 break;
1880 case TLAN_TIMER_PHY_RESET: 1912 case TLAN_TIMER_PHY_RESET:
1881 TLan_PhyReset( dev ); 1913 tlan_phy_reset(dev);
1882 break; 1914 break;
1883 case TLAN_TIMER_PHY_START_LINK: 1915 case TLAN_TIMER_PHY_START_LINK:
1884 TLan_PhyStartLink( dev ); 1916 tlan_phy_start_link(dev);
1885 break; 1917 break;
1886 case TLAN_TIMER_PHY_FINISH_AN: 1918 case TLAN_TIMER_PHY_FINISH_AN:
1887 TLan_PhyFinishAutoNeg( dev ); 1919 tlan_phy_finish_auto_neg(dev);
1888 break; 1920 break;
1889 case TLAN_TIMER_FINISH_RESET: 1921 case TLAN_TIMER_FINISH_RESET:
1890 TLan_FinishReset( dev ); 1922 tlan_finish_reset(dev);
1891 break; 1923 break;
1892 case TLAN_TIMER_ACTIVITY: 1924 case TLAN_TIMER_ACTIVITY:
1893 spin_lock_irqsave(&priv->lock, flags); 1925 spin_lock_irqsave(&priv->lock, flags);
1894 if ( priv->timer.function == NULL ) { 1926 if (priv->timer.function == NULL) {
1895 elapsed = jiffies - priv->timerSetAt; 1927 elapsed = jiffies - priv->timer_set_at;
1896 if ( elapsed >= TLAN_TIMER_ACT_DELAY ) { 1928 if (elapsed >= TLAN_TIMER_ACT_DELAY) {
1897 TLan_DioWrite8( dev->base_addr, 1929 tlan_dio_write8(dev->base_addr,
1898 TLAN_LED_REG, TLAN_LED_LINK ); 1930 TLAN_LED_REG, TLAN_LED_LINK);
1899 } else { 1931 } else {
1900 priv->timer.function = TLan_Timer; 1932 priv->timer.function = tlan_timer;
1901 priv->timer.expires = priv->timerSetAt 1933 priv->timer.expires = priv->timer_set_at
1902 + TLAN_TIMER_ACT_DELAY; 1934 + TLAN_TIMER_ACT_DELAY;
1903 spin_unlock_irqrestore(&priv->lock, flags); 1935 spin_unlock_irqrestore(&priv->lock, flags);
1904 add_timer( &priv->timer ); 1936 add_timer(&priv->timer);
1905 break; 1937 break;
1906 }
1907 } 1938 }
1908 spin_unlock_irqrestore(&priv->lock, flags); 1939 }
1909 break; 1940 spin_unlock_irqrestore(&priv->lock, flags);
1910 default: 1941 break;
1911 break; 1942 default:
1943 break;
1912 } 1944 }
1913 1945
1914} /* TLan_Timer */ 1946}
1915 1947
1916 1948
1917 1949
@@ -1919,39 +1951,39 @@ static void TLan_Timer( unsigned long data )
1919/***************************************************************************** 1951/*****************************************************************************
1920****************************************************************************** 1952******************************************************************************
1921 1953
1922 ThunderLAN Driver Adapter Related Routines 1954ThunderLAN driver adapter related routines
1923 1955
1924****************************************************************************** 1956******************************************************************************
1925*****************************************************************************/ 1957*****************************************************************************/
1926 1958
1927 1959
1928 /*************************************************************** 1960/***************************************************************
1929 * TLan_ResetLists 1961 * tlan_reset_lists
1930 * 1962 *
1931 * Returns: 1963 * Returns:
1932 * Nothing 1964 * Nothing
1933 * Parms: 1965 * Parms:
1934 * dev The device structure with the list 1966 * dev The device structure with the list
1935 * stuctures to be reset. 1967 * stuctures to be reset.
1936 * 1968 *
1937 * This routine sets the variables associated with managing 1969 * This routine sets the variables associated with managing
1938 * the TLAN lists to their initial values. 1970 * the TLAN lists to their initial values.
1939 * 1971 *
1940 **************************************************************/ 1972 **************************************************************/
1941 1973
1942static void TLan_ResetLists( struct net_device *dev ) 1974static void tlan_reset_lists(struct net_device *dev)
1943{ 1975{
1944 TLanPrivateInfo *priv = netdev_priv(dev); 1976 struct tlan_priv *priv = netdev_priv(dev);
1945 int i; 1977 int i;
1946 TLanList *list; 1978 struct tlan_list *list;
1947 dma_addr_t list_phys; 1979 dma_addr_t list_phys;
1948 struct sk_buff *skb; 1980 struct sk_buff *skb;
1949 1981
1950 priv->txHead = 0; 1982 priv->tx_head = 0;
1951 priv->txTail = 0; 1983 priv->tx_tail = 0;
1952 for ( i = 0; i < TLAN_NUM_TX_LISTS; i++ ) { 1984 for (i = 0; i < TLAN_NUM_TX_LISTS; i++) {
1953 list = priv->txList + i; 1985 list = priv->tx_list + i;
1954 list->cStat = TLAN_CSTAT_UNUSED; 1986 list->c_stat = TLAN_CSTAT_UNUSED;
1955 list->buffer[0].address = 0; 1987 list->buffer[0].address = 0;
1956 list->buffer[2].count = 0; 1988 list->buffer[2].count = 0;
1957 list->buffer[2].address = 0; 1989 list->buffer[2].address = 0;
@@ -1959,169 +1991,169 @@ static void TLan_ResetLists( struct net_device *dev )
1959 list->buffer[9].address = 0; 1991 list->buffer[9].address = 0;
1960 } 1992 }
1961 1993
1962 priv->rxHead = 0; 1994 priv->rx_head = 0;
1963 priv->rxTail = TLAN_NUM_RX_LISTS - 1; 1995 priv->rx_tail = TLAN_NUM_RX_LISTS - 1;
1964 for ( i = 0; i < TLAN_NUM_RX_LISTS; i++ ) { 1996 for (i = 0; i < TLAN_NUM_RX_LISTS; i++) {
1965 list = priv->rxList + i; 1997 list = priv->rx_list + i;
1966 list_phys = priv->rxListDMA + sizeof(TLanList) * i; 1998 list_phys = priv->rx_list_dma + sizeof(struct tlan_list)*i;
1967 list->cStat = TLAN_CSTAT_READY; 1999 list->c_stat = TLAN_CSTAT_READY;
1968 list->frameSize = TLAN_MAX_FRAME_SIZE; 2000 list->frame_size = TLAN_MAX_FRAME_SIZE;
1969 list->buffer[0].count = TLAN_MAX_FRAME_SIZE | TLAN_LAST_BUFFER; 2001 list->buffer[0].count = TLAN_MAX_FRAME_SIZE | TLAN_LAST_BUFFER;
1970 skb = netdev_alloc_skb_ip_align(dev, TLAN_MAX_FRAME_SIZE + 5); 2002 skb = netdev_alloc_skb_ip_align(dev, TLAN_MAX_FRAME_SIZE + 5);
1971 if ( !skb ) { 2003 if (!skb) {
1972 pr_err("TLAN: out of memory for received data.\n" ); 2004 pr_err("TLAN: out of memory for received data.\n");
1973 break; 2005 break;
1974 } 2006 }
1975 2007
1976 list->buffer[0].address = pci_map_single(priv->pciDev, 2008 list->buffer[0].address = pci_map_single(priv->pci_dev,
1977 skb->data, 2009 skb->data,
1978 TLAN_MAX_FRAME_SIZE, 2010 TLAN_MAX_FRAME_SIZE,
1979 PCI_DMA_FROMDEVICE); 2011 PCI_DMA_FROMDEVICE);
1980 TLan_StoreSKB(list, skb); 2012 tlan_store_skb(list, skb);
1981 list->buffer[1].count = 0; 2013 list->buffer[1].count = 0;
1982 list->buffer[1].address = 0; 2014 list->buffer[1].address = 0;
1983 list->forward = list_phys + sizeof(TLanList); 2015 list->forward = list_phys + sizeof(struct tlan_list);
1984 } 2016 }
1985 2017
1986 /* in case ran out of memory early, clear bits */ 2018 /* in case ran out of memory early, clear bits */
1987 while (i < TLAN_NUM_RX_LISTS) { 2019 while (i < TLAN_NUM_RX_LISTS) {
1988 TLan_StoreSKB(priv->rxList + i, NULL); 2020 tlan_store_skb(priv->rx_list + i, NULL);
1989 ++i; 2021 ++i;
1990 } 2022 }
1991 list->forward = 0; 2023 list->forward = 0;
1992 2024
1993} /* TLan_ResetLists */ 2025}
1994 2026
1995 2027
1996static void TLan_FreeLists( struct net_device *dev ) 2028static void tlan_free_lists(struct net_device *dev)
1997{ 2029{
1998 TLanPrivateInfo *priv = netdev_priv(dev); 2030 struct tlan_priv *priv = netdev_priv(dev);
1999 int i; 2031 int i;
2000 TLanList *list; 2032 struct tlan_list *list;
2001 struct sk_buff *skb; 2033 struct sk_buff *skb;
2002 2034
2003 for ( i = 0; i < TLAN_NUM_TX_LISTS; i++ ) { 2035 for (i = 0; i < TLAN_NUM_TX_LISTS; i++) {
2004 list = priv->txList + i; 2036 list = priv->tx_list + i;
2005 skb = TLan_GetSKB(list); 2037 skb = tlan_get_skb(list);
2006 if ( skb ) { 2038 if (skb) {
2007 pci_unmap_single( 2039 pci_unmap_single(
2008 priv->pciDev, 2040 priv->pci_dev,
2009 list->buffer[0].address, 2041 list->buffer[0].address,
2010 max(skb->len, 2042 max(skb->len,
2011 (unsigned int)TLAN_MIN_FRAME_SIZE), 2043 (unsigned int)TLAN_MIN_FRAME_SIZE),
2012 PCI_DMA_TODEVICE); 2044 PCI_DMA_TODEVICE);
2013 dev_kfree_skb_any( skb ); 2045 dev_kfree_skb_any(skb);
2014 list->buffer[8].address = 0; 2046 list->buffer[8].address = 0;
2015 list->buffer[9].address = 0; 2047 list->buffer[9].address = 0;
2016 } 2048 }
2017 } 2049 }
2018 2050
2019 for ( i = 0; i < TLAN_NUM_RX_LISTS; i++ ) { 2051 for (i = 0; i < TLAN_NUM_RX_LISTS; i++) {
2020 list = priv->rxList + i; 2052 list = priv->rx_list + i;
2021 skb = TLan_GetSKB(list); 2053 skb = tlan_get_skb(list);
2022 if ( skb ) { 2054 if (skb) {
2023 pci_unmap_single(priv->pciDev, 2055 pci_unmap_single(priv->pci_dev,
2024 list->buffer[0].address, 2056 list->buffer[0].address,
2025 TLAN_MAX_FRAME_SIZE, 2057 TLAN_MAX_FRAME_SIZE,
2026 PCI_DMA_FROMDEVICE); 2058 PCI_DMA_FROMDEVICE);
2027 dev_kfree_skb_any( skb ); 2059 dev_kfree_skb_any(skb);
2028 list->buffer[8].address = 0; 2060 list->buffer[8].address = 0;
2029 list->buffer[9].address = 0; 2061 list->buffer[9].address = 0;
2030 } 2062 }
2031 } 2063 }
2032} /* TLan_FreeLists */ 2064}
2033 2065
2034 2066
2035 2067
2036 2068
2037 /*************************************************************** 2069/***************************************************************
2038 * TLan_PrintDio 2070 * tlan_print_dio
2039 * 2071 *
2040 * Returns: 2072 * Returns:
2041 * Nothing 2073 * Nothing
2042 * Parms: 2074 * Parms:
2043 * io_base Base IO port of the device of 2075 * io_base Base IO port of the device of
2044 * which to print DIO registers. 2076 * which to print DIO registers.
2045 * 2077 *
2046 * This function prints out all the internal (DIO) 2078 * This function prints out all the internal (DIO)
2047 * registers of a TLAN chip. 2079 * registers of a TLAN chip.
2048 * 2080 *
2049 **************************************************************/ 2081 **************************************************************/
2050 2082
2051static void TLan_PrintDio( u16 io_base ) 2083static void tlan_print_dio(u16 io_base)
2052{ 2084{
2053 u32 data0, data1; 2085 u32 data0, data1;
2054 int i; 2086 int i;
2055 2087
2056 printk( "TLAN: Contents of internal registers for io base 0x%04hx.\n", 2088 pr_info("TLAN: Contents of internal registers for io base 0x%04hx.\n",
2057 io_base ); 2089 io_base);
2058 printk( "TLAN: Off. +0 +4\n" ); 2090 pr_info("TLAN: Off. +0 +4\n");
2059 for ( i = 0; i < 0x4C; i+= 8 ) { 2091 for (i = 0; i < 0x4C; i += 8) {
2060 data0 = TLan_DioRead32( io_base, i ); 2092 data0 = tlan_dio_read32(io_base, i);
2061 data1 = TLan_DioRead32( io_base, i + 0x4 ); 2093 data1 = tlan_dio_read32(io_base, i + 0x4);
2062 printk( "TLAN: 0x%02x 0x%08x 0x%08x\n", i, data0, data1 ); 2094 pr_info("TLAN: 0x%02x 0x%08x 0x%08x\n", i, data0, data1);
2063 } 2095 }
2064 2096
2065} /* TLan_PrintDio */ 2097}
2066 2098
2067 2099
2068 2100
2069 2101
2070 /*************************************************************** 2102/***************************************************************
2071 * TLan_PrintList 2103 * TLan_PrintList
2072 * 2104 *
2073 * Returns: 2105 * Returns:
2074 * Nothing 2106 * Nothing
2075 * Parms: 2107 * Parms:
2076 * list A pointer to the TLanList structure to 2108 * list A pointer to the struct tlan_list structure to
2077 * be printed. 2109 * be printed.
2078 * type A string to designate type of list, 2110 * type A string to designate type of list,
2079 * "Rx" or "Tx". 2111 * "Rx" or "Tx".
2080 * num The index of the list. 2112 * num The index of the list.
2081 * 2113 *
2082 * This function prints out the contents of the list 2114 * This function prints out the contents of the list
2083 * pointed to by the list parameter. 2115 * pointed to by the list parameter.
2084 * 2116 *
2085 **************************************************************/ 2117 **************************************************************/
2086 2118
2087static void TLan_PrintList( TLanList *list, char *type, int num) 2119static void tlan_print_list(struct tlan_list *list, char *type, int num)
2088{ 2120{
2089 int i; 2121 int i;
2090 2122
2091 printk( "TLAN: %s List %d at %p\n", type, num, list ); 2123 pr_info("TLAN: %s List %d at %p\n", type, num, list);
2092 printk( "TLAN: Forward = 0x%08x\n", list->forward ); 2124 pr_info("TLAN: Forward = 0x%08x\n", list->forward);
2093 printk( "TLAN: CSTAT = 0x%04hx\n", list->cStat ); 2125 pr_info("TLAN: CSTAT = 0x%04hx\n", list->c_stat);
2094 printk( "TLAN: Frame Size = 0x%04hx\n", list->frameSize ); 2126 pr_info("TLAN: Frame Size = 0x%04hx\n", list->frame_size);
2095 /* for ( i = 0; i < 10; i++ ) { */ 2127 /* for (i = 0; i < 10; i++) { */
2096 for ( i = 0; i < 2; i++ ) { 2128 for (i = 0; i < 2; i++) {
2097 printk( "TLAN: Buffer[%d].count, addr = 0x%08x, 0x%08x\n", 2129 pr_info("TLAN: Buffer[%d].count, addr = 0x%08x, 0x%08x\n",
2098 i, list->buffer[i].count, list->buffer[i].address ); 2130 i, list->buffer[i].count, list->buffer[i].address);
2099 } 2131 }
2100 2132
2101} /* TLan_PrintList */ 2133}
2102 2134
2103 2135
2104 2136
2105 2137
2106 /*************************************************************** 2138/***************************************************************
2107 * TLan_ReadAndClearStats 2139 * tlan_read_and_clear_stats
2108 * 2140 *
2109 * Returns: 2141 * Returns:
2110 * Nothing 2142 * Nothing
2111 * Parms: 2143 * Parms:
2112 * dev Pointer to device structure of adapter 2144 * dev Pointer to device structure of adapter
2113 * to which to read stats. 2145 * to which to read stats.
2114 * record Flag indicating whether to add 2146 * record Flag indicating whether to add
2115 * 2147 *
2116 * This functions reads all the internal status registers 2148 * This functions reads all the internal status registers
2117 * of the TLAN chip, which clears them as a side effect. 2149 * of the TLAN chip, which clears them as a side effect.
2118 * It then either adds the values to the device's status 2150 * It then either adds the values to the device's status
2119 * struct, or discards them, depending on whether record 2151 * struct, or discards them, depending on whether record
2120 * is TLAN_RECORD (!=0) or TLAN_IGNORE (==0). 2152 * is TLAN_RECORD (!=0) or TLAN_IGNORE (==0).
2121 * 2153 *
2122 **************************************************************/ 2154 **************************************************************/
2123 2155
2124static void TLan_ReadAndClearStats( struct net_device *dev, int record ) 2156static void tlan_read_and_clear_stats(struct net_device *dev, int record)
2125{ 2157{
2126 u32 tx_good, tx_under; 2158 u32 tx_good, tx_under;
2127 u32 rx_good, rx_over; 2159 u32 rx_good, rx_over;
@@ -2129,41 +2161,42 @@ static void TLan_ReadAndClearStats( struct net_device *dev, int record )
2129 u32 multi_col, single_col; 2161 u32 multi_col, single_col;
2130 u32 excess_col, late_col, loss; 2162 u32 excess_col, late_col, loss;
2131 2163
2132 outw( TLAN_GOOD_TX_FRMS, dev->base_addr + TLAN_DIO_ADR ); 2164 outw(TLAN_GOOD_TX_FRMS, dev->base_addr + TLAN_DIO_ADR);
2133 tx_good = inb( dev->base_addr + TLAN_DIO_DATA ); 2165 tx_good = inb(dev->base_addr + TLAN_DIO_DATA);
2134 tx_good += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8; 2166 tx_good += inb(dev->base_addr + TLAN_DIO_DATA + 1) << 8;
2135 tx_good += inb( dev->base_addr + TLAN_DIO_DATA + 2 ) << 16; 2167 tx_good += inb(dev->base_addr + TLAN_DIO_DATA + 2) << 16;
2136 tx_under = inb( dev->base_addr + TLAN_DIO_DATA + 3 ); 2168 tx_under = inb(dev->base_addr + TLAN_DIO_DATA + 3);
2137 2169
2138 outw( TLAN_GOOD_RX_FRMS, dev->base_addr + TLAN_DIO_ADR ); 2170 outw(TLAN_GOOD_RX_FRMS, dev->base_addr + TLAN_DIO_ADR);
2139 rx_good = inb( dev->base_addr + TLAN_DIO_DATA ); 2171 rx_good = inb(dev->base_addr + TLAN_DIO_DATA);
2140 rx_good += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8; 2172 rx_good += inb(dev->base_addr + TLAN_DIO_DATA + 1) << 8;
2141 rx_good += inb( dev->base_addr + TLAN_DIO_DATA + 2 ) << 16; 2173 rx_good += inb(dev->base_addr + TLAN_DIO_DATA + 2) << 16;
2142 rx_over = inb( dev->base_addr + TLAN_DIO_DATA + 3 ); 2174 rx_over = inb(dev->base_addr + TLAN_DIO_DATA + 3);
2143 2175
2144 outw( TLAN_DEFERRED_TX, dev->base_addr + TLAN_DIO_ADR ); 2176 outw(TLAN_DEFERRED_TX, dev->base_addr + TLAN_DIO_ADR);
2145 def_tx = inb( dev->base_addr + TLAN_DIO_DATA ); 2177 def_tx = inb(dev->base_addr + TLAN_DIO_DATA);
2146 def_tx += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8; 2178 def_tx += inb(dev->base_addr + TLAN_DIO_DATA + 1) << 8;
2147 crc = inb( dev->base_addr + TLAN_DIO_DATA + 2 ); 2179 crc = inb(dev->base_addr + TLAN_DIO_DATA + 2);
2148 code = inb( dev->base_addr + TLAN_DIO_DATA + 3 ); 2180 code = inb(dev->base_addr + TLAN_DIO_DATA + 3);
2149 2181
2150 outw( TLAN_MULTICOL_FRMS, dev->base_addr + TLAN_DIO_ADR ); 2182 outw(TLAN_MULTICOL_FRMS, dev->base_addr + TLAN_DIO_ADR);
2151 multi_col = inb( dev->base_addr + TLAN_DIO_DATA ); 2183 multi_col = inb(dev->base_addr + TLAN_DIO_DATA);
2152 multi_col += inb( dev->base_addr + TLAN_DIO_DATA + 1 ) << 8; 2184 multi_col += inb(dev->base_addr + TLAN_DIO_DATA + 1) << 8;
2153 single_col = inb( dev->base_addr + TLAN_DIO_DATA + 2 ); 2185 single_col = inb(dev->base_addr + TLAN_DIO_DATA + 2);
2154 single_col += inb( dev->base_addr + TLAN_DIO_DATA + 3 ) << 8; 2186 single_col += inb(dev->base_addr + TLAN_DIO_DATA + 3) << 8;
2155 2187
2156 outw( TLAN_EXCESSCOL_FRMS, dev->base_addr + TLAN_DIO_ADR ); 2188 outw(TLAN_EXCESSCOL_FRMS, dev->base_addr + TLAN_DIO_ADR);
2157 excess_col = inb( dev->base_addr + TLAN_DIO_DATA ); 2189 excess_col = inb(dev->base_addr + TLAN_DIO_DATA);
2158 late_col = inb( dev->base_addr + TLAN_DIO_DATA + 1 ); 2190 late_col = inb(dev->base_addr + TLAN_DIO_DATA + 1);
2159 loss = inb( dev->base_addr + TLAN_DIO_DATA + 2 ); 2191 loss = inb(dev->base_addr + TLAN_DIO_DATA + 2);
2160 2192
2161 if ( record ) { 2193 if (record) {
2162 dev->stats.rx_packets += rx_good; 2194 dev->stats.rx_packets += rx_good;
2163 dev->stats.rx_errors += rx_over + crc + code; 2195 dev->stats.rx_errors += rx_over + crc + code;
2164 dev->stats.tx_packets += tx_good; 2196 dev->stats.tx_packets += tx_good;
2165 dev->stats.tx_errors += tx_under + loss; 2197 dev->stats.tx_errors += tx_under + loss;
2166 dev->stats.collisions += multi_col + single_col + excess_col + late_col; 2198 dev->stats.collisions += multi_col
2199 + single_col + excess_col + late_col;
2167 2200
2168 dev->stats.rx_over_errors += rx_over; 2201 dev->stats.rx_over_errors += rx_over;
2169 dev->stats.rx_crc_errors += crc; 2202 dev->stats.rx_crc_errors += crc;
@@ -2173,39 +2206,39 @@ static void TLan_ReadAndClearStats( struct net_device *dev, int record )
2173 dev->stats.tx_carrier_errors += loss; 2206 dev->stats.tx_carrier_errors += loss;
2174 } 2207 }
2175 2208
2176} /* TLan_ReadAndClearStats */ 2209}
2177 2210
2178 2211
2179 2212
2180 2213
2181 /*************************************************************** 2214/***************************************************************
2182 * TLan_Reset 2215 * TLan_Reset
2183 * 2216 *
2184 * Returns: 2217 * Returns:
2185 * 0 2218 * 0
2186 * Parms: 2219 * Parms:
2187 * dev Pointer to device structure of adapter 2220 * dev Pointer to device structure of adapter
2188 * to be reset. 2221 * to be reset.
2189 * 2222 *
2190 * This function resets the adapter and it's physical 2223 * This function resets the adapter and it's physical
2191 * device. See Chap. 3, pp. 9-10 of the "ThunderLAN 2224 * device. See Chap. 3, pp. 9-10 of the "ThunderLAN
2192 * Programmer's Guide" for details. The routine tries to 2225 * Programmer's Guide" for details. The routine tries to
2193 * implement what is detailed there, though adjustments 2226 * implement what is detailed there, though adjustments
2194 * have been made. 2227 * have been made.
2195 * 2228 *
2196 **************************************************************/ 2229 **************************************************************/
2197 2230
2198static void 2231static void
2199TLan_ResetAdapter( struct net_device *dev ) 2232tlan_reset_adapter(struct net_device *dev)
2200{ 2233{
2201 TLanPrivateInfo *priv = netdev_priv(dev); 2234 struct tlan_priv *priv = netdev_priv(dev);
2202 int i; 2235 int i;
2203 u32 addr; 2236 u32 addr;
2204 u32 data; 2237 u32 data;
2205 u8 data8; 2238 u8 data8;
2206 2239
2207 priv->tlanFullDuplex = false; 2240 priv->tlan_full_duplex = false;
2208 priv->phyOnline=0; 2241 priv->phy_online = 0;
2209 netif_carrier_off(dev); 2242 netif_carrier_off(dev);
2210 2243
2211/* 1. Assert reset bit. */ 2244/* 1. Assert reset bit. */
@@ -2216,7 +2249,7 @@ TLan_ResetAdapter( struct net_device *dev )
2216 2249
2217 udelay(1000); 2250 udelay(1000);
2218 2251
2219/* 2. Turn off interrupts. ( Probably isn't necessary ) */ 2252/* 2. Turn off interrupts. (Probably isn't necessary) */
2220 2253
2221 data = inl(dev->base_addr + TLAN_HOST_CMD); 2254 data = inl(dev->base_addr + TLAN_HOST_CMD);
2222 data |= TLAN_HC_INT_OFF; 2255 data |= TLAN_HC_INT_OFF;
@@ -2224,207 +2257,208 @@ TLan_ResetAdapter( struct net_device *dev )
2224 2257
2225/* 3. Clear AREGs and HASHs. */ 2258/* 3. Clear AREGs and HASHs. */
2226 2259
2227 for ( i = TLAN_AREG_0; i <= TLAN_HASH_2; i += 4 ) { 2260 for (i = TLAN_AREG_0; i <= TLAN_HASH_2; i += 4)
2228 TLan_DioWrite32( dev->base_addr, (u16) i, 0 ); 2261 tlan_dio_write32(dev->base_addr, (u16) i, 0);
2229 }
2230 2262
2231/* 4. Setup NetConfig register. */ 2263/* 4. Setup NetConfig register. */
2232 2264
2233 data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN | TLAN_NET_CFG_PHY_EN; 2265 data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN | TLAN_NET_CFG_PHY_EN;
2234 TLan_DioWrite16( dev->base_addr, TLAN_NET_CONFIG, (u16) data ); 2266 tlan_dio_write16(dev->base_addr, TLAN_NET_CONFIG, (u16) data);
2235 2267
2236/* 5. Load Ld_Tmr and Ld_Thr in HOST_CMD. */ 2268/* 5. Load Ld_Tmr and Ld_Thr in HOST_CMD. */
2237 2269
2238 outl( TLAN_HC_LD_TMR | 0x3f, dev->base_addr + TLAN_HOST_CMD ); 2270 outl(TLAN_HC_LD_TMR | 0x3f, dev->base_addr + TLAN_HOST_CMD);
2239 outl( TLAN_HC_LD_THR | 0x9, dev->base_addr + TLAN_HOST_CMD ); 2271 outl(TLAN_HC_LD_THR | 0x9, dev->base_addr + TLAN_HOST_CMD);
2240 2272
2241/* 6. Unreset the MII by setting NMRST (in NetSio) to 1. */ 2273/* 6. Unreset the MII by setting NMRST (in NetSio) to 1. */
2242 2274
2243 outw( TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR ); 2275 outw(TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR);
2244 addr = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO; 2276 addr = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO;
2245 TLan_SetBit( TLAN_NET_SIO_NMRST, addr ); 2277 tlan_set_bit(TLAN_NET_SIO_NMRST, addr);
2246 2278
2247/* 7. Setup the remaining registers. */ 2279/* 7. Setup the remaining registers. */
2248 2280
2249 if ( priv->tlanRev >= 0x30 ) { 2281 if (priv->tlan_rev >= 0x30) {
2250 data8 = TLAN_ID_TX_EOC | TLAN_ID_RX_EOC; 2282 data8 = TLAN_ID_TX_EOC | TLAN_ID_RX_EOC;
2251 TLan_DioWrite8( dev->base_addr, TLAN_INT_DIS, data8 ); 2283 tlan_dio_write8(dev->base_addr, TLAN_INT_DIS, data8);
2252 } 2284 }
2253 TLan_PhyDetect( dev ); 2285 tlan_phy_detect(dev);
2254 data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN; 2286 data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN;
2255 2287
2256 if ( priv->adapter->flags & TLAN_ADAPTER_BIT_RATE_PHY ) { 2288 if (priv->adapter->flags & TLAN_ADAPTER_BIT_RATE_PHY) {
2257 data |= TLAN_NET_CFG_BIT; 2289 data |= TLAN_NET_CFG_BIT;
2258 if ( priv->aui == 1 ) { 2290 if (priv->aui == 1) {
2259 TLan_DioWrite8( dev->base_addr, TLAN_ACOMMIT, 0x0a ); 2291 tlan_dio_write8(dev->base_addr, TLAN_ACOMMIT, 0x0a);
2260 } else if ( priv->duplex == TLAN_DUPLEX_FULL ) { 2292 } else if (priv->duplex == TLAN_DUPLEX_FULL) {
2261 TLan_DioWrite8( dev->base_addr, TLAN_ACOMMIT, 0x00 ); 2293 tlan_dio_write8(dev->base_addr, TLAN_ACOMMIT, 0x00);
2262 priv->tlanFullDuplex = true; 2294 priv->tlan_full_duplex = true;
2263 } else { 2295 } else {
2264 TLan_DioWrite8( dev->base_addr, TLAN_ACOMMIT, 0x08 ); 2296 tlan_dio_write8(dev->base_addr, TLAN_ACOMMIT, 0x08);
2265 } 2297 }
2266 } 2298 }
2267 2299
2268 if ( priv->phyNum == 0 ) { 2300 if (priv->phy_num == 0)
2269 data |= TLAN_NET_CFG_PHY_EN; 2301 data |= TLAN_NET_CFG_PHY_EN;
2270 } 2302 tlan_dio_write16(dev->base_addr, TLAN_NET_CONFIG, (u16) data);
2271 TLan_DioWrite16( dev->base_addr, TLAN_NET_CONFIG, (u16) data );
2272 2303
2273 if ( priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY ) { 2304 if (priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY)
2274 TLan_FinishReset( dev ); 2305 tlan_finish_reset(dev);
2275 } else { 2306 else
2276 TLan_PhyPowerDown( dev ); 2307 tlan_phy_power_down(dev);
2277 }
2278 2308
2279} /* TLan_ResetAdapter */ 2309}
2280 2310
2281 2311
2282 2312
2283 2313
2284static void 2314static void
2285TLan_FinishReset( struct net_device *dev ) 2315tlan_finish_reset(struct net_device *dev)
2286{ 2316{
2287 TLanPrivateInfo *priv = netdev_priv(dev); 2317 struct tlan_priv *priv = netdev_priv(dev);
2288 u8 data; 2318 u8 data;
2289 u32 phy; 2319 u32 phy;
2290 u8 sio; 2320 u8 sio;
2291 u16 status; 2321 u16 status;
2292 u16 partner; 2322 u16 partner;
2293 u16 tlphy_ctl; 2323 u16 tlphy_ctl;
2294 u16 tlphy_par; 2324 u16 tlphy_par;
2295 u16 tlphy_id1, tlphy_id2; 2325 u16 tlphy_id1, tlphy_id2;
2296 int i; 2326 int i;
2297 2327
2298 phy = priv->phy[priv->phyNum]; 2328 phy = priv->phy[priv->phy_num];
2299 2329
2300 data = TLAN_NET_CMD_NRESET | TLAN_NET_CMD_NWRAP; 2330 data = TLAN_NET_CMD_NRESET | TLAN_NET_CMD_NWRAP;
2301 if ( priv->tlanFullDuplex ) { 2331 if (priv->tlan_full_duplex)
2302 data |= TLAN_NET_CMD_DUPLEX; 2332 data |= TLAN_NET_CMD_DUPLEX;
2303 } 2333 tlan_dio_write8(dev->base_addr, TLAN_NET_CMD, data);
2304 TLan_DioWrite8( dev->base_addr, TLAN_NET_CMD, data );
2305 data = TLAN_NET_MASK_MASK4 | TLAN_NET_MASK_MASK5; 2334 data = TLAN_NET_MASK_MASK4 | TLAN_NET_MASK_MASK5;
2306 if ( priv->phyNum == 0 ) { 2335 if (priv->phy_num == 0)
2307 data |= TLAN_NET_MASK_MASK7; 2336 data |= TLAN_NET_MASK_MASK7;
2308 } 2337 tlan_dio_write8(dev->base_addr, TLAN_NET_MASK, data);
2309 TLan_DioWrite8( dev->base_addr, TLAN_NET_MASK, data ); 2338 tlan_dio_write16(dev->base_addr, TLAN_MAX_RX, ((1536)+7)&~7);
2310 TLan_DioWrite16( dev->base_addr, TLAN_MAX_RX, ((1536)+7)&~7 ); 2339 tlan_mii_read_reg(dev, phy, MII_GEN_ID_HI, &tlphy_id1);
2311 TLan_MiiReadReg( dev, phy, MII_GEN_ID_HI, &tlphy_id1 ); 2340 tlan_mii_read_reg(dev, phy, MII_GEN_ID_LO, &tlphy_id2);
2312 TLan_MiiReadReg( dev, phy, MII_GEN_ID_LO, &tlphy_id2 );
2313 2341
2314 if ( ( priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY ) || 2342 if ((priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY) ||
2315 ( priv->aui ) ) { 2343 (priv->aui)) {
2316 status = MII_GS_LINK; 2344 status = MII_GS_LINK;
2317 printk( "TLAN: %s: Link forced.\n", dev->name ); 2345 pr_info("TLAN: %s: Link forced.\n", dev->name);
2318 } else { 2346 } else {
2319 TLan_MiiReadReg( dev, phy, MII_GEN_STS, &status ); 2347 tlan_mii_read_reg(dev, phy, MII_GEN_STS, &status);
2320 udelay( 1000 ); 2348 udelay(1000);
2321 TLan_MiiReadReg( dev, phy, MII_GEN_STS, &status ); 2349 tlan_mii_read_reg(dev, phy, MII_GEN_STS, &status);
2322 if ( (status & MII_GS_LINK) && 2350 if ((status & MII_GS_LINK) &&
2323 /* We only support link info on Nat.Sem. PHY's */ 2351 /* We only support link info on Nat.Sem. PHY's */
2324 (tlphy_id1 == NAT_SEM_ID1) && 2352 (tlphy_id1 == NAT_SEM_ID1) &&
2325 (tlphy_id2 == NAT_SEM_ID2) ) { 2353 (tlphy_id2 == NAT_SEM_ID2)) {
2326 TLan_MiiReadReg( dev, phy, MII_AN_LPA, &partner ); 2354 tlan_mii_read_reg(dev, phy, MII_AN_LPA, &partner);
2327 TLan_MiiReadReg( dev, phy, TLAN_TLPHY_PAR, &tlphy_par ); 2355 tlan_mii_read_reg(dev, phy, TLAN_TLPHY_PAR, &tlphy_par);
2328 2356
2329 printk( "TLAN: %s: Link active with ", dev->name ); 2357 pr_info("TLAN: %s: Link active with ", dev->name);
2330 if (!(tlphy_par & TLAN_PHY_AN_EN_STAT)) { 2358 if (!(tlphy_par & TLAN_PHY_AN_EN_STAT)) {
2331 printk( "forced 10%sMbps %s-Duplex\n", 2359 pr_info("forced 10%sMbps %s-Duplex\n",
2332 tlphy_par & TLAN_PHY_SPEED_100 ? "" : "0", 2360 tlphy_par & TLAN_PHY_SPEED_100
2333 tlphy_par & TLAN_PHY_DUPLEX_FULL ? "Full" : "Half"); 2361 ? "" : "0",
2362 tlphy_par & TLAN_PHY_DUPLEX_FULL
2363 ? "Full" : "Half");
2334 } else { 2364 } else {
2335 printk( "AutoNegotiation enabled, at 10%sMbps %s-Duplex\n", 2365 pr_info("Autonegotiation enabled, at 10%sMbps %s-Duplex\n",
2336 tlphy_par & TLAN_PHY_SPEED_100 ? "" : "0", 2366 tlphy_par & TLAN_PHY_SPEED_100
2337 tlphy_par & TLAN_PHY_DUPLEX_FULL ? "Full" : "Half"); 2367 ? "" : "0",
2338 printk("TLAN: Partner capability: "); 2368 tlphy_par & TLAN_PHY_DUPLEX_FULL
2339 for (i = 5; i <= 10; i++) 2369 ? "Full" : "half");
2340 if (partner & (1<<i)) 2370 pr_info("TLAN: Partner capability: ");
2341 printk("%s",media[i-5]); 2371 for (i = 5; i <= 10; i++)
2372 if (partner & (1<<i))
2373 printk("%s", media[i-5]);
2342 printk("\n"); 2374 printk("\n");
2343 } 2375 }
2344 2376
2345 TLan_DioWrite8( dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK ); 2377 tlan_dio_write8(dev->base_addr, TLAN_LED_REG,
2378 TLAN_LED_LINK);
2346#ifdef MONITOR 2379#ifdef MONITOR
2347 /* We have link beat..for now anyway */ 2380 /* We have link beat..for now anyway */
2348 priv->link = 1; 2381 priv->link = 1;
2349 /*Enabling link beat monitoring */ 2382 /*Enabling link beat monitoring */
2350 TLan_SetTimer( dev, (10*HZ), TLAN_TIMER_LINK_BEAT ); 2383 tlan_set_timer(dev, (10*HZ), TLAN_TIMER_LINK_BEAT);
2351#endif 2384#endif
2352 } else if (status & MII_GS_LINK) { 2385 } else if (status & MII_GS_LINK) {
2353 printk( "TLAN: %s: Link active\n", dev->name ); 2386 pr_info("TLAN: %s: Link active\n", dev->name);
2354 TLan_DioWrite8( dev->base_addr, TLAN_LED_REG, TLAN_LED_LINK ); 2387 tlan_dio_write8(dev->base_addr, TLAN_LED_REG,
2388 TLAN_LED_LINK);
2355 } 2389 }
2356 } 2390 }
2357 2391
2358 if ( priv->phyNum == 0 ) { 2392 if (priv->phy_num == 0) {
2359 TLan_MiiReadReg( dev, phy, TLAN_TLPHY_CTL, &tlphy_ctl ); 2393 tlan_mii_read_reg(dev, phy, TLAN_TLPHY_CTL, &tlphy_ctl);
2360 tlphy_ctl |= TLAN_TC_INTEN; 2394 tlphy_ctl |= TLAN_TC_INTEN;
2361 TLan_MiiWriteReg( dev, phy, TLAN_TLPHY_CTL, tlphy_ctl ); 2395 tlan_mii_write_reg(dev, phy, TLAN_TLPHY_CTL, tlphy_ctl);
2362 sio = TLan_DioRead8( dev->base_addr, TLAN_NET_SIO ); 2396 sio = tlan_dio_read8(dev->base_addr, TLAN_NET_SIO);
2363 sio |= TLAN_NET_SIO_MINTEN; 2397 sio |= TLAN_NET_SIO_MINTEN;
2364 TLan_DioWrite8( dev->base_addr, TLAN_NET_SIO, sio ); 2398 tlan_dio_write8(dev->base_addr, TLAN_NET_SIO, sio);
2365 } 2399 }
2366 2400
2367 if ( status & MII_GS_LINK ) { 2401 if (status & MII_GS_LINK) {
2368 TLan_SetMac( dev, 0, dev->dev_addr ); 2402 tlan_set_mac(dev, 0, dev->dev_addr);
2369 priv->phyOnline = 1; 2403 priv->phy_online = 1;
2370 outb( ( TLAN_HC_INT_ON >> 8 ), dev->base_addr + TLAN_HOST_CMD + 1 ); 2404 outb((TLAN_HC_INT_ON >> 8), dev->base_addr + TLAN_HOST_CMD + 1);
2371 if ( debug >= 1 && debug != TLAN_DEBUG_PROBE ) { 2405 if (debug >= 1 && debug != TLAN_DEBUG_PROBE)
2372 outb( ( TLAN_HC_REQ_INT >> 8 ), dev->base_addr + TLAN_HOST_CMD + 1 ); 2406 outb((TLAN_HC_REQ_INT >> 8),
2373 } 2407 dev->base_addr + TLAN_HOST_CMD + 1);
2374 outl( priv->rxListDMA, dev->base_addr + TLAN_CH_PARM ); 2408 outl(priv->rx_list_dma, dev->base_addr + TLAN_CH_PARM);
2375 outl( TLAN_HC_GO | TLAN_HC_RT, dev->base_addr + TLAN_HOST_CMD ); 2409 outl(TLAN_HC_GO | TLAN_HC_RT, dev->base_addr + TLAN_HOST_CMD);
2376 netif_carrier_on(dev); 2410 netif_carrier_on(dev);
2377 } else { 2411 } else {
2378 printk( "TLAN: %s: Link inactive, will retry in 10 secs...\n", 2412 pr_info("TLAN: %s: Link inactive, will retry in 10 secs...\n",
2379 dev->name ); 2413 dev->name);
2380 TLan_SetTimer( dev, (10*HZ), TLAN_TIMER_FINISH_RESET ); 2414 tlan_set_timer(dev, (10*HZ), TLAN_TIMER_FINISH_RESET);
2381 return; 2415 return;
2382 } 2416 }
2383 TLan_SetMulticastList(dev); 2417 tlan_set_multicast_list(dev);
2384 2418
2385} /* TLan_FinishReset */ 2419}
2386 2420
2387 2421
2388 2422
2389 2423
2390 /*************************************************************** 2424/***************************************************************
2391 * TLan_SetMac 2425 * tlan_set_mac
2392 * 2426 *
2393 * Returns: 2427 * Returns:
2394 * Nothing 2428 * Nothing
2395 * Parms: 2429 * Parms:
2396 * dev Pointer to device structure of adapter 2430 * dev Pointer to device structure of adapter
2397 * on which to change the AREG. 2431 * on which to change the AREG.
2398 * areg The AREG to set the address in (0 - 3). 2432 * areg The AREG to set the address in (0 - 3).
2399 * mac A pointer to an array of chars. Each 2433 * mac A pointer to an array of chars. Each
2400 * element stores one byte of the address. 2434 * element stores one byte of the address.
2401 * IE, it isn't in ascii. 2435 * IE, it isn't in ascii.
2402 * 2436 *
2403 * This function transfers a MAC address to one of the 2437 * This function transfers a MAC address to one of the
2404 * TLAN AREGs (address registers). The TLAN chip locks 2438 * TLAN AREGs (address registers). The TLAN chip locks
2405 * the register on writing to offset 0 and unlocks the 2439 * the register on writing to offset 0 and unlocks the
2406 * register after writing to offset 5. If NULL is passed 2440 * register after writing to offset 5. If NULL is passed
2407 * in mac, then the AREG is filled with 0's. 2441 * in mac, then the AREG is filled with 0's.
2408 * 2442 *
2409 **************************************************************/ 2443 **************************************************************/
2410 2444
2411static void TLan_SetMac( struct net_device *dev, int areg, char *mac ) 2445static void tlan_set_mac(struct net_device *dev, int areg, char *mac)
2412{ 2446{
2413 int i; 2447 int i;
2414 2448
2415 areg *= 6; 2449 areg *= 6;
2416 2450
2417 if ( mac != NULL ) { 2451 if (mac != NULL) {
2418 for ( i = 0; i < 6; i++ ) 2452 for (i = 0; i < 6; i++)
2419 TLan_DioWrite8( dev->base_addr, 2453 tlan_dio_write8(dev->base_addr,
2420 TLAN_AREG_0 + areg + i, mac[i] ); 2454 TLAN_AREG_0 + areg + i, mac[i]);
2421 } else { 2455 } else {
2422 for ( i = 0; i < 6; i++ ) 2456 for (i = 0; i < 6; i++)
2423 TLan_DioWrite8( dev->base_addr, 2457 tlan_dio_write8(dev->base_addr,
2424 TLAN_AREG_0 + areg + i, 0 ); 2458 TLAN_AREG_0 + areg + i, 0);
2425 } 2459 }
2426 2460
2427} /* TLan_SetMac */ 2461}
2428 2462
2429 2463
2430 2464
@@ -2432,205 +2466,202 @@ static void TLan_SetMac( struct net_device *dev, int areg, char *mac )
2432/***************************************************************************** 2466/*****************************************************************************
2433****************************************************************************** 2467******************************************************************************
2434 2468
2435 ThunderLAN Driver PHY Layer Routines 2469ThunderLAN driver PHY layer routines
2436 2470
2437****************************************************************************** 2471******************************************************************************
2438*****************************************************************************/ 2472*****************************************************************************/
2439 2473
2440 2474
2441 2475
2442 /********************************************************************* 2476/*********************************************************************
2443 * TLan_PhyPrint 2477 * tlan_phy_print
2444 * 2478 *
2445 * Returns: 2479 * Returns:
2446 * Nothing 2480 * Nothing
2447 * Parms: 2481 * Parms:
2448 * dev A pointer to the device structure of the 2482 * dev A pointer to the device structure of the
2449 * TLAN device having the PHYs to be detailed. 2483 * TLAN device having the PHYs to be detailed.
2450 * 2484 *
2451 * This function prints the registers a PHY (aka transceiver). 2485 * This function prints the registers a PHY (aka transceiver).
2452 * 2486 *
2453 ********************************************************************/ 2487 ********************************************************************/
2454 2488
2455static void TLan_PhyPrint( struct net_device *dev ) 2489static void tlan_phy_print(struct net_device *dev)
2456{ 2490{
2457 TLanPrivateInfo *priv = netdev_priv(dev); 2491 struct tlan_priv *priv = netdev_priv(dev);
2458 u16 i, data0, data1, data2, data3, phy; 2492 u16 i, data0, data1, data2, data3, phy;
2459 2493
2460 phy = priv->phy[priv->phyNum]; 2494 phy = priv->phy[priv->phy_num];
2461 2495
2462 if ( priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY ) { 2496 if (priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY) {
2463 printk( "TLAN: Device %s, Unmanaged PHY.\n", dev->name ); 2497 pr_info("TLAN: Device %s, Unmanaged PHY.\n", dev->name);
2464 } else if ( phy <= TLAN_PHY_MAX_ADDR ) { 2498 } else if (phy <= TLAN_PHY_MAX_ADDR) {
2465 printk( "TLAN: Device %s, PHY 0x%02x.\n", dev->name, phy ); 2499 pr_info("TLAN: Device %s, PHY 0x%02x.\n", dev->name, phy);
2466 printk( "TLAN: Off. +0 +1 +2 +3\n" ); 2500 pr_info("TLAN: Off. +0 +1 +2 +3\n");
2467 for ( i = 0; i < 0x20; i+= 4 ) { 2501 for (i = 0; i < 0x20; i += 4) {
2468 printk( "TLAN: 0x%02x", i ); 2502 pr_info("TLAN: 0x%02x", i);
2469 TLan_MiiReadReg( dev, phy, i, &data0 ); 2503 tlan_mii_read_reg(dev, phy, i, &data0);
2470 printk( " 0x%04hx", data0 ); 2504 printk(" 0x%04hx", data0);
2471 TLan_MiiReadReg( dev, phy, i + 1, &data1 ); 2505 tlan_mii_read_reg(dev, phy, i + 1, &data1);
2472 printk( " 0x%04hx", data1 ); 2506 printk(" 0x%04hx", data1);
2473 TLan_MiiReadReg( dev, phy, i + 2, &data2 ); 2507 tlan_mii_read_reg(dev, phy, i + 2, &data2);
2474 printk( " 0x%04hx", data2 ); 2508 printk(" 0x%04hx", data2);
2475 TLan_MiiReadReg( dev, phy, i + 3, &data3 ); 2509 tlan_mii_read_reg(dev, phy, i + 3, &data3);
2476 printk( " 0x%04hx\n", data3 ); 2510 printk(" 0x%04hx\n", data3);
2477 } 2511 }
2478 } else { 2512 } else {
2479 printk( "TLAN: Device %s, Invalid PHY.\n", dev->name ); 2513 pr_info("TLAN: Device %s, Invalid PHY.\n", dev->name);
2480 } 2514 }
2481 2515
2482} /* TLan_PhyPrint */ 2516}
2483 2517
2484 2518
2485 2519
2486 2520
2487 /********************************************************************* 2521/*********************************************************************
2488 * TLan_PhyDetect 2522 * tlan_phy_detect
2489 * 2523 *
2490 * Returns: 2524 * Returns:
2491 * Nothing 2525 * Nothing
2492 * Parms: 2526 * Parms:
2493 * dev A pointer to the device structure of the adapter 2527 * dev A pointer to the device structure of the adapter
2494 * for which the PHY needs determined. 2528 * for which the PHY needs determined.
2495 * 2529 *
2496 * So far I've found that adapters which have external PHYs 2530 * So far I've found that adapters which have external PHYs
2497 * may also use the internal PHY for part of the functionality. 2531 * may also use the internal PHY for part of the functionality.
2498 * (eg, AUI/Thinnet). This function finds out if this TLAN 2532 * (eg, AUI/Thinnet). This function finds out if this TLAN
2499 * chip has an internal PHY, and then finds the first external 2533 * chip has an internal PHY, and then finds the first external
2500 * PHY (starting from address 0) if it exists). 2534 * PHY (starting from address 0) if it exists).
2501 * 2535 *
2502 ********************************************************************/ 2536 ********************************************************************/
2503 2537
2504static void TLan_PhyDetect( struct net_device *dev ) 2538static void tlan_phy_detect(struct net_device *dev)
2505{ 2539{
2506 TLanPrivateInfo *priv = netdev_priv(dev); 2540 struct tlan_priv *priv = netdev_priv(dev);
2507 u16 control; 2541 u16 control;
2508 u16 hi; 2542 u16 hi;
2509 u16 lo; 2543 u16 lo;
2510 u32 phy; 2544 u32 phy;
2511 2545
2512 if ( priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY ) { 2546 if (priv->adapter->flags & TLAN_ADAPTER_UNMANAGED_PHY) {
2513 priv->phyNum = 0xFFFF; 2547 priv->phy_num = 0xffff;
2514 return; 2548 return;
2515 } 2549 }
2516 2550
2517 TLan_MiiReadReg( dev, TLAN_PHY_MAX_ADDR, MII_GEN_ID_HI, &hi ); 2551 tlan_mii_read_reg(dev, TLAN_PHY_MAX_ADDR, MII_GEN_ID_HI, &hi);
2518 2552
2519 if ( hi != 0xFFFF ) { 2553 if (hi != 0xffff)
2520 priv->phy[0] = TLAN_PHY_MAX_ADDR; 2554 priv->phy[0] = TLAN_PHY_MAX_ADDR;
2521 } else { 2555 else
2522 priv->phy[0] = TLAN_PHY_NONE; 2556 priv->phy[0] = TLAN_PHY_NONE;
2523 }
2524 2557
2525 priv->phy[1] = TLAN_PHY_NONE; 2558 priv->phy[1] = TLAN_PHY_NONE;
2526 for ( phy = 0; phy <= TLAN_PHY_MAX_ADDR; phy++ ) { 2559 for (phy = 0; phy <= TLAN_PHY_MAX_ADDR; phy++) {
2527 TLan_MiiReadReg( dev, phy, MII_GEN_CTL, &control ); 2560 tlan_mii_read_reg(dev, phy, MII_GEN_CTL, &control);
2528 TLan_MiiReadReg( dev, phy, MII_GEN_ID_HI, &hi ); 2561 tlan_mii_read_reg(dev, phy, MII_GEN_ID_HI, &hi);
2529 TLan_MiiReadReg( dev, phy, MII_GEN_ID_LO, &lo ); 2562 tlan_mii_read_reg(dev, phy, MII_GEN_ID_LO, &lo);
2530 if ( ( control != 0xFFFF ) || 2563 if ((control != 0xffff) ||
2531 ( hi != 0xFFFF ) || ( lo != 0xFFFF ) ) { 2564 (hi != 0xffff) || (lo != 0xffff)) {
2532 TLAN_DBG( TLAN_DEBUG_GNRL, 2565 TLAN_DBG(TLAN_DEBUG_GNRL,
2533 "PHY found at %02x %04x %04x %04x\n", 2566 "PHY found at %02x %04x %04x %04x\n",
2534 phy, control, hi, lo ); 2567 phy, control, hi, lo);
2535 if ( ( priv->phy[1] == TLAN_PHY_NONE ) && 2568 if ((priv->phy[1] == TLAN_PHY_NONE) &&
2536 ( phy != TLAN_PHY_MAX_ADDR ) ) { 2569 (phy != TLAN_PHY_MAX_ADDR)) {
2537 priv->phy[1] = phy; 2570 priv->phy[1] = phy;
2538 } 2571 }
2539 } 2572 }
2540 } 2573 }
2541 2574
2542 if ( priv->phy[1] != TLAN_PHY_NONE ) { 2575 if (priv->phy[1] != TLAN_PHY_NONE)
2543 priv->phyNum = 1; 2576 priv->phy_num = 1;
2544 } else if ( priv->phy[0] != TLAN_PHY_NONE ) { 2577 else if (priv->phy[0] != TLAN_PHY_NONE)
2545 priv->phyNum = 0; 2578 priv->phy_num = 0;
2546 } else { 2579 else
2547 printk( "TLAN: Cannot initialize device, no PHY was found!\n" ); 2580 pr_info("TLAN: Cannot initialize device, no PHY was found!\n");
2548 }
2549 2581
2550} /* TLan_PhyDetect */ 2582}
2551 2583
2552 2584
2553 2585
2554 2586
2555static void TLan_PhyPowerDown( struct net_device *dev ) 2587static void tlan_phy_power_down(struct net_device *dev)
2556{ 2588{
2557 TLanPrivateInfo *priv = netdev_priv(dev); 2589 struct tlan_priv *priv = netdev_priv(dev);
2558 u16 value; 2590 u16 value;
2559 2591
2560 TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Powering down PHY(s).\n", dev->name ); 2592 TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Powering down PHY(s).\n", dev->name);
2561 value = MII_GC_PDOWN | MII_GC_LOOPBK | MII_GC_ISOLATE; 2593 value = MII_GC_PDOWN | MII_GC_LOOPBK | MII_GC_ISOLATE;
2562 TLan_MiiSync( dev->base_addr ); 2594 tlan_mii_sync(dev->base_addr);
2563 TLan_MiiWriteReg( dev, priv->phy[priv->phyNum], MII_GEN_CTL, value ); 2595 tlan_mii_write_reg(dev, priv->phy[priv->phy_num], MII_GEN_CTL, value);
2564 if ( ( priv->phyNum == 0 ) && 2596 if ((priv->phy_num == 0) &&
2565 ( priv->phy[1] != TLAN_PHY_NONE ) && 2597 (priv->phy[1] != TLAN_PHY_NONE) &&
2566 ( ! ( priv->adapter->flags & TLAN_ADAPTER_USE_INTERN_10 ) ) ) { 2598 (!(priv->adapter->flags & TLAN_ADAPTER_USE_INTERN_10))) {
2567 TLan_MiiSync( dev->base_addr ); 2599 tlan_mii_sync(dev->base_addr);
2568 TLan_MiiWriteReg( dev, priv->phy[1], MII_GEN_CTL, value ); 2600 tlan_mii_write_reg(dev, priv->phy[1], MII_GEN_CTL, value);
2569 } 2601 }
2570 2602
2571 /* Wait for 50 ms and powerup 2603 /* Wait for 50 ms and powerup
2572 * This is abitrary. It is intended to make sure the 2604 * This is abitrary. It is intended to make sure the
2573 * transceiver settles. 2605 * transceiver settles.
2574 */ 2606 */
2575 TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_PUP ); 2607 tlan_set_timer(dev, (HZ/20), TLAN_TIMER_PHY_PUP);
2576 2608
2577} /* TLan_PhyPowerDown */ 2609}
2578 2610
2579 2611
2580 2612
2581 2613
2582static void TLan_PhyPowerUp( struct net_device *dev ) 2614static void tlan_phy_power_up(struct net_device *dev)
2583{ 2615{
2584 TLanPrivateInfo *priv = netdev_priv(dev); 2616 struct tlan_priv *priv = netdev_priv(dev);
2585 u16 value; 2617 u16 value;
2586 2618
2587 TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Powering up PHY.\n", dev->name ); 2619 TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Powering up PHY.\n", dev->name);
2588 TLan_MiiSync( dev->base_addr ); 2620 tlan_mii_sync(dev->base_addr);
2589 value = MII_GC_LOOPBK; 2621 value = MII_GC_LOOPBK;
2590 TLan_MiiWriteReg( dev, priv->phy[priv->phyNum], MII_GEN_CTL, value ); 2622 tlan_mii_write_reg(dev, priv->phy[priv->phy_num], MII_GEN_CTL, value);
2591 TLan_MiiSync(dev->base_addr); 2623 tlan_mii_sync(dev->base_addr);
2592 /* Wait for 500 ms and reset the 2624 /* Wait for 500 ms and reset the
2593 * transceiver. The TLAN docs say both 50 ms and 2625 * transceiver. The TLAN docs say both 50 ms and
2594 * 500 ms, so do the longer, just in case. 2626 * 500 ms, so do the longer, just in case.
2595 */ 2627 */
2596 TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_RESET ); 2628 tlan_set_timer(dev, (HZ/20), TLAN_TIMER_PHY_RESET);
2597 2629
2598} /* TLan_PhyPowerUp */ 2630}
2599 2631
2600 2632
2601 2633
2602 2634
2603static void TLan_PhyReset( struct net_device *dev ) 2635static void tlan_phy_reset(struct net_device *dev)
2604{ 2636{
2605 TLanPrivateInfo *priv = netdev_priv(dev); 2637 struct tlan_priv *priv = netdev_priv(dev);
2606 u16 phy; 2638 u16 phy;
2607 u16 value; 2639 u16 value;
2608 2640
2609 phy = priv->phy[priv->phyNum]; 2641 phy = priv->phy[priv->phy_num];
2610 2642
2611 TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Reseting PHY.\n", dev->name ); 2643 TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Reseting PHY.\n", dev->name);
2612 TLan_MiiSync( dev->base_addr ); 2644 tlan_mii_sync(dev->base_addr);
2613 value = MII_GC_LOOPBK | MII_GC_RESET; 2645 value = MII_GC_LOOPBK | MII_GC_RESET;
2614 TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, value ); 2646 tlan_mii_write_reg(dev, phy, MII_GEN_CTL, value);
2615 TLan_MiiReadReg( dev, phy, MII_GEN_CTL, &value ); 2647 tlan_mii_read_reg(dev, phy, MII_GEN_CTL, &value);
2616 while ( value & MII_GC_RESET ) { 2648 while (value & MII_GC_RESET)
2617 TLan_MiiReadReg( dev, phy, MII_GEN_CTL, &value ); 2649 tlan_mii_read_reg(dev, phy, MII_GEN_CTL, &value);
2618 }
2619 2650
2620 /* Wait for 500 ms and initialize. 2651 /* Wait for 500 ms and initialize.
2621 * I don't remember why I wait this long. 2652 * I don't remember why I wait this long.
2622 * I've changed this to 50ms, as it seems long enough. 2653 * I've changed this to 50ms, as it seems long enough.
2623 */ 2654 */
2624 TLan_SetTimer( dev, (HZ/20), TLAN_TIMER_PHY_START_LINK ); 2655 tlan_set_timer(dev, (HZ/20), TLAN_TIMER_PHY_START_LINK);
2625 2656
2626} /* TLan_PhyReset */ 2657}
2627 2658
2628 2659
2629 2660
2630 2661
2631static void TLan_PhyStartLink( struct net_device *dev ) 2662static void tlan_phy_start_link(struct net_device *dev)
2632{ 2663{
2633 TLanPrivateInfo *priv = netdev_priv(dev); 2664 struct tlan_priv *priv = netdev_priv(dev);
2634 u16 ability; 2665 u16 ability;
2635 u16 control; 2666 u16 control;
2636 u16 data; 2667 u16 data;
@@ -2638,86 +2669,88 @@ static void TLan_PhyStartLink( struct net_device *dev )
2638 u16 status; 2669 u16 status;
2639 u16 tctl; 2670 u16 tctl;
2640 2671
2641 phy = priv->phy[priv->phyNum]; 2672 phy = priv->phy[priv->phy_num];
2642 TLAN_DBG( TLAN_DEBUG_GNRL, "%s: Trying to activate link.\n", dev->name ); 2673 TLAN_DBG(TLAN_DEBUG_GNRL, "%s: Trying to activate link.\n", dev->name);
2643 TLan_MiiReadReg( dev, phy, MII_GEN_STS, &status ); 2674 tlan_mii_read_reg(dev, phy, MII_GEN_STS, &status);
2644 TLan_MiiReadReg( dev, phy, MII_GEN_STS, &ability ); 2675 tlan_mii_read_reg(dev, phy, MII_GEN_STS, &ability);
2645 2676
2646 if ( ( status & MII_GS_AUTONEG ) && 2677 if ((status & MII_GS_AUTONEG) &&
2647 ( ! priv->aui ) ) { 2678 (!priv->aui)) {
2648 ability = status >> 11; 2679 ability = status >> 11;
2649 if ( priv->speed == TLAN_SPEED_10 && 2680 if (priv->speed == TLAN_SPEED_10 &&
2650 priv->duplex == TLAN_DUPLEX_HALF) { 2681 priv->duplex == TLAN_DUPLEX_HALF) {
2651 TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x0000); 2682 tlan_mii_write_reg(dev, phy, MII_GEN_CTL, 0x0000);
2652 } else if ( priv->speed == TLAN_SPEED_10 && 2683 } else if (priv->speed == TLAN_SPEED_10 &&
2653 priv->duplex == TLAN_DUPLEX_FULL) { 2684 priv->duplex == TLAN_DUPLEX_FULL) {
2654 priv->tlanFullDuplex = true; 2685 priv->tlan_full_duplex = true;
2655 TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x0100); 2686 tlan_mii_write_reg(dev, phy, MII_GEN_CTL, 0x0100);
2656 } else if ( priv->speed == TLAN_SPEED_100 && 2687 } else if (priv->speed == TLAN_SPEED_100 &&
2657 priv->duplex == TLAN_DUPLEX_HALF) { 2688 priv->duplex == TLAN_DUPLEX_HALF) {
2658 TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x2000); 2689 tlan_mii_write_reg(dev, phy, MII_GEN_CTL, 0x2000);
2659 } else if ( priv->speed == TLAN_SPEED_100 && 2690 } else if (priv->speed == TLAN_SPEED_100 &&
2660 priv->duplex == TLAN_DUPLEX_FULL) { 2691 priv->duplex == TLAN_DUPLEX_FULL) {
2661 priv->tlanFullDuplex = true; 2692 priv->tlan_full_duplex = true;
2662 TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x2100); 2693 tlan_mii_write_reg(dev, phy, MII_GEN_CTL, 0x2100);
2663 } else { 2694 } else {
2664 2695
2665 /* Set Auto-Neg advertisement */ 2696 /* Set Auto-Neg advertisement */
2666 TLan_MiiWriteReg( dev, phy, MII_AN_ADV, (ability << 5) | 1); 2697 tlan_mii_write_reg(dev, phy, MII_AN_ADV,
2698 (ability << 5) | 1);
2667 /* Enablee Auto-Neg */ 2699 /* Enablee Auto-Neg */
2668 TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x1000 ); 2700 tlan_mii_write_reg(dev, phy, MII_GEN_CTL, 0x1000);
2669 /* Restart Auto-Neg */ 2701 /* Restart Auto-Neg */
2670 TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 0x1200 ); 2702 tlan_mii_write_reg(dev, phy, MII_GEN_CTL, 0x1200);
2671 /* Wait for 4 sec for autonegotiation 2703 /* Wait for 4 sec for autonegotiation
2672 * to complete. The max spec time is less than this 2704 * to complete. The max spec time is less than this
2673 * but the card need additional time to start AN. 2705 * but the card need additional time to start AN.
2674 * .5 sec should be plenty extra. 2706 * .5 sec should be plenty extra.
2675 */ 2707 */
2676 printk( "TLAN: %s: Starting autonegotiation.\n", dev->name ); 2708 pr_info("TLAN: %s: Starting autonegotiation.\n",
2677 TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_PHY_FINISH_AN ); 2709 dev->name);
2710 tlan_set_timer(dev, (2*HZ), TLAN_TIMER_PHY_FINISH_AN);
2678 return; 2711 return;
2679 } 2712 }
2680 2713
2681 } 2714 }
2682 2715
2683 if ( ( priv->aui ) && ( priv->phyNum != 0 ) ) { 2716 if ((priv->aui) && (priv->phy_num != 0)) {
2684 priv->phyNum = 0; 2717 priv->phy_num = 0;
2685 data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN | TLAN_NET_CFG_PHY_EN; 2718 data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN
2686 TLan_DioWrite16( dev->base_addr, TLAN_NET_CONFIG, data ); 2719 | TLAN_NET_CFG_PHY_EN;
2687 TLan_SetTimer( dev, (40*HZ/1000), TLAN_TIMER_PHY_PDOWN ); 2720 tlan_dio_write16(dev->base_addr, TLAN_NET_CONFIG, data);
2721 tlan_set_timer(dev, (40*HZ/1000), TLAN_TIMER_PHY_PDOWN);
2688 return; 2722 return;
2689 } else if ( priv->phyNum == 0 ) { 2723 } else if (priv->phy_num == 0) {
2690 control = 0; 2724 control = 0;
2691 TLan_MiiReadReg( dev, phy, TLAN_TLPHY_CTL, &tctl ); 2725 tlan_mii_read_reg(dev, phy, TLAN_TLPHY_CTL, &tctl);
2692 if ( priv->aui ) { 2726 if (priv->aui) {
2693 tctl |= TLAN_TC_AUISEL; 2727 tctl |= TLAN_TC_AUISEL;
2694 } else { 2728 } else {
2695 tctl &= ~TLAN_TC_AUISEL; 2729 tctl &= ~TLAN_TC_AUISEL;
2696 if ( priv->duplex == TLAN_DUPLEX_FULL ) { 2730 if (priv->duplex == TLAN_DUPLEX_FULL) {
2697 control |= MII_GC_DUPLEX; 2731 control |= MII_GC_DUPLEX;
2698 priv->tlanFullDuplex = true; 2732 priv->tlan_full_duplex = true;
2699 } 2733 }
2700 if ( priv->speed == TLAN_SPEED_100 ) { 2734 if (priv->speed == TLAN_SPEED_100)
2701 control |= MII_GC_SPEEDSEL; 2735 control |= MII_GC_SPEEDSEL;
2702 }
2703 } 2736 }
2704 TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, control ); 2737 tlan_mii_write_reg(dev, phy, MII_GEN_CTL, control);
2705 TLan_MiiWriteReg( dev, phy, TLAN_TLPHY_CTL, tctl ); 2738 tlan_mii_write_reg(dev, phy, TLAN_TLPHY_CTL, tctl);
2706 } 2739 }
2707 2740
2708 /* Wait for 2 sec to give the transceiver time 2741 /* Wait for 2 sec to give the transceiver time
2709 * to establish link. 2742 * to establish link.
2710 */ 2743 */
2711 TLan_SetTimer( dev, (4*HZ), TLAN_TIMER_FINISH_RESET ); 2744 tlan_set_timer(dev, (4*HZ), TLAN_TIMER_FINISH_RESET);
2712 2745
2713} /* TLan_PhyStartLink */ 2746}
2714 2747
2715 2748
2716 2749
2717 2750
2718static void TLan_PhyFinishAutoNeg( struct net_device *dev ) 2751static void tlan_phy_finish_auto_neg(struct net_device *dev)
2719{ 2752{
2720 TLanPrivateInfo *priv = netdev_priv(dev); 2753 struct tlan_priv *priv = netdev_priv(dev);
2721 u16 an_adv; 2754 u16 an_adv;
2722 u16 an_lpa; 2755 u16 an_lpa;
2723 u16 data; 2756 u16 data;
@@ -2725,115 +2758,118 @@ static void TLan_PhyFinishAutoNeg( struct net_device *dev )
2725 u16 phy; 2758 u16 phy;
2726 u16 status; 2759 u16 status;
2727 2760
2728 phy = priv->phy[priv->phyNum]; 2761 phy = priv->phy[priv->phy_num];
2729 2762
2730 TLan_MiiReadReg( dev, phy, MII_GEN_STS, &status ); 2763 tlan_mii_read_reg(dev, phy, MII_GEN_STS, &status);
2731 udelay( 1000 ); 2764 udelay(1000);
2732 TLan_MiiReadReg( dev, phy, MII_GEN_STS, &status ); 2765 tlan_mii_read_reg(dev, phy, MII_GEN_STS, &status);
2733 2766
2734 if ( ! ( status & MII_GS_AUTOCMPLT ) ) { 2767 if (!(status & MII_GS_AUTOCMPLT)) {
2735 /* Wait for 8 sec to give the process 2768 /* Wait for 8 sec to give the process
2736 * more time. Perhaps we should fail after a while. 2769 * more time. Perhaps we should fail after a while.
2737 */ 2770 */
2738 if (!priv->neg_be_verbose++) { 2771 if (!priv->neg_be_verbose++) {
2739 pr_info("TLAN: Giving autonegotiation more time.\n"); 2772 pr_info("TLAN: Giving autonegotiation more time.\n");
2740 pr_info("TLAN: Please check that your adapter has\n"); 2773 pr_info("TLAN: Please check that your adapter has\n");
2741 pr_info("TLAN: been properly connected to a HUB or Switch.\n"); 2774 pr_info("TLAN: been properly connected to a HUB or Switch.\n");
2742 pr_info("TLAN: Trying to establish link in the background...\n"); 2775 pr_info("TLAN: Trying to establish link in the background...\n");
2743 } 2776 }
2744 TLan_SetTimer( dev, (8*HZ), TLAN_TIMER_PHY_FINISH_AN ); 2777 tlan_set_timer(dev, (8*HZ), TLAN_TIMER_PHY_FINISH_AN);
2745 return; 2778 return;
2746 } 2779 }
2747 2780
2748 printk( "TLAN: %s: Autonegotiation complete.\n", dev->name ); 2781 pr_info("TLAN: %s: Autonegotiation complete.\n", dev->name);
2749 TLan_MiiReadReg( dev, phy, MII_AN_ADV, &an_adv ); 2782 tlan_mii_read_reg(dev, phy, MII_AN_ADV, &an_adv);
2750 TLan_MiiReadReg( dev, phy, MII_AN_LPA, &an_lpa ); 2783 tlan_mii_read_reg(dev, phy, MII_AN_LPA, &an_lpa);
2751 mode = an_adv & an_lpa & 0x03E0; 2784 mode = an_adv & an_lpa & 0x03E0;
2752 if ( mode & 0x0100 ) { 2785 if (mode & 0x0100)
2753 priv->tlanFullDuplex = true; 2786 priv->tlan_full_duplex = true;
2754 } else if ( ! ( mode & 0x0080 ) && ( mode & 0x0040 ) ) { 2787 else if (!(mode & 0x0080) && (mode & 0x0040))
2755 priv->tlanFullDuplex = true; 2788 priv->tlan_full_duplex = true;
2756 } 2789
2757 2790 if ((!(mode & 0x0180)) &&
2758 if ( ( ! ( mode & 0x0180 ) ) && 2791 (priv->adapter->flags & TLAN_ADAPTER_USE_INTERN_10) &&
2759 ( priv->adapter->flags & TLAN_ADAPTER_USE_INTERN_10 ) && 2792 (priv->phy_num != 0)) {
2760 ( priv->phyNum != 0 ) ) { 2793 priv->phy_num = 0;
2761 priv->phyNum = 0; 2794 data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN
2762 data = TLAN_NET_CFG_1FRAG | TLAN_NET_CFG_1CHAN | TLAN_NET_CFG_PHY_EN; 2795 | TLAN_NET_CFG_PHY_EN;
2763 TLan_DioWrite16( dev->base_addr, TLAN_NET_CONFIG, data ); 2796 tlan_dio_write16(dev->base_addr, TLAN_NET_CONFIG, data);
2764 TLan_SetTimer( dev, (400*HZ/1000), TLAN_TIMER_PHY_PDOWN ); 2797 tlan_set_timer(dev, (400*HZ/1000), TLAN_TIMER_PHY_PDOWN);
2765 return; 2798 return;
2766 } 2799 }
2767 2800
2768 if ( priv->phyNum == 0 ) { 2801 if (priv->phy_num == 0) {
2769 if ( ( priv->duplex == TLAN_DUPLEX_FULL ) || 2802 if ((priv->duplex == TLAN_DUPLEX_FULL) ||
2770 ( an_adv & an_lpa & 0x0040 ) ) { 2803 (an_adv & an_lpa & 0x0040)) {
2771 TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, 2804 tlan_mii_write_reg(dev, phy, MII_GEN_CTL,
2772 MII_GC_AUTOENB | MII_GC_DUPLEX ); 2805 MII_GC_AUTOENB | MII_GC_DUPLEX);
2773 pr_info("TLAN: Starting internal PHY with FULL-DUPLEX\n" ); 2806 pr_info("TLAN: Starting internal PHY with FULL-DUPLEX\n");
2774 } else { 2807 } else {
2775 TLan_MiiWriteReg( dev, phy, MII_GEN_CTL, MII_GC_AUTOENB ); 2808 tlan_mii_write_reg(dev, phy, MII_GEN_CTL,
2776 pr_info( "TLAN: Starting internal PHY with HALF-DUPLEX\n" ); 2809 MII_GC_AUTOENB);
2810 pr_info("TLAN: Starting internal PHY with HALF-DUPLEX\n");
2777 } 2811 }
2778 } 2812 }
2779 2813
2780 /* Wait for 100 ms. No reason in partiticular. 2814 /* Wait for 100 ms. No reason in partiticular.
2781 */ 2815 */
2782 TLan_SetTimer( dev, (HZ/10), TLAN_TIMER_FINISH_RESET ); 2816 tlan_set_timer(dev, (HZ/10), TLAN_TIMER_FINISH_RESET);
2783 2817
2784} /* TLan_PhyFinishAutoNeg */ 2818}
2785 2819
2786#ifdef MONITOR 2820#ifdef MONITOR
2787 2821
2788 /********************************************************************* 2822/*********************************************************************
2789 * 2823 *
2790 * TLan_phyMonitor 2824 * tlan_phy_monitor
2791 * 2825 *
2792 * Returns: 2826 * Returns:
2793 * None 2827 * None
2794 * 2828 *
2795 * Params: 2829 * Params:
2796 * dev The device structure of this device. 2830 * dev The device structure of this device.
2797 * 2831 *
2798 * 2832 *
2799 * This function monitors PHY condition by reading the status 2833 * This function monitors PHY condition by reading the status
2800 * register via the MII bus. This can be used to give info 2834 * register via the MII bus. This can be used to give info
2801 * about link changes (up/down), and possible switch to alternate 2835 * about link changes (up/down), and possible switch to alternate
2802 * media. 2836 * media.
2803 * 2837 *
2804 * ******************************************************************/ 2838 *******************************************************************/
2805 2839
2806void TLan_PhyMonitor( struct net_device *dev ) 2840void tlan_phy_monitor(struct net_device *dev)
2807{ 2841{
2808 TLanPrivateInfo *priv = netdev_priv(dev); 2842 struct tlan_priv *priv = netdev_priv(dev);
2809 u16 phy; 2843 u16 phy;
2810 u16 phy_status; 2844 u16 phy_status;
2811 2845
2812 phy = priv->phy[priv->phyNum]; 2846 phy = priv->phy[priv->phy_num];
2813 2847
2814 /* Get PHY status register */ 2848 /* Get PHY status register */
2815 TLan_MiiReadReg( dev, phy, MII_GEN_STS, &phy_status ); 2849 tlan_mii_read_reg(dev, phy, MII_GEN_STS, &phy_status);
2816 2850
2817 /* Check if link has been lost */ 2851 /* Check if link has been lost */
2818 if (!(phy_status & MII_GS_LINK)) { 2852 if (!(phy_status & MII_GS_LINK)) {
2819 if (priv->link) { 2853 if (priv->link) {
2820 priv->link = 0; 2854 priv->link = 0;
2821 printk(KERN_DEBUG "TLAN: %s has lost link\n", dev->name); 2855 printk(KERN_DEBUG "TLAN: %s has lost link\n",
2822 netif_carrier_off(dev); 2856 dev->name);
2823 TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_LINK_BEAT ); 2857 netif_carrier_off(dev);
2824 return; 2858 tlan_set_timer(dev, (2*HZ), TLAN_TIMER_LINK_BEAT);
2859 return;
2825 } 2860 }
2826 } 2861 }
2827 2862
2828 /* Link restablished? */ 2863 /* Link restablished? */
2829 if ((phy_status & MII_GS_LINK) && !priv->link) { 2864 if ((phy_status & MII_GS_LINK) && !priv->link) {
2830 priv->link = 1; 2865 priv->link = 1;
2831 printk(KERN_DEBUG "TLAN: %s has reestablished link\n", dev->name); 2866 printk(KERN_DEBUG "TLAN: %s has reestablished link\n",
2867 dev->name);
2832 netif_carrier_on(dev); 2868 netif_carrier_on(dev);
2833 } 2869 }
2834 2870
2835 /* Setup a new monitor */ 2871 /* Setup a new monitor */
2836 TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_LINK_BEAT ); 2872 tlan_set_timer(dev, (2*HZ), TLAN_TIMER_LINK_BEAT);
2837} 2873}
2838 2874
2839#endif /* MONITOR */ 2875#endif /* MONITOR */
@@ -2842,47 +2878,48 @@ void TLan_PhyMonitor( struct net_device *dev )
2842/***************************************************************************** 2878/*****************************************************************************
2843****************************************************************************** 2879******************************************************************************
2844 2880
2845 ThunderLAN Driver MII Routines 2881ThunderLAN driver MII routines
2846 2882
2847 These routines are based on the information in Chap. 2 of the 2883these routines are based on the information in chap. 2 of the
2848 "ThunderLAN Programmer's Guide", pp. 15-24. 2884"ThunderLAN Programmer's Guide", pp. 15-24.
2849 2885
2850****************************************************************************** 2886******************************************************************************
2851*****************************************************************************/ 2887*****************************************************************************/
2852 2888
2853 2889
2854 /*************************************************************** 2890/***************************************************************
2855 * TLan_MiiReadReg 2891 * tlan_mii_read_reg
2856 * 2892 *
2857 * Returns: 2893 * Returns:
2858 * false if ack received ok 2894 * false if ack received ok
2859 * true if no ack received or other error 2895 * true if no ack received or other error
2860 * 2896 *
2861 * Parms: 2897 * Parms:
2862 * dev The device structure containing 2898 * dev The device structure containing
2863 * The io address and interrupt count 2899 * The io address and interrupt count
2864 * for this device. 2900 * for this device.
2865 * phy The address of the PHY to be queried. 2901 * phy The address of the PHY to be queried.
2866 * reg The register whose contents are to be 2902 * reg The register whose contents are to be
2867 * retrieved. 2903 * retrieved.
2868 * val A pointer to a variable to store the 2904 * val A pointer to a variable to store the
2869 * retrieved value. 2905 * retrieved value.
2870 * 2906 *
2871 * This function uses the TLAN's MII bus to retrieve the contents 2907 * This function uses the TLAN's MII bus to retrieve the contents
2872 * of a given register on a PHY. It sends the appropriate info 2908 * of a given register on a PHY. It sends the appropriate info
2873 * and then reads the 16-bit register value from the MII bus via 2909 * and then reads the 16-bit register value from the MII bus via
2874 * the TLAN SIO register. 2910 * the TLAN SIO register.
2875 * 2911 *
2876 **************************************************************/ 2912 **************************************************************/
2877 2913
2878static bool TLan_MiiReadReg( struct net_device *dev, u16 phy, u16 reg, u16 *val ) 2914static bool
2915tlan_mii_read_reg(struct net_device *dev, u16 phy, u16 reg, u16 *val)
2879{ 2916{
2880 u8 nack; 2917 u8 nack;
2881 u16 sio, tmp; 2918 u16 sio, tmp;
2882 u32 i; 2919 u32 i;
2883 bool err; 2920 bool err;
2884 int minten; 2921 int minten;
2885 TLanPrivateInfo *priv = netdev_priv(dev); 2922 struct tlan_priv *priv = netdev_priv(dev);
2886 unsigned long flags = 0; 2923 unsigned long flags = 0;
2887 2924
2888 err = false; 2925 err = false;
@@ -2892,48 +2929,48 @@ static bool TLan_MiiReadReg( struct net_device *dev, u16 phy, u16 reg, u16 *val
2892 if (!in_irq()) 2929 if (!in_irq())
2893 spin_lock_irqsave(&priv->lock, flags); 2930 spin_lock_irqsave(&priv->lock, flags);
2894 2931
2895 TLan_MiiSync(dev->base_addr); 2932 tlan_mii_sync(dev->base_addr);
2896 2933
2897 minten = TLan_GetBit( TLAN_NET_SIO_MINTEN, sio ); 2934 minten = tlan_get_bit(TLAN_NET_SIO_MINTEN, sio);
2898 if ( minten ) 2935 if (minten)
2899 TLan_ClearBit(TLAN_NET_SIO_MINTEN, sio); 2936 tlan_clear_bit(TLAN_NET_SIO_MINTEN, sio);
2900 2937
2901 TLan_MiiSendData( dev->base_addr, 0x1, 2 ); /* Start ( 01b ) */ 2938 tlan_mii_send_data(dev->base_addr, 0x1, 2); /* start (01b) */
2902 TLan_MiiSendData( dev->base_addr, 0x2, 2 ); /* Read ( 10b ) */ 2939 tlan_mii_send_data(dev->base_addr, 0x2, 2); /* read (10b) */
2903 TLan_MiiSendData( dev->base_addr, phy, 5 ); /* Device # */ 2940 tlan_mii_send_data(dev->base_addr, phy, 5); /* device # */
2904 TLan_MiiSendData( dev->base_addr, reg, 5 ); /* Register # */ 2941 tlan_mii_send_data(dev->base_addr, reg, 5); /* register # */
2905 2942
2906 2943
2907 TLan_ClearBit(TLAN_NET_SIO_MTXEN, sio); /* Change direction */ 2944 tlan_clear_bit(TLAN_NET_SIO_MTXEN, sio); /* change direction */
2908 2945
2909 TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Clock Idle bit */ 2946 tlan_clear_bit(TLAN_NET_SIO_MCLK, sio); /* clock idle bit */
2910 TLan_SetBit(TLAN_NET_SIO_MCLK, sio); 2947 tlan_set_bit(TLAN_NET_SIO_MCLK, sio);
2911 TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Wait 300ns */ 2948 tlan_clear_bit(TLAN_NET_SIO_MCLK, sio); /* wait 300ns */
2912 2949
2913 nack = TLan_GetBit(TLAN_NET_SIO_MDATA, sio); /* Check for ACK */ 2950 nack = tlan_get_bit(TLAN_NET_SIO_MDATA, sio); /* check for ACK */
2914 TLan_SetBit(TLAN_NET_SIO_MCLK, sio); /* Finish ACK */ 2951 tlan_set_bit(TLAN_NET_SIO_MCLK, sio); /* finish ACK */
2915 if (nack) { /* No ACK, so fake it */ 2952 if (nack) { /* no ACK, so fake it */
2916 for (i = 0; i < 16; i++) { 2953 for (i = 0; i < 16; i++) {
2917 TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); 2954 tlan_clear_bit(TLAN_NET_SIO_MCLK, sio);
2918 TLan_SetBit(TLAN_NET_SIO_MCLK, sio); 2955 tlan_set_bit(TLAN_NET_SIO_MCLK, sio);
2919 } 2956 }
2920 tmp = 0xffff; 2957 tmp = 0xffff;
2921 err = true; 2958 err = true;
2922 } else { /* ACK, so read data */ 2959 } else { /* ACK, so read data */
2923 for (tmp = 0, i = 0x8000; i; i >>= 1) { 2960 for (tmp = 0, i = 0x8000; i; i >>= 1) {
2924 TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); 2961 tlan_clear_bit(TLAN_NET_SIO_MCLK, sio);
2925 if (TLan_GetBit(TLAN_NET_SIO_MDATA, sio)) 2962 if (tlan_get_bit(TLAN_NET_SIO_MDATA, sio))
2926 tmp |= i; 2963 tmp |= i;
2927 TLan_SetBit(TLAN_NET_SIO_MCLK, sio); 2964 tlan_set_bit(TLAN_NET_SIO_MCLK, sio);
2928 } 2965 }
2929 } 2966 }
2930 2967
2931 2968
2932 TLan_ClearBit(TLAN_NET_SIO_MCLK, sio); /* Idle cycle */ 2969 tlan_clear_bit(TLAN_NET_SIO_MCLK, sio); /* idle cycle */
2933 TLan_SetBit(TLAN_NET_SIO_MCLK, sio); 2970 tlan_set_bit(TLAN_NET_SIO_MCLK, sio);
2934 2971
2935 if ( minten ) 2972 if (minten)
2936 TLan_SetBit(TLAN_NET_SIO_MINTEN, sio); 2973 tlan_set_bit(TLAN_NET_SIO_MINTEN, sio);
2937 2974
2938 *val = tmp; 2975 *val = tmp;
2939 2976
@@ -2942,116 +2979,117 @@ static bool TLan_MiiReadReg( struct net_device *dev, u16 phy, u16 reg, u16 *val
2942 2979
2943 return err; 2980 return err;
2944 2981
2945} /* TLan_MiiReadReg */ 2982}
2946 2983
2947 2984
2948 2985
2949 2986
2950 /*************************************************************** 2987/***************************************************************
2951 * TLan_MiiSendData 2988 * tlan_mii_send_data
2952 * 2989 *
2953 * Returns: 2990 * Returns:
2954 * Nothing 2991 * Nothing
2955 * Parms: 2992 * Parms:
2956 * base_port The base IO port of the adapter in 2993 * base_port The base IO port of the adapter in
2957 * question. 2994 * question.
2958 * dev The address of the PHY to be queried. 2995 * dev The address of the PHY to be queried.
2959 * data The value to be placed on the MII bus. 2996 * data The value to be placed on the MII bus.
2960 * num_bits The number of bits in data that are to 2997 * num_bits The number of bits in data that are to
2961 * be placed on the MII bus. 2998 * be placed on the MII bus.
2962 * 2999 *
2963 * This function sends on sequence of bits on the MII 3000 * This function sends on sequence of bits on the MII
2964 * configuration bus. 3001 * configuration bus.
2965 * 3002 *
2966 **************************************************************/ 3003 **************************************************************/
2967 3004
2968static void TLan_MiiSendData( u16 base_port, u32 data, unsigned num_bits ) 3005static void tlan_mii_send_data(u16 base_port, u32 data, unsigned num_bits)
2969{ 3006{
2970 u16 sio; 3007 u16 sio;
2971 u32 i; 3008 u32 i;
2972 3009
2973 if ( num_bits == 0 ) 3010 if (num_bits == 0)
2974 return; 3011 return;
2975 3012
2976 outw( TLAN_NET_SIO, base_port + TLAN_DIO_ADR ); 3013 outw(TLAN_NET_SIO, base_port + TLAN_DIO_ADR);
2977 sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO; 3014 sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO;
2978 TLan_SetBit( TLAN_NET_SIO_MTXEN, sio ); 3015 tlan_set_bit(TLAN_NET_SIO_MTXEN, sio);
2979 3016
2980 for ( i = ( 0x1 << ( num_bits - 1 ) ); i; i >>= 1 ) { 3017 for (i = (0x1 << (num_bits - 1)); i; i >>= 1) {
2981 TLan_ClearBit( TLAN_NET_SIO_MCLK, sio ); 3018 tlan_clear_bit(TLAN_NET_SIO_MCLK, sio);
2982 (void) TLan_GetBit( TLAN_NET_SIO_MCLK, sio ); 3019 (void) tlan_get_bit(TLAN_NET_SIO_MCLK, sio);
2983 if ( data & i ) 3020 if (data & i)
2984 TLan_SetBit( TLAN_NET_SIO_MDATA, sio ); 3021 tlan_set_bit(TLAN_NET_SIO_MDATA, sio);
2985 else 3022 else
2986 TLan_ClearBit( TLAN_NET_SIO_MDATA, sio ); 3023 tlan_clear_bit(TLAN_NET_SIO_MDATA, sio);
2987 TLan_SetBit( TLAN_NET_SIO_MCLK, sio ); 3024 tlan_set_bit(TLAN_NET_SIO_MCLK, sio);
2988 (void) TLan_GetBit( TLAN_NET_SIO_MCLK, sio ); 3025 (void) tlan_get_bit(TLAN_NET_SIO_MCLK, sio);
2989 } 3026 }
2990 3027
2991} /* TLan_MiiSendData */ 3028}
2992 3029
2993 3030
2994 3031
2995 3032
2996 /*************************************************************** 3033/***************************************************************
2997 * TLan_MiiSync 3034 * TLan_MiiSync
2998 * 3035 *
2999 * Returns: 3036 * Returns:
3000 * Nothing 3037 * Nothing
3001 * Parms: 3038 * Parms:
3002 * base_port The base IO port of the adapter in 3039 * base_port The base IO port of the adapter in
3003 * question. 3040 * question.
3004 * 3041 *
3005 * This functions syncs all PHYs in terms of the MII configuration 3042 * This functions syncs all PHYs in terms of the MII configuration
3006 * bus. 3043 * bus.
3007 * 3044 *
3008 **************************************************************/ 3045 **************************************************************/
3009 3046
3010static void TLan_MiiSync( u16 base_port ) 3047static void tlan_mii_sync(u16 base_port)
3011{ 3048{
3012 int i; 3049 int i;
3013 u16 sio; 3050 u16 sio;
3014 3051
3015 outw( TLAN_NET_SIO, base_port + TLAN_DIO_ADR ); 3052 outw(TLAN_NET_SIO, base_port + TLAN_DIO_ADR);
3016 sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO; 3053 sio = base_port + TLAN_DIO_DATA + TLAN_NET_SIO;
3017 3054
3018 TLan_ClearBit( TLAN_NET_SIO_MTXEN, sio ); 3055 tlan_clear_bit(TLAN_NET_SIO_MTXEN, sio);
3019 for ( i = 0; i < 32; i++ ) { 3056 for (i = 0; i < 32; i++) {
3020 TLan_ClearBit( TLAN_NET_SIO_MCLK, sio ); 3057 tlan_clear_bit(TLAN_NET_SIO_MCLK, sio);
3021 TLan_SetBit( TLAN_NET_SIO_MCLK, sio ); 3058 tlan_set_bit(TLAN_NET_SIO_MCLK, sio);
3022 } 3059 }
3023 3060
3024} /* TLan_MiiSync */ 3061}
3025 3062
3026 3063
3027 3064
3028 3065
3029 /*************************************************************** 3066/***************************************************************
3030 * TLan_MiiWriteReg 3067 * tlan_mii_write_reg
3031 * 3068 *
3032 * Returns: 3069 * Returns:
3033 * Nothing 3070 * Nothing
3034 * Parms: 3071 * Parms:
3035 * dev The device structure for the device 3072 * dev The device structure for the device
3036 * to write to. 3073 * to write to.
3037 * phy The address of the PHY to be written to. 3074 * phy The address of the PHY to be written to.
3038 * reg The register whose contents are to be 3075 * reg The register whose contents are to be
3039 * written. 3076 * written.
3040 * val The value to be written to the register. 3077 * val The value to be written to the register.
3041 * 3078 *
3042 * This function uses the TLAN's MII bus to write the contents of a 3079 * This function uses the TLAN's MII bus to write the contents of a
3043 * given register on a PHY. It sends the appropriate info and then 3080 * given register on a PHY. It sends the appropriate info and then
3044 * writes the 16-bit register value from the MII configuration bus 3081 * writes the 16-bit register value from the MII configuration bus
3045 * via the TLAN SIO register. 3082 * via the TLAN SIO register.
3046 * 3083 *
3047 **************************************************************/ 3084 **************************************************************/
3048 3085
3049static void TLan_MiiWriteReg( struct net_device *dev, u16 phy, u16 reg, u16 val ) 3086static void
3087tlan_mii_write_reg(struct net_device *dev, u16 phy, u16 reg, u16 val)
3050{ 3088{
3051 u16 sio; 3089 u16 sio;
3052 int minten; 3090 int minten;
3053 unsigned long flags = 0; 3091 unsigned long flags = 0;
3054 TLanPrivateInfo *priv = netdev_priv(dev); 3092 struct tlan_priv *priv = netdev_priv(dev);
3055 3093
3056 outw(TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR); 3094 outw(TLAN_NET_SIO, dev->base_addr + TLAN_DIO_ADR);
3057 sio = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO; 3095 sio = dev->base_addr + TLAN_DIO_DATA + TLAN_NET_SIO;
@@ -3059,30 +3097,30 @@ static void TLan_MiiWriteReg( struct net_device *dev, u16 phy, u16 reg, u16 val
3059 if (!in_irq()) 3097 if (!in_irq())
3060 spin_lock_irqsave(&priv->lock, flags); 3098 spin_lock_irqsave(&priv->lock, flags);
3061 3099
3062 TLan_MiiSync( dev->base_addr ); 3100 tlan_mii_sync(dev->base_addr);
3063 3101
3064 minten = TLan_GetBit( TLAN_NET_SIO_MINTEN, sio ); 3102 minten = tlan_get_bit(TLAN_NET_SIO_MINTEN, sio);
3065 if ( minten ) 3103 if (minten)
3066 TLan_ClearBit( TLAN_NET_SIO_MINTEN, sio ); 3104 tlan_clear_bit(TLAN_NET_SIO_MINTEN, sio);
3067 3105
3068 TLan_MiiSendData( dev->base_addr, 0x1, 2 ); /* Start ( 01b ) */ 3106 tlan_mii_send_data(dev->base_addr, 0x1, 2); /* start (01b) */
3069 TLan_MiiSendData( dev->base_addr, 0x1, 2 ); /* Write ( 01b ) */ 3107 tlan_mii_send_data(dev->base_addr, 0x1, 2); /* write (01b) */
3070 TLan_MiiSendData( dev->base_addr, phy, 5 ); /* Device # */ 3108 tlan_mii_send_data(dev->base_addr, phy, 5); /* device # */
3071 TLan_MiiSendData( dev->base_addr, reg, 5 ); /* Register # */ 3109 tlan_mii_send_data(dev->base_addr, reg, 5); /* register # */
3072 3110
3073 TLan_MiiSendData( dev->base_addr, 0x2, 2 ); /* Send ACK */ 3111 tlan_mii_send_data(dev->base_addr, 0x2, 2); /* send ACK */
3074 TLan_MiiSendData( dev->base_addr, val, 16 ); /* Send Data */ 3112 tlan_mii_send_data(dev->base_addr, val, 16); /* send data */
3075 3113
3076 TLan_ClearBit( TLAN_NET_SIO_MCLK, sio ); /* Idle cycle */ 3114 tlan_clear_bit(TLAN_NET_SIO_MCLK, sio); /* idle cycle */
3077 TLan_SetBit( TLAN_NET_SIO_MCLK, sio ); 3115 tlan_set_bit(TLAN_NET_SIO_MCLK, sio);
3078 3116
3079 if ( minten ) 3117 if (minten)
3080 TLan_SetBit( TLAN_NET_SIO_MINTEN, sio ); 3118 tlan_set_bit(TLAN_NET_SIO_MINTEN, sio);
3081 3119
3082 if (!in_irq()) 3120 if (!in_irq())
3083 spin_unlock_irqrestore(&priv->lock, flags); 3121 spin_unlock_irqrestore(&priv->lock, flags);
3084 3122
3085} /* TLan_MiiWriteReg */ 3123}
3086 3124
3087 3125
3088 3126
@@ -3090,229 +3128,226 @@ static void TLan_MiiWriteReg( struct net_device *dev, u16 phy, u16 reg, u16 val
3090/***************************************************************************** 3128/*****************************************************************************
3091****************************************************************************** 3129******************************************************************************
3092 3130
3093 ThunderLAN Driver Eeprom routines 3131ThunderLAN driver eeprom routines
3094 3132
3095 The Compaq Netelligent 10 and 10/100 cards use a Microchip 24C02A 3133the Compaq netelligent 10 and 10/100 cards use a microchip 24C02A
3096 EEPROM. These functions are based on information in Microchip's 3134EEPROM. these functions are based on information in microchip's
3097 data sheet. I don't know how well this functions will work with 3135data sheet. I don't know how well this functions will work with
3098 other EEPROMs. 3136other Eeproms.
3099 3137
3100****************************************************************************** 3138******************************************************************************
3101*****************************************************************************/ 3139*****************************************************************************/
3102 3140
3103 3141
3104 /*************************************************************** 3142/***************************************************************
3105 * TLan_EeSendStart 3143 * tlan_ee_send_start
3106 * 3144 *
3107 * Returns: 3145 * Returns:
3108 * Nothing 3146 * Nothing
3109 * Parms: 3147 * Parms:
3110 * io_base The IO port base address for the 3148 * io_base The IO port base address for the
3111 * TLAN device with the EEPROM to 3149 * TLAN device with the EEPROM to
3112 * use. 3150 * use.
3113 * 3151 *
3114 * This function sends a start cycle to an EEPROM attached 3152 * This function sends a start cycle to an EEPROM attached
3115 * to a TLAN chip. 3153 * to a TLAN chip.
3116 * 3154 *
3117 **************************************************************/ 3155 **************************************************************/
3118 3156
3119static void TLan_EeSendStart( u16 io_base ) 3157static void tlan_ee_send_start(u16 io_base)
3120{ 3158{
3121 u16 sio; 3159 u16 sio;
3122 3160
3123 outw( TLAN_NET_SIO, io_base + TLAN_DIO_ADR ); 3161 outw(TLAN_NET_SIO, io_base + TLAN_DIO_ADR);
3124 sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO; 3162 sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
3125 3163
3126 TLan_SetBit( TLAN_NET_SIO_ECLOK, sio ); 3164 tlan_set_bit(TLAN_NET_SIO_ECLOK, sio);
3127 TLan_SetBit( TLAN_NET_SIO_EDATA, sio ); 3165 tlan_set_bit(TLAN_NET_SIO_EDATA, sio);
3128 TLan_SetBit( TLAN_NET_SIO_ETXEN, sio ); 3166 tlan_set_bit(TLAN_NET_SIO_ETXEN, sio);
3129 TLan_ClearBit( TLAN_NET_SIO_EDATA, sio ); 3167 tlan_clear_bit(TLAN_NET_SIO_EDATA, sio);
3130 TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio ); 3168 tlan_clear_bit(TLAN_NET_SIO_ECLOK, sio);
3131 3169
3132} /* TLan_EeSendStart */ 3170}
3133 3171
3134 3172
3135 3173
3136 3174
3137 /*************************************************************** 3175/***************************************************************
3138 * TLan_EeSendByte 3176 * tlan_ee_send_byte
3139 * 3177 *
3140 * Returns: 3178 * Returns:
3141 * If the correct ack was received, 0, otherwise 1 3179 * If the correct ack was received, 0, otherwise 1
3142 * Parms: io_base The IO port base address for the 3180 * Parms: io_base The IO port base address for the
3143 * TLAN device with the EEPROM to 3181 * TLAN device with the EEPROM to
3144 * use. 3182 * use.
3145 * data The 8 bits of information to 3183 * data The 8 bits of information to
3146 * send to the EEPROM. 3184 * send to the EEPROM.
3147 * stop If TLAN_EEPROM_STOP is passed, a 3185 * stop If TLAN_EEPROM_STOP is passed, a
3148 * stop cycle is sent after the 3186 * stop cycle is sent after the
3149 * byte is sent after the ack is 3187 * byte is sent after the ack is
3150 * read. 3188 * read.
3151 * 3189 *
3152 * This function sends a byte on the serial EEPROM line, 3190 * This function sends a byte on the serial EEPROM line,
3153 * driving the clock to send each bit. The function then 3191 * driving the clock to send each bit. The function then
3154 * reverses transmission direction and reads an acknowledge 3192 * reverses transmission direction and reads an acknowledge
3155 * bit. 3193 * bit.
3156 * 3194 *
3157 **************************************************************/ 3195 **************************************************************/
3158 3196
3159static int TLan_EeSendByte( u16 io_base, u8 data, int stop ) 3197static int tlan_ee_send_byte(u16 io_base, u8 data, int stop)
3160{ 3198{
3161 int err; 3199 int err;
3162 u8 place; 3200 u8 place;
3163 u16 sio; 3201 u16 sio;
3164 3202
3165 outw( TLAN_NET_SIO, io_base + TLAN_DIO_ADR ); 3203 outw(TLAN_NET_SIO, io_base + TLAN_DIO_ADR);
3166 sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO; 3204 sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
3167 3205
3168 /* Assume clock is low, tx is enabled; */ 3206 /* Assume clock is low, tx is enabled; */
3169 for ( place = 0x80; place != 0; place >>= 1 ) { 3207 for (place = 0x80; place != 0; place >>= 1) {
3170 if ( place & data ) 3208 if (place & data)
3171 TLan_SetBit( TLAN_NET_SIO_EDATA, sio ); 3209 tlan_set_bit(TLAN_NET_SIO_EDATA, sio);
3172 else 3210 else
3173 TLan_ClearBit( TLAN_NET_SIO_EDATA, sio ); 3211 tlan_clear_bit(TLAN_NET_SIO_EDATA, sio);
3174 TLan_SetBit( TLAN_NET_SIO_ECLOK, sio ); 3212 tlan_set_bit(TLAN_NET_SIO_ECLOK, sio);
3175 TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio ); 3213 tlan_clear_bit(TLAN_NET_SIO_ECLOK, sio);
3176 } 3214 }
3177 TLan_ClearBit( TLAN_NET_SIO_ETXEN, sio ); 3215 tlan_clear_bit(TLAN_NET_SIO_ETXEN, sio);
3178 TLan_SetBit( TLAN_NET_SIO_ECLOK, sio ); 3216 tlan_set_bit(TLAN_NET_SIO_ECLOK, sio);
3179 err = TLan_GetBit( TLAN_NET_SIO_EDATA, sio ); 3217 err = tlan_get_bit(TLAN_NET_SIO_EDATA, sio);
3180 TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio ); 3218 tlan_clear_bit(TLAN_NET_SIO_ECLOK, sio);
3181 TLan_SetBit( TLAN_NET_SIO_ETXEN, sio ); 3219 tlan_set_bit(TLAN_NET_SIO_ETXEN, sio);
3182 3220
3183 if ( ( ! err ) && stop ) { 3221 if ((!err) && stop) {
3184 /* STOP, raise data while clock is high */ 3222 /* STOP, raise data while clock is high */
3185 TLan_ClearBit( TLAN_NET_SIO_EDATA, sio ); 3223 tlan_clear_bit(TLAN_NET_SIO_EDATA, sio);
3186 TLan_SetBit( TLAN_NET_SIO_ECLOK, sio ); 3224 tlan_set_bit(TLAN_NET_SIO_ECLOK, sio);
3187 TLan_SetBit( TLAN_NET_SIO_EDATA, sio ); 3225 tlan_set_bit(TLAN_NET_SIO_EDATA, sio);
3188 } 3226 }
3189 3227
3190 return err; 3228 return err;
3191 3229
3192} /* TLan_EeSendByte */ 3230}
3193 3231
3194 3232
3195 3233
3196 3234
3197 /*************************************************************** 3235/***************************************************************
3198 * TLan_EeReceiveByte 3236 * tlan_ee_receive_byte
3199 * 3237 *
3200 * Returns: 3238 * Returns:
3201 * Nothing 3239 * Nothing
3202 * Parms: 3240 * Parms:
3203 * io_base The IO port base address for the 3241 * io_base The IO port base address for the
3204 * TLAN device with the EEPROM to 3242 * TLAN device with the EEPROM to
3205 * use. 3243 * use.
3206 * data An address to a char to hold the 3244 * data An address to a char to hold the
3207 * data sent from the EEPROM. 3245 * data sent from the EEPROM.
3208 * stop If TLAN_EEPROM_STOP is passed, a 3246 * stop If TLAN_EEPROM_STOP is passed, a
3209 * stop cycle is sent after the 3247 * stop cycle is sent after the
3210 * byte is received, and no ack is 3248 * byte is received, and no ack is
3211 * sent. 3249 * sent.
3212 * 3250 *
3213 * This function receives 8 bits of data from the EEPROM 3251 * This function receives 8 bits of data from the EEPROM
3214 * over the serial link. It then sends and ack bit, or no 3252 * over the serial link. It then sends and ack bit, or no
3215 * ack and a stop bit. This function is used to retrieve 3253 * ack and a stop bit. This function is used to retrieve
3216 * data after the address of a byte in the EEPROM has been 3254 * data after the address of a byte in the EEPROM has been
3217 * sent. 3255 * sent.
3218 * 3256 *
3219 **************************************************************/ 3257 **************************************************************/
3220 3258
3221static void TLan_EeReceiveByte( u16 io_base, u8 *data, int stop ) 3259static void tlan_ee_receive_byte(u16 io_base, u8 *data, int stop)
3222{ 3260{
3223 u8 place; 3261 u8 place;
3224 u16 sio; 3262 u16 sio;
3225 3263
3226 outw( TLAN_NET_SIO, io_base + TLAN_DIO_ADR ); 3264 outw(TLAN_NET_SIO, io_base + TLAN_DIO_ADR);
3227 sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO; 3265 sio = io_base + TLAN_DIO_DATA + TLAN_NET_SIO;
3228 *data = 0; 3266 *data = 0;
3229 3267
3230 /* Assume clock is low, tx is enabled; */ 3268 /* Assume clock is low, tx is enabled; */
3231 TLan_ClearBit( TLAN_NET_SIO_ETXEN, sio ); 3269 tlan_clear_bit(TLAN_NET_SIO_ETXEN, sio);
3232 for ( place = 0x80; place; place >>= 1 ) { 3270 for (place = 0x80; place; place >>= 1) {
3233 TLan_SetBit( TLAN_NET_SIO_ECLOK, sio ); 3271 tlan_set_bit(TLAN_NET_SIO_ECLOK, sio);
3234 if ( TLan_GetBit( TLAN_NET_SIO_EDATA, sio ) ) 3272 if (tlan_get_bit(TLAN_NET_SIO_EDATA, sio))
3235 *data |= place; 3273 *data |= place;
3236 TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio ); 3274 tlan_clear_bit(TLAN_NET_SIO_ECLOK, sio);
3237 } 3275 }
3238 3276
3239 TLan_SetBit( TLAN_NET_SIO_ETXEN, sio ); 3277 tlan_set_bit(TLAN_NET_SIO_ETXEN, sio);
3240 if ( ! stop ) { 3278 if (!stop) {
3241 TLan_ClearBit( TLAN_NET_SIO_EDATA, sio ); /* Ack = 0 */ 3279 tlan_clear_bit(TLAN_NET_SIO_EDATA, sio); /* ack = 0 */
3242 TLan_SetBit( TLAN_NET_SIO_ECLOK, sio ); 3280 tlan_set_bit(TLAN_NET_SIO_ECLOK, sio);
3243 TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio ); 3281 tlan_clear_bit(TLAN_NET_SIO_ECLOK, sio);
3244 } else { 3282 } else {
3245 TLan_SetBit( TLAN_NET_SIO_EDATA, sio ); /* No ack = 1 (?) */ 3283 tlan_set_bit(TLAN_NET_SIO_EDATA, sio); /* no ack = 1 (?) */
3246 TLan_SetBit( TLAN_NET_SIO_ECLOK, sio ); 3284 tlan_set_bit(TLAN_NET_SIO_ECLOK, sio);
3247 TLan_ClearBit( TLAN_NET_SIO_ECLOK, sio ); 3285 tlan_clear_bit(TLAN_NET_SIO_ECLOK, sio);
3248 /* STOP, raise data while clock is high */ 3286 /* STOP, raise data while clock is high */
3249 TLan_ClearBit( TLAN_NET_SIO_EDATA, sio ); 3287 tlan_clear_bit(TLAN_NET_SIO_EDATA, sio);
3250 TLan_SetBit( TLAN_NET_SIO_ECLOK, sio ); 3288 tlan_set_bit(TLAN_NET_SIO_ECLOK, sio);
3251 TLan_SetBit( TLAN_NET_SIO_EDATA, sio ); 3289 tlan_set_bit(TLAN_NET_SIO_EDATA, sio);
3252 } 3290 }
3253 3291
3254} /* TLan_EeReceiveByte */ 3292}
3255 3293
3256 3294
3257 3295
3258 3296
3259 /*************************************************************** 3297/***************************************************************
3260 * TLan_EeReadByte 3298 * tlan_ee_read_byte
3261 * 3299 *
3262 * Returns: 3300 * Returns:
3263 * No error = 0, else, the stage at which the error 3301 * No error = 0, else, the stage at which the error
3264 * occurred. 3302 * occurred.
3265 * Parms: 3303 * Parms:
3266 * io_base The IO port base address for the 3304 * io_base The IO port base address for the
3267 * TLAN device with the EEPROM to 3305 * TLAN device with the EEPROM to
3268 * use. 3306 * use.
3269 * ee_addr The address of the byte in the 3307 * ee_addr The address of the byte in the
3270 * EEPROM whose contents are to be 3308 * EEPROM whose contents are to be
3271 * retrieved. 3309 * retrieved.
3272 * data An address to a char to hold the 3310 * data An address to a char to hold the
3273 * data obtained from the EEPROM. 3311 * data obtained from the EEPROM.
3274 * 3312 *
3275 * This function reads a byte of information from an byte 3313 * This function reads a byte of information from an byte
3276 * cell in the EEPROM. 3314 * cell in the EEPROM.
3277 * 3315 *
3278 **************************************************************/ 3316 **************************************************************/
3279 3317
3280static int TLan_EeReadByte( struct net_device *dev, u8 ee_addr, u8 *data ) 3318static int tlan_ee_read_byte(struct net_device *dev, u8 ee_addr, u8 *data)
3281{ 3319{
3282 int err; 3320 int err;
3283 TLanPrivateInfo *priv = netdev_priv(dev); 3321 struct tlan_priv *priv = netdev_priv(dev);
3284 unsigned long flags = 0; 3322 unsigned long flags = 0;
3285 int ret=0; 3323 int ret = 0;
3286 3324
3287 spin_lock_irqsave(&priv->lock, flags); 3325 spin_lock_irqsave(&priv->lock, flags);
3288 3326
3289 TLan_EeSendStart( dev->base_addr ); 3327 tlan_ee_send_start(dev->base_addr);
3290 err = TLan_EeSendByte( dev->base_addr, 0xA0, TLAN_EEPROM_ACK ); 3328 err = tlan_ee_send_byte(dev->base_addr, 0xa0, TLAN_EEPROM_ACK);
3291 if (err) 3329 if (err) {
3292 { 3330 ret = 1;
3293 ret=1;
3294 goto fail; 3331 goto fail;
3295 } 3332 }
3296 err = TLan_EeSendByte( dev->base_addr, ee_addr, TLAN_EEPROM_ACK ); 3333 err = tlan_ee_send_byte(dev->base_addr, ee_addr, TLAN_EEPROM_ACK);
3297 if (err) 3334 if (err) {
3298 { 3335 ret = 2;
3299 ret=2;
3300 goto fail; 3336 goto fail;
3301 } 3337 }
3302 TLan_EeSendStart( dev->base_addr ); 3338 tlan_ee_send_start(dev->base_addr);
3303 err = TLan_EeSendByte( dev->base_addr, 0xA1, TLAN_EEPROM_ACK ); 3339 err = tlan_ee_send_byte(dev->base_addr, 0xa1, TLAN_EEPROM_ACK);
3304 if (err) 3340 if (err) {
3305 { 3341 ret = 3;
3306 ret=3;
3307 goto fail; 3342 goto fail;
3308 } 3343 }
3309 TLan_EeReceiveByte( dev->base_addr, data, TLAN_EEPROM_STOP ); 3344 tlan_ee_receive_byte(dev->base_addr, data, TLAN_EEPROM_STOP);
3310fail: 3345fail:
3311 spin_unlock_irqrestore(&priv->lock, flags); 3346 spin_unlock_irqrestore(&priv->lock, flags);
3312 3347
3313 return ret; 3348 return ret;
3314 3349
3315} /* TLan_EeReadByte */ 3350}
3316 3351
3317 3352
3318 3353
diff --git a/drivers/net/tlan.h b/drivers/net/tlan.h
index 3315ced774e2..5fc98a8e4889 100644
--- a/drivers/net/tlan.h
+++ b/drivers/net/tlan.h
@@ -20,8 +20,8 @@
20 ********************************************************************/ 20 ********************************************************************/
21 21
22 22
23#include <asm/io.h> 23#include <linux/io.h>
24#include <asm/types.h> 24#include <linux/types.h>
25#include <linux/netdevice.h> 25#include <linux/netdevice.h>
26 26
27 27
@@ -40,8 +40,11 @@
40#define TLAN_IGNORE 0 40#define TLAN_IGNORE 0
41#define TLAN_RECORD 1 41#define TLAN_RECORD 1
42 42
43#define TLAN_DBG(lvl, format, args...) \ 43#define TLAN_DBG(lvl, format, args...) \
44 do { if (debug&lvl) printk(KERN_DEBUG "TLAN: " format, ##args ); } while(0) 44 do { \
45 if (debug&lvl) \
46 printk(KERN_DEBUG "TLAN: " format, ##args); \
47 } while (0)
45 48
46#define TLAN_DEBUG_GNRL 0x0001 49#define TLAN_DEBUG_GNRL 0x0001
47#define TLAN_DEBUG_TX 0x0002 50#define TLAN_DEBUG_TX 0x0002
@@ -50,7 +53,8 @@
50#define TLAN_DEBUG_PROBE 0x0010 53#define TLAN_DEBUG_PROBE 0x0010
51 54
52#define TX_TIMEOUT (10*HZ) /* We need time for auto-neg */ 55#define TX_TIMEOUT (10*HZ) /* We need time for auto-neg */
53#define MAX_TLAN_BOARDS 8 /* Max number of boards installed at a time */ 56#define MAX_TLAN_BOARDS 8 /* Max number of boards installed
57 at a time */
54 58
55 59
56 /***************************************************************** 60 /*****************************************************************
@@ -70,13 +74,13 @@
70#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014 74#define PCI_DEVICE_ID_OLICOM_OC2326 0x0014
71#endif 75#endif
72 76
73typedef struct tlan_adapter_entry { 77struct tlan_adapter_entry {
74 u16 vendorId; 78 u16 vendor_id;
75 u16 deviceId; 79 u16 device_id;
76 char *deviceLabel; 80 char *device_label;
77 u32 flags; 81 u32 flags;
78 u16 addrOfs; 82 u16 addr_ofs;
79} TLanAdapterEntry; 83};
80 84
81#define TLAN_ADAPTER_NONE 0x00000000 85#define TLAN_ADAPTER_NONE 0x00000000
82#define TLAN_ADAPTER_UNMANAGED_PHY 0x00000001 86#define TLAN_ADAPTER_UNMANAGED_PHY 0x00000001
@@ -129,18 +133,18 @@ typedef struct tlan_adapter_entry {
129#define TLAN_CSTAT_DP_PR 0x0100 133#define TLAN_CSTAT_DP_PR 0x0100
130 134
131 135
132typedef struct tlan_buffer_ref_tag { 136struct tlan_buffer {
133 u32 count; 137 u32 count;
134 u32 address; 138 u32 address;
135} TLanBufferRef; 139};
136 140
137 141
138typedef struct tlan_list_tag { 142struct tlan_list {
139 u32 forward; 143 u32 forward;
140 u16 cStat; 144 u16 c_stat;
141 u16 frameSize; 145 u16 frame_size;
142 TLanBufferRef buffer[TLAN_BUFFERS_PER_LIST]; 146 struct tlan_buffer buffer[TLAN_BUFFERS_PER_LIST];
143} TLanList; 147};
144 148
145 149
146typedef u8 TLanBuffer[TLAN_MAX_FRAME_SIZE]; 150typedef u8 TLanBuffer[TLAN_MAX_FRAME_SIZE];
@@ -164,49 +168,49 @@ typedef u8 TLanBuffer[TLAN_MAX_FRAME_SIZE];
164 * 168 *
165 ****************************************************************/ 169 ****************************************************************/
166 170
167typedef struct tlan_private_tag { 171struct tlan_priv {
168 struct net_device *nextDevice; 172 struct net_device *next_device;
169 struct pci_dev *pciDev; 173 struct pci_dev *pci_dev;
170 struct net_device *dev; 174 struct net_device *dev;
171 void *dmaStorage; 175 void *dma_storage;
172 dma_addr_t dmaStorageDMA; 176 dma_addr_t dma_storage_dma;
173 unsigned int dmaSize; 177 unsigned int dma_size;
174 u8 *padBuffer; 178 u8 *pad_buffer;
175 TLanList *rxList; 179 struct tlan_list *rx_list;
176 dma_addr_t rxListDMA; 180 dma_addr_t rx_list_dma;
177 u8 *rxBuffer; 181 u8 *rx_buffer;
178 dma_addr_t rxBufferDMA; 182 dma_addr_t rx_buffer_dma;
179 u32 rxHead; 183 u32 rx_head;
180 u32 rxTail; 184 u32 rx_tail;
181 u32 rxEocCount; 185 u32 rx_eoc_count;
182 TLanList *txList; 186 struct tlan_list *tx_list;
183 dma_addr_t txListDMA; 187 dma_addr_t tx_list_dma;
184 u8 *txBuffer; 188 u8 *tx_buffer;
185 dma_addr_t txBufferDMA; 189 dma_addr_t tx_buffer_dma;
186 u32 txHead; 190 u32 tx_head;
187 u32 txInProgress; 191 u32 tx_in_progress;
188 u32 txTail; 192 u32 tx_tail;
189 u32 txBusyCount; 193 u32 tx_busy_count;
190 u32 phyOnline; 194 u32 phy_online;
191 u32 timerSetAt; 195 u32 timer_set_at;
192 u32 timerType; 196 u32 timer_type;
193 struct timer_list timer; 197 struct timer_list timer;
194 struct board *adapter; 198 struct board *adapter;
195 u32 adapterRev; 199 u32 adapter_rev;
196 u32 aui; 200 u32 aui;
197 u32 debug; 201 u32 debug;
198 u32 duplex; 202 u32 duplex;
199 u32 phy[2]; 203 u32 phy[2];
200 u32 phyNum; 204 u32 phy_num;
201 u32 speed; 205 u32 speed;
202 u8 tlanRev; 206 u8 tlan_rev;
203 u8 tlanFullDuplex; 207 u8 tlan_full_duplex;
204 spinlock_t lock; 208 spinlock_t lock;
205 u8 link; 209 u8 link;
206 u8 is_eisa; 210 u8 is_eisa;
207 struct work_struct tlan_tqueue; 211 struct work_struct tlan_tqueue;
208 u8 neg_be_verbose; 212 u8 neg_be_verbose;
209} TLanPrivateInfo; 213};
210 214
211 215
212 216
@@ -247,7 +251,7 @@ typedef struct tlan_private_tag {
247 ****************************************************************/ 251 ****************************************************************/
248 252
249#define TLAN_HOST_CMD 0x00 253#define TLAN_HOST_CMD 0x00
250#define TLAN_HC_GO 0x80000000 254#define TLAN_HC_GO 0x80000000
251#define TLAN_HC_STOP 0x40000000 255#define TLAN_HC_STOP 0x40000000
252#define TLAN_HC_ACK 0x20000000 256#define TLAN_HC_ACK 0x20000000
253#define TLAN_HC_CS_MASK 0x1FE00000 257#define TLAN_HC_CS_MASK 0x1FE00000
@@ -283,7 +287,7 @@ typedef struct tlan_private_tag {
283#define TLAN_NET_CMD_TRFRAM 0x02 287#define TLAN_NET_CMD_TRFRAM 0x02
284#define TLAN_NET_CMD_TXPACE 0x01 288#define TLAN_NET_CMD_TXPACE 0x01
285#define TLAN_NET_SIO 0x01 289#define TLAN_NET_SIO 0x01
286#define TLAN_NET_SIO_MINTEN 0x80 290#define TLAN_NET_SIO_MINTEN 0x80
287#define TLAN_NET_SIO_ECLOK 0x40 291#define TLAN_NET_SIO_ECLOK 0x40
288#define TLAN_NET_SIO_ETXEN 0x20 292#define TLAN_NET_SIO_ETXEN 0x20
289#define TLAN_NET_SIO_EDATA 0x10 293#define TLAN_NET_SIO_EDATA 0x10
@@ -304,7 +308,7 @@ typedef struct tlan_private_tag {
304#define TLAN_NET_MASK_MASK4 0x10 308#define TLAN_NET_MASK_MASK4 0x10
305#define TLAN_NET_MASK_RSRVD 0x0F 309#define TLAN_NET_MASK_RSRVD 0x0F
306#define TLAN_NET_CONFIG 0x04 310#define TLAN_NET_CONFIG 0x04
307#define TLAN_NET_CFG_RCLK 0x8000 311#define TLAN_NET_CFG_RCLK 0x8000
308#define TLAN_NET_CFG_TCLK 0x4000 312#define TLAN_NET_CFG_TCLK 0x4000
309#define TLAN_NET_CFG_BIT 0x2000 313#define TLAN_NET_CFG_BIT 0x2000
310#define TLAN_NET_CFG_RXCRC 0x1000 314#define TLAN_NET_CFG_RXCRC 0x1000
@@ -372,7 +376,7 @@ typedef struct tlan_private_tag {
372/* Generic MII/PHY Registers */ 376/* Generic MII/PHY Registers */
373 377
374#define MII_GEN_CTL 0x00 378#define MII_GEN_CTL 0x00
375#define MII_GC_RESET 0x8000 379#define MII_GC_RESET 0x8000
376#define MII_GC_LOOPBK 0x4000 380#define MII_GC_LOOPBK 0x4000
377#define MII_GC_SPEEDSEL 0x2000 381#define MII_GC_SPEEDSEL 0x2000
378#define MII_GC_AUTOENB 0x1000 382#define MII_GC_AUTOENB 0x1000
@@ -397,9 +401,9 @@ typedef struct tlan_private_tag {
397#define MII_GS_EXTCAP 0x0001 401#define MII_GS_EXTCAP 0x0001
398#define MII_GEN_ID_HI 0x02 402#define MII_GEN_ID_HI 0x02
399#define MII_GEN_ID_LO 0x03 403#define MII_GEN_ID_LO 0x03
400#define MII_GIL_OUI 0xFC00 404#define MII_GIL_OUI 0xFC00
401#define MII_GIL_MODEL 0x03F0 405#define MII_GIL_MODEL 0x03F0
402#define MII_GIL_REVISION 0x000F 406#define MII_GIL_REVISION 0x000F
403#define MII_AN_ADV 0x04 407#define MII_AN_ADV 0x04
404#define MII_AN_LPA 0x05 408#define MII_AN_LPA 0x05
405#define MII_AN_EXP 0x06 409#define MII_AN_EXP 0x06
@@ -408,7 +412,7 @@ typedef struct tlan_private_tag {
408 412
409#define TLAN_TLPHY_ID 0x10 413#define TLAN_TLPHY_ID 0x10
410#define TLAN_TLPHY_CTL 0x11 414#define TLAN_TLPHY_CTL 0x11
411#define TLAN_TC_IGLINK 0x8000 415#define TLAN_TC_IGLINK 0x8000
412#define TLAN_TC_SWAPOL 0x4000 416#define TLAN_TC_SWAPOL 0x4000
413#define TLAN_TC_AUISEL 0x2000 417#define TLAN_TC_AUISEL 0x2000
414#define TLAN_TC_SQEEN 0x1000 418#define TLAN_TC_SQEEN 0x1000
@@ -435,41 +439,41 @@ typedef struct tlan_private_tag {
435#define LEVEL1_ID1 0x7810 439#define LEVEL1_ID1 0x7810
436#define LEVEL1_ID2 0x0000 440#define LEVEL1_ID2 0x0000
437 441
438#define CIRC_INC( a, b ) if ( ++a >= b ) a = 0 442#define CIRC_INC(a, b) if (++a >= b) a = 0
439 443
440/* Routines to access internal registers. */ 444/* Routines to access internal registers. */
441 445
442static inline u8 TLan_DioRead8(u16 base_addr, u16 internal_addr) 446static inline u8 tlan_dio_read8(u16 base_addr, u16 internal_addr)
443{ 447{
444 outw(internal_addr, base_addr + TLAN_DIO_ADR); 448 outw(internal_addr, base_addr + TLAN_DIO_ADR);
445 return inb((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x3)); 449 return inb((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x3));
446 450
447} /* TLan_DioRead8 */ 451}
448 452
449 453
450 454
451 455
452static inline u16 TLan_DioRead16(u16 base_addr, u16 internal_addr) 456static inline u16 tlan_dio_read16(u16 base_addr, u16 internal_addr)
453{ 457{
454 outw(internal_addr, base_addr + TLAN_DIO_ADR); 458 outw(internal_addr, base_addr + TLAN_DIO_ADR);
455 return inw((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x2)); 459 return inw((base_addr + TLAN_DIO_DATA) + (internal_addr & 0x2));
456 460
457} /* TLan_DioRead16 */ 461}
458 462
459 463
460 464
461 465
462static inline u32 TLan_DioRead32(u16 base_addr, u16 internal_addr) 466static inline u32 tlan_dio_read32(u16 base_addr, u16 internal_addr)
463{ 467{
464 outw(internal_addr, base_addr + TLAN_DIO_ADR); 468 outw(internal_addr, base_addr + TLAN_DIO_ADR);
465 return inl(base_addr + TLAN_DIO_DATA); 469 return inl(base_addr + TLAN_DIO_DATA);
466 470
467} /* TLan_DioRead32 */ 471}
468 472
469 473
470 474
471 475
472static inline void TLan_DioWrite8(u16 base_addr, u16 internal_addr, u8 data) 476static inline void tlan_dio_write8(u16 base_addr, u16 internal_addr, u8 data)
473{ 477{
474 outw(internal_addr, base_addr + TLAN_DIO_ADR); 478 outw(internal_addr, base_addr + TLAN_DIO_ADR);
475 outb(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x3)); 479 outb(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x3));
@@ -479,7 +483,7 @@ static inline void TLan_DioWrite8(u16 base_addr, u16 internal_addr, u8 data)
479 483
480 484
481 485
482static inline void TLan_DioWrite16(u16 base_addr, u16 internal_addr, u16 data) 486static inline void tlan_dio_write16(u16 base_addr, u16 internal_addr, u16 data)
483{ 487{
484 outw(internal_addr, base_addr + TLAN_DIO_ADR); 488 outw(internal_addr, base_addr + TLAN_DIO_ADR);
485 outw(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2)); 489 outw(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2));
@@ -489,16 +493,16 @@ static inline void TLan_DioWrite16(u16 base_addr, u16 internal_addr, u16 data)
489 493
490 494
491 495
492static inline void TLan_DioWrite32(u16 base_addr, u16 internal_addr, u32 data) 496static inline void tlan_dio_write32(u16 base_addr, u16 internal_addr, u32 data)
493{ 497{
494 outw(internal_addr, base_addr + TLAN_DIO_ADR); 498 outw(internal_addr, base_addr + TLAN_DIO_ADR);
495 outl(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2)); 499 outl(data, base_addr + TLAN_DIO_DATA + (internal_addr & 0x2));
496 500
497} 501}
498 502
499#define TLan_ClearBit( bit, port ) outb_p(inb_p(port) & ~bit, port) 503#define tlan_clear_bit(bit, port) outb_p(inb_p(port) & ~bit, port)
500#define TLan_GetBit( bit, port ) ((int) (inb_p(port) & bit)) 504#define tlan_get_bit(bit, port) ((int) (inb_p(port) & bit))
501#define TLan_SetBit( bit, port ) outb_p(inb_p(port) | bit, port) 505#define tlan_set_bit(bit, port) outb_p(inb_p(port) | bit, port)
502 506
503/* 507/*
504 * given 6 bytes, view them as 8 6-bit numbers and return the XOR of those 508 * given 6 bytes, view them as 8 6-bit numbers and return the XOR of those
@@ -506,37 +510,37 @@ static inline void TLan_DioWrite32(u16 base_addr, u16 internal_addr, u32 data)
506 * 510 *
507 * The original code was: 511 * The original code was:
508 * 512 *
509 * u32 xor( u32 a, u32 b ) { return ( ( a && ! b ) || ( ! a && b ) ); } 513 * u32 xor(u32 a, u32 b) { return ((a && !b ) || (! a && b )); }
510 * 514 *
511 * #define XOR8( a, b, c, d, e, f, g, h ) \ 515 * #define XOR8(a, b, c, d, e, f, g, h) \
512 * xor( a, xor( b, xor( c, xor( d, xor( e, xor( f, xor( g, h ) ) ) ) ) ) ) 516 * xor(a, xor(b, xor(c, xor(d, xor(e, xor(f, xor(g, h)) ) ) ) ) )
513 * #define DA( a, bit ) ( ( (u8) a[bit/8] ) & ( (u8) ( 1 << bit%8 ) ) ) 517 * #define DA(a, bit) (( (u8) a[bit/8] ) & ( (u8) (1 << bit%8)) )
514 * 518 *
515 * hash = XOR8( DA(a,0), DA(a, 6), DA(a,12), DA(a,18), DA(a,24), 519 * hash = XOR8(DA(a,0), DA(a, 6), DA(a,12), DA(a,18), DA(a,24),
516 * DA(a,30), DA(a,36), DA(a,42) ); 520 * DA(a,30), DA(a,36), DA(a,42));
517 * hash |= XOR8( DA(a,1), DA(a, 7), DA(a,13), DA(a,19), DA(a,25), 521 * hash |= XOR8(DA(a,1), DA(a, 7), DA(a,13), DA(a,19), DA(a,25),
518 * DA(a,31), DA(a,37), DA(a,43) ) << 1; 522 * DA(a,31), DA(a,37), DA(a,43)) << 1;
519 * hash |= XOR8( DA(a,2), DA(a, 8), DA(a,14), DA(a,20), DA(a,26), 523 * hash |= XOR8(DA(a,2), DA(a, 8), DA(a,14), DA(a,20), DA(a,26),
520 * DA(a,32), DA(a,38), DA(a,44) ) << 2; 524 * DA(a,32), DA(a,38), DA(a,44)) << 2;
521 * hash |= XOR8( DA(a,3), DA(a, 9), DA(a,15), DA(a,21), DA(a,27), 525 * hash |= XOR8(DA(a,3), DA(a, 9), DA(a,15), DA(a,21), DA(a,27),
522 * DA(a,33), DA(a,39), DA(a,45) ) << 3; 526 * DA(a,33), DA(a,39), DA(a,45)) << 3;
523 * hash |= XOR8( DA(a,4), DA(a,10), DA(a,16), DA(a,22), DA(a,28), 527 * hash |= XOR8(DA(a,4), DA(a,10), DA(a,16), DA(a,22), DA(a,28),
524 * DA(a,34), DA(a,40), DA(a,46) ) << 4; 528 * DA(a,34), DA(a,40), DA(a,46)) << 4;
525 * hash |= XOR8( DA(a,5), DA(a,11), DA(a,17), DA(a,23), DA(a,29), 529 * hash |= XOR8(DA(a,5), DA(a,11), DA(a,17), DA(a,23), DA(a,29),
526 * DA(a,35), DA(a,41), DA(a,47) ) << 5; 530 * DA(a,35), DA(a,41), DA(a,47)) << 5;
527 * 531 *
528 */ 532 */
529static inline u32 TLan_HashFunc( const u8 *a ) 533static inline u32 tlan_hash_func(const u8 *a)
530{ 534{
531 u8 hash; 535 u8 hash;
532 536
533 hash = (a[0]^a[3]); /* & 077 */ 537 hash = (a[0]^a[3]); /* & 077 */
534 hash ^= ((a[0]^a[3])>>6); /* & 003 */ 538 hash ^= ((a[0]^a[3])>>6); /* & 003 */
535 hash ^= ((a[1]^a[4])<<2); /* & 074 */ 539 hash ^= ((a[1]^a[4])<<2); /* & 074 */
536 hash ^= ((a[1]^a[4])>>4); /* & 017 */ 540 hash ^= ((a[1]^a[4])>>4); /* & 017 */
537 hash ^= ((a[2]^a[5])<<4); /* & 060 */ 541 hash ^= ((a[2]^a[5])<<4); /* & 060 */
538 hash ^= ((a[2]^a[5])>>2); /* & 077 */ 542 hash ^= ((a[2]^a[5])>>2); /* & 077 */
539 543
540 return hash & 077; 544 return hash & 077;
541} 545}
542#endif 546#endif