aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoberto Medina <robertoxmed@gmail.com>2014-10-27 19:51:56 -0400
committerDavid S. Miller <davem@davemloft.net>2014-10-29 14:52:06 -0400
commit7aef06db0f91c7b48305d07b62edf43179adb28c (patch)
tree10665e087047d01f6e41ca04db2927561f41acd0
parent432c856fcf45c468fffe2e5029cb3f95c7dc9475 (diff)
net: ethernet: realtek: atp: checkpatch errors and warnings corrected
Several warnings and errors of coding style rules corrected. Compile tested. Signed-off-by: Roberto Medina <robertoxmed@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/realtek/atp.h246
1 files changed, 127 insertions, 119 deletions
diff --git a/drivers/net/ethernet/realtek/atp.h b/drivers/net/ethernet/realtek/atp.h
index 040b13739947..32497f0e537c 100644
--- a/drivers/net/ethernet/realtek/atp.h
+++ b/drivers/net/ethernet/realtek/atp.h
@@ -6,10 +6,10 @@
6 6
7/* The header prepended to received packets. */ 7/* The header prepended to received packets. */
8struct rx_header { 8struct rx_header {
9 ushort pad; /* Pad. */ 9 ushort pad; /* Pad. */
10 ushort rx_count; 10 ushort rx_count;
11 ushort rx_status; /* Unknown bit assignments :-<. */ 11 ushort rx_status; /* Unknown bit assignments :-<. */
12 ushort cur_addr; /* Apparently the current buffer address(?) */ 12 ushort cur_addr; /* Apparently the current buffer address(?) */
13}; 13};
14 14
15#define PAR_DATA 0 15#define PAR_DATA 0
@@ -29,22 +29,25 @@ struct rx_header {
29#define RdAddr 0xC0 29#define RdAddr 0xC0
30#define HNib 0x10 30#define HNib 0x10
31 31
32enum page0_regs 32enum page0_regs {
33{ 33 /* The first six registers hold
34 /* The first six registers hold the ethernet physical station address. */ 34 * the ethernet physical station address.
35 PAR0 = 0, PAR1 = 1, PAR2 = 2, PAR3 = 3, PAR4 = 4, PAR5 = 5, 35 */
36 TxCNT0 = 6, TxCNT1 = 7, /* The transmit byte count. */ 36 PAR0 = 0, PAR1 = 1, PAR2 = 2, PAR3 = 3, PAR4 = 4, PAR5 = 5,
37 TxSTAT = 8, RxSTAT = 9, /* Tx and Rx status. */ 37 TxCNT0 = 6, TxCNT1 = 7, /* The transmit byte count. */
38 ISR = 10, IMR = 11, /* Interrupt status and mask. */ 38 TxSTAT = 8, RxSTAT = 9, /* Tx and Rx status. */
39 CMR1 = 12, /* Command register 1. */ 39 ISR = 10, IMR = 11, /* Interrupt status and mask. */
40 CMR2 = 13, /* Command register 2. */ 40 CMR1 = 12, /* Command register 1. */
41 MODSEL = 14, /* Mode select register. */ 41 CMR2 = 13, /* Command register 2. */
42 MAR = 14, /* Memory address register (?). */ 42 MODSEL = 14, /* Mode select register. */
43 CMR2_h = 0x1d, }; 43 MAR = 14, /* Memory address register (?). */
44 44 CMR2_h = 0x1d,
45enum eepage_regs 45};
46{ PROM_CMD = 6, PROM_DATA = 7 }; /* Note that PROM_CMD is in the "high" bits. */
47 46
47enum eepage_regs {
48 PROM_CMD = 6,
49 PROM_DATA = 7 /* Note that PROM_CMD is in the "high" bits. */
50};
48 51
49#define ISR_TxOK 0x01 52#define ISR_TxOK 0x01
50#define ISR_RxOK 0x04 53#define ISR_RxOK 0x04
@@ -72,141 +75,146 @@ enum eepage_regs
72#define CMR2h_Normal 2 /* Accept physical and broadcast address. */ 75#define CMR2h_Normal 2 /* Accept physical and broadcast address. */
73#define CMR2h_PROMISC 3 /* Promiscuous mode. */ 76#define CMR2h_PROMISC 3 /* Promiscuous mode. */
74 77
75/* An inline function used below: it differs from inb() by explicitly return an unsigned 78/* An inline function used below: it differs from inb() by explicitly
76 char, saving a truncation. */ 79 * return an unsigned char, saving a truncation.
80 */
77static inline unsigned char inbyte(unsigned short port) 81static inline unsigned char inbyte(unsigned short port)
78{ 82{
79 unsigned char _v; 83 unsigned char _v;
80 __asm__ __volatile__ ("inb %w1,%b0" :"=a" (_v):"d" (port)); 84
81 return _v; 85 __asm__ __volatile__ ("inb %w1,%b0" : "=a" (_v) : "d" (port));
86 return _v;
82} 87}
83 88
84/* Read register OFFSET. 89/* Read register OFFSET.
85 This command should always be terminated with read_end(). */ 90 * This command should always be terminated with read_end().
91 */
86static inline unsigned char read_nibble(short port, unsigned char offset) 92static inline unsigned char read_nibble(short port, unsigned char offset)
87{ 93{
88 unsigned char retval; 94 unsigned char retval;
89 outb(EOC+offset, port + PAR_DATA); 95
90 outb(RdAddr+offset, port + PAR_DATA); 96 outb(EOC+offset, port + PAR_DATA);
91 inbyte(port + PAR_STATUS); /* Settling time delay */ 97 outb(RdAddr+offset, port + PAR_DATA);
92 retval = inbyte(port + PAR_STATUS); 98 inbyte(port + PAR_STATUS); /* Settling time delay */
93 outb(EOC+offset, port + PAR_DATA); 99 retval = inbyte(port + PAR_STATUS);
94 100 outb(EOC+offset, port + PAR_DATA);
95 return retval; 101
102 return retval;
96} 103}
97 104
98/* Functions for bulk data read. The interrupt line is always disabled. */ 105/* Functions for bulk data read. The interrupt line is always disabled. */
99/* Get a byte using read mode 0, reading data from the control lines. */ 106/* Get a byte using read mode 0, reading data from the control lines. */
100static inline unsigned char read_byte_mode0(short ioaddr) 107static inline unsigned char read_byte_mode0(short ioaddr)
101{ 108{
102 unsigned char low_nib; 109 unsigned char low_nib;
103 110
104 outb(Ctrl_LNibRead, ioaddr + PAR_CONTROL); 111 outb(Ctrl_LNibRead, ioaddr + PAR_CONTROL);
105 inbyte(ioaddr + PAR_STATUS); 112 inbyte(ioaddr + PAR_STATUS);
106 low_nib = (inbyte(ioaddr + PAR_STATUS) >> 3) & 0x0f; 113 low_nib = (inbyte(ioaddr + PAR_STATUS) >> 3) & 0x0f;
107 outb(Ctrl_HNibRead, ioaddr + PAR_CONTROL); 114 outb(Ctrl_HNibRead, ioaddr + PAR_CONTROL);
108 inbyte(ioaddr + PAR_STATUS); /* Settling time delay -- needed! */ 115 inbyte(ioaddr + PAR_STATUS); /* Settling time delay -- needed! */
109 inbyte(ioaddr + PAR_STATUS); /* Settling time delay -- needed! */ 116 inbyte(ioaddr + PAR_STATUS); /* Settling time delay -- needed! */
110 return low_nib | ((inbyte(ioaddr + PAR_STATUS) << 1) & 0xf0); 117 return low_nib | ((inbyte(ioaddr + PAR_STATUS) << 1) & 0xf0);
111} 118}
112 119
113/* The same as read_byte_mode0(), but does multiple inb()s for stability. */ 120/* The same as read_byte_mode0(), but does multiple inb()s for stability. */
114static inline unsigned char read_byte_mode2(short ioaddr) 121static inline unsigned char read_byte_mode2(short ioaddr)
115{ 122{
116 unsigned char low_nib; 123 unsigned char low_nib;
117 124
118 outb(Ctrl_LNibRead, ioaddr + PAR_CONTROL); 125 outb(Ctrl_LNibRead, ioaddr + PAR_CONTROL);
119 inbyte(ioaddr + PAR_STATUS); 126 inbyte(ioaddr + PAR_STATUS);
120 low_nib = (inbyte(ioaddr + PAR_STATUS) >> 3) & 0x0f; 127 low_nib = (inbyte(ioaddr + PAR_STATUS) >> 3) & 0x0f;
121 outb(Ctrl_HNibRead, ioaddr + PAR_CONTROL); 128 outb(Ctrl_HNibRead, ioaddr + PAR_CONTROL);
122 inbyte(ioaddr + PAR_STATUS); /* Settling time delay -- needed! */ 129 inbyte(ioaddr + PAR_STATUS); /* Settling time delay -- needed! */
123 return low_nib | ((inbyte(ioaddr + PAR_STATUS) << 1) & 0xf0); 130 return low_nib | ((inbyte(ioaddr + PAR_STATUS) << 1) & 0xf0);
124} 131}
125 132
126/* Read a byte through the data register. */ 133/* Read a byte through the data register. */
127static inline unsigned char read_byte_mode4(short ioaddr) 134static inline unsigned char read_byte_mode4(short ioaddr)
128{ 135{
129 unsigned char low_nib; 136 unsigned char low_nib;
130 137
131 outb(RdAddr | MAR, ioaddr + PAR_DATA); 138 outb(RdAddr | MAR, ioaddr + PAR_DATA);
132 low_nib = (inbyte(ioaddr + PAR_STATUS) >> 3) & 0x0f; 139 low_nib = (inbyte(ioaddr + PAR_STATUS) >> 3) & 0x0f;
133 outb(RdAddr | HNib | MAR, ioaddr + PAR_DATA); 140 outb(RdAddr | HNib | MAR, ioaddr + PAR_DATA);
134 return low_nib | ((inbyte(ioaddr + PAR_STATUS) << 1) & 0xf0); 141 return low_nib | ((inbyte(ioaddr + PAR_STATUS) << 1) & 0xf0);
135} 142}
136 143
137/* Read a byte through the data register, double reading to allow settling. */ 144/* Read a byte through the data register, double reading to allow settling. */
138static inline unsigned char read_byte_mode6(short ioaddr) 145static inline unsigned char read_byte_mode6(short ioaddr)
139{ 146{
140 unsigned char low_nib; 147 unsigned char low_nib;
141 148
142 outb(RdAddr | MAR, ioaddr + PAR_DATA); 149 outb(RdAddr | MAR, ioaddr + PAR_DATA);
143 inbyte(ioaddr + PAR_STATUS); 150 inbyte(ioaddr + PAR_STATUS);
144 low_nib = (inbyte(ioaddr + PAR_STATUS) >> 3) & 0x0f; 151 low_nib = (inbyte(ioaddr + PAR_STATUS) >> 3) & 0x0f;
145 outb(RdAddr | HNib | MAR, ioaddr + PAR_DATA); 152 outb(RdAddr | HNib | MAR, ioaddr + PAR_DATA);
146 inbyte(ioaddr + PAR_STATUS); 153 inbyte(ioaddr + PAR_STATUS);
147 return low_nib | ((inbyte(ioaddr + PAR_STATUS) << 1) & 0xf0); 154 return low_nib | ((inbyte(ioaddr + PAR_STATUS) << 1) & 0xf0);
148} 155}
149 156
150static inline void 157static inline void
151write_reg(short port, unsigned char reg, unsigned char value) 158write_reg(short port, unsigned char reg, unsigned char value)
152{ 159{
153 unsigned char outval; 160 unsigned char outval;
154 outb(EOC | reg, port + PAR_DATA); 161
155 outval = WrAddr | reg; 162 outb(EOC | reg, port + PAR_DATA);
156 outb(outval, port + PAR_DATA); 163 outval = WrAddr | reg;
157 outb(outval, port + PAR_DATA); /* Double write for PS/2. */ 164 outb(outval, port + PAR_DATA);
158 165 outb(outval, port + PAR_DATA); /* Double write for PS/2. */
159 outval &= 0xf0; 166
160 outval |= value; 167 outval &= 0xf0;
161 outb(outval, port + PAR_DATA); 168 outval |= value;
162 outval &= 0x1f; 169 outb(outval, port + PAR_DATA);
163 outb(outval, port + PAR_DATA); 170 outval &= 0x1f;
164 outb(outval, port + PAR_DATA); 171 outb(outval, port + PAR_DATA);
165 172 outb(outval, port + PAR_DATA);
166 outb(EOC | outval, port + PAR_DATA); 173
174 outb(EOC | outval, port + PAR_DATA);
167} 175}
168 176
169static inline void 177static inline void
170write_reg_high(short port, unsigned char reg, unsigned char value) 178write_reg_high(short port, unsigned char reg, unsigned char value)
171{ 179{
172 unsigned char outval = EOC | HNib | reg; 180 unsigned char outval = EOC | HNib | reg;
173 181
174 outb(outval, port + PAR_DATA); 182 outb(outval, port + PAR_DATA);
175 outval &= WrAddr | HNib | 0x0f; 183 outval &= WrAddr | HNib | 0x0f;
176 outb(outval, port + PAR_DATA); 184 outb(outval, port + PAR_DATA);
177 outb(outval, port + PAR_DATA); /* Double write for PS/2. */ 185 outb(outval, port + PAR_DATA); /* Double write for PS/2. */
178 186
179 outval = WrAddr | HNib | value; 187 outval = WrAddr | HNib | value;
180 outb(outval, port + PAR_DATA); 188 outb(outval, port + PAR_DATA);
181 outval &= HNib | 0x0f; /* HNib | value */ 189 outval &= HNib | 0x0f; /* HNib | value */
182 outb(outval, port + PAR_DATA); 190 outb(outval, port + PAR_DATA);
183 outb(outval, port + PAR_DATA); 191 outb(outval, port + PAR_DATA);
184 192
185 outb(EOC | HNib | outval, port + PAR_DATA); 193 outb(EOC | HNib | outval, port + PAR_DATA);
186} 194}
187 195
188/* Write a byte out using nibble mode. The low nibble is written first. */ 196/* Write a byte out using nibble mode. The low nibble is written first. */
189static inline void 197static inline void
190write_reg_byte(short port, unsigned char reg, unsigned char value) 198write_reg_byte(short port, unsigned char reg, unsigned char value)
191{ 199{
192 unsigned char outval; 200 unsigned char outval;
193 outb(EOC | reg, port + PAR_DATA); /* Reset the address register. */ 201
194 outval = WrAddr | reg; 202 outb(EOC | reg, port + PAR_DATA); /* Reset the address register. */
195 outb(outval, port + PAR_DATA); 203 outval = WrAddr | reg;
196 outb(outval, port + PAR_DATA); /* Double write for PS/2. */ 204 outb(outval, port + PAR_DATA);
197 205 outb(outval, port + PAR_DATA); /* Double write for PS/2. */
198 outb((outval & 0xf0) | (value & 0x0f), port + PAR_DATA); 206
199 outb(value & 0x0f, port + PAR_DATA); 207 outb((outval & 0xf0) | (value & 0x0f), port + PAR_DATA);
200 value >>= 4; 208 outb(value & 0x0f, port + PAR_DATA);
201 outb(value, port + PAR_DATA); 209 value >>= 4;
202 outb(0x10 | value, port + PAR_DATA); 210 outb(value, port + PAR_DATA);
203 outb(0x10 | value, port + PAR_DATA); 211 outb(0x10 | value, port + PAR_DATA);
204 212 outb(0x10 | value, port + PAR_DATA);
205 outb(EOC | value, port + PAR_DATA); /* Reset the address register. */ 213
214 outb(EOC | value, port + PAR_DATA); /* Reset the address register. */
206} 215}
207 216
208/* 217/* Bulk data writes to the packet buffer. The interrupt line remains enabled.
209 * Bulk data writes to the packet buffer. The interrupt line remains enabled.
210 * The first, faster method uses only the dataport (data modes 0, 2 & 4). 218 * The first, faster method uses only the dataport (data modes 0, 2 & 4).
211 * The second (backup) method uses data and control regs (modes 1, 3 & 5). 219 * The second (backup) method uses data and control regs (modes 1, 3 & 5).
212 * It should only be needed when there is skew between the individual data 220 * It should only be needed when there is skew between the individual data
@@ -214,28 +222,28 @@ write_reg_byte(short port, unsigned char reg, unsigned char value)
214 */ 222 */
215static inline void write_byte_mode0(short ioaddr, unsigned char value) 223static inline void write_byte_mode0(short ioaddr, unsigned char value)
216{ 224{
217 outb(value & 0x0f, ioaddr + PAR_DATA); 225 outb(value & 0x0f, ioaddr + PAR_DATA);
218 outb((value>>4) | 0x10, ioaddr + PAR_DATA); 226 outb((value>>4) | 0x10, ioaddr + PAR_DATA);
219} 227}
220 228
221static inline void write_byte_mode1(short ioaddr, unsigned char value) 229static inline void write_byte_mode1(short ioaddr, unsigned char value)
222{ 230{
223 outb(value & 0x0f, ioaddr + PAR_DATA); 231 outb(value & 0x0f, ioaddr + PAR_DATA);
224 outb(Ctrl_IRQEN | Ctrl_LNibWrite, ioaddr + PAR_CONTROL); 232 outb(Ctrl_IRQEN | Ctrl_LNibWrite, ioaddr + PAR_CONTROL);
225 outb((value>>4) | 0x10, ioaddr + PAR_DATA); 233 outb((value>>4) | 0x10, ioaddr + PAR_DATA);
226 outb(Ctrl_IRQEN | Ctrl_HNibWrite, ioaddr + PAR_CONTROL); 234 outb(Ctrl_IRQEN | Ctrl_HNibWrite, ioaddr + PAR_CONTROL);
227} 235}
228 236
229/* Write 16bit VALUE to the packet buffer: the same as above just doubled. */ 237/* Write 16bit VALUE to the packet buffer: the same as above just doubled. */
230static inline void write_word_mode0(short ioaddr, unsigned short value) 238static inline void write_word_mode0(short ioaddr, unsigned short value)
231{ 239{
232 outb(value & 0x0f, ioaddr + PAR_DATA); 240 outb(value & 0x0f, ioaddr + PAR_DATA);
233 value >>= 4; 241 value >>= 4;
234 outb((value & 0x0f) | 0x10, ioaddr + PAR_DATA); 242 outb((value & 0x0f) | 0x10, ioaddr + PAR_DATA);
235 value >>= 4; 243 value >>= 4;
236 outb(value & 0x0f, ioaddr + PAR_DATA); 244 outb(value & 0x0f, ioaddr + PAR_DATA);
237 value >>= 4; 245 value >>= 4;
238 outb((value & 0x0f) | 0x10, ioaddr + PAR_DATA); 246 outb((value & 0x0f) | 0x10, ioaddr + PAR_DATA);
239} 247}
240 248
241/* EEPROM_Ctrl bits. */ 249/* EEPROM_Ctrl bits. */
@@ -248,10 +256,10 @@ static inline void write_word_mode0(short ioaddr, unsigned short value)
248 256
249/* Delay between EEPROM clock transitions. */ 257/* Delay between EEPROM clock transitions. */
250#define eeprom_delay(ticks) \ 258#define eeprom_delay(ticks) \
251do { int _i = 40; while (--_i > 0) { __SLOW_DOWN_IO; }} while (0) 259do { int _i = 40; while (--_i > 0) { __SLOW_DOWN_IO; } } while (0)
252 260
253/* The EEPROM commands include the alway-set leading bit. */ 261/* The EEPROM commands include the alway-set leading bit. */
254#define EE_WRITE_CMD(offset) (((5 << 6) + (offset)) << 17) 262#define EE_WRITE_CMD(offset) (((5 << 6) + (offset)) << 17)
255#define EE_READ(offset) (((6 << 6) + (offset)) << 17) 263#define EE_READ(offset) (((6 << 6) + (offset)) << 17)
256#define EE_ERASE(offset) (((7 << 6) + (offset)) << 17) 264#define EE_ERASE(offset) (((7 << 6) + (offset)) << 17)
257#define EE_CMD_SIZE 27 /* The command+address+data size. */ 265#define EE_CMD_SIZE 27 /* The command+address+data size. */