Commit d133ae4cd6a3c75c31b1630f906cc9979a11077f

Authored by Pavel Roskin
Committed by Jeff Garzik
1 parent 393da59834

[PATCH] orinoco: Annotate endianess of variables and structure members.

Signed-off-by: Pavel Roskin <proski@gnu.org>

Annotate endianess of variables and structure members.

Don't reuse variables for both host-endian and little-endian data.
Minor comment changes in affected structures.
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>

Showing 4 changed files with 99 additions and 97 deletions Side-by-side Diff

drivers/net/wireless/hermes.h
... ... @@ -191,13 +191,13 @@
191 191 #define HERMES_RXSTAT_WMP (0x6000) /* Wavelan-II Management Protocol frame */
192 192  
193 193 struct hermes_tx_descriptor {
194   - u16 status;
195   - u16 reserved1;
196   - u16 reserved2;
197   - u32 sw_support;
  194 + __le16 status;
  195 + __le16 reserved1;
  196 + __le16 reserved2;
  197 + __le32 sw_support;
198 198 u8 retry_count;
199 199 u8 tx_rate;
200   - u16 tx_control;
  200 + __le16 tx_control;
201 201 } __attribute__ ((packed));
202 202  
203 203 #define HERMES_TXSTAT_RETRYERR (0x0001)
204 204  
205 205  
206 206  
207 207  
208 208  
209 209  
210 210  
... ... @@ -221,60 +221,60 @@
221 221 #define HERMES_INQ_SEC_STAT_AGERE (0xF202)
222 222  
223 223 struct hermes_tallies_frame {
224   - u16 TxUnicastFrames;
225   - u16 TxMulticastFrames;
226   - u16 TxFragments;
227   - u16 TxUnicastOctets;
228   - u16 TxMulticastOctets;
229   - u16 TxDeferredTransmissions;
230   - u16 TxSingleRetryFrames;
231   - u16 TxMultipleRetryFrames;
232   - u16 TxRetryLimitExceeded;
233   - u16 TxDiscards;
234   - u16 RxUnicastFrames;
235   - u16 RxMulticastFrames;
236   - u16 RxFragments;
237   - u16 RxUnicastOctets;
238   - u16 RxMulticastOctets;
239   - u16 RxFCSErrors;
240   - u16 RxDiscards_NoBuffer;
241   - u16 TxDiscardsWrongSA;
242   - u16 RxWEPUndecryptable;
243   - u16 RxMsgInMsgFragments;
244   - u16 RxMsgInBadMsgFragments;
  224 + __le16 TxUnicastFrames;
  225 + __le16 TxMulticastFrames;
  226 + __le16 TxFragments;
  227 + __le16 TxUnicastOctets;
  228 + __le16 TxMulticastOctets;
  229 + __le16 TxDeferredTransmissions;
  230 + __le16 TxSingleRetryFrames;
  231 + __le16 TxMultipleRetryFrames;
  232 + __le16 TxRetryLimitExceeded;
  233 + __le16 TxDiscards;
  234 + __le16 RxUnicastFrames;
  235 + __le16 RxMulticastFrames;
  236 + __le16 RxFragments;
  237 + __le16 RxUnicastOctets;
  238 + __le16 RxMulticastOctets;
  239 + __le16 RxFCSErrors;
  240 + __le16 RxDiscards_NoBuffer;
  241 + __le16 TxDiscardsWrongSA;
  242 + __le16 RxWEPUndecryptable;
  243 + __le16 RxMsgInMsgFragments;
  244 + __le16 RxMsgInBadMsgFragments;
245 245 /* Those last are probably not available in very old firmwares */
246   - u16 RxDiscards_WEPICVError;
247   - u16 RxDiscards_WEPExcluded;
  246 + __le16 RxDiscards_WEPICVError;
  247 + __le16 RxDiscards_WEPExcluded;
248 248 } __attribute__ ((packed));
249 249  
250 250 /* Grabbed from wlan-ng - Thanks Mark... - Jean II
251 251 * This is the result of a scan inquiry command */
252 252 /* Structure describing info about an Access Point */
253 253 struct prism2_scan_apinfo {
254   - u16 channel; /* Channel where the AP sits */
255   - u16 noise; /* Noise level */
256   - u16 level; /* Signal level */
  254 + __le16 channel; /* Channel where the AP sits */
  255 + __le16 noise; /* Noise level */
  256 + __le16 level; /* Signal level */
257 257 u8 bssid[ETH_ALEN]; /* MAC address of the Access Point */
258   - u16 beacon_interv; /* Beacon interval */
259   - u16 capabilities; /* Capabilities */
260   - u16 essid_len; /* ESSID length */
  258 + __le16 beacon_interv; /* Beacon interval */
  259 + __le16 capabilities; /* Capabilities */
  260 + __le16 essid_len; /* ESSID length */
261 261 u8 essid[32]; /* ESSID of the network */
262 262 u8 rates[10]; /* Bit rate supported */
263   - u16 proberesp_rate; /* Data rate of the response frame */
264   - u16 atim; /* ATIM window time, Kus (hostscan only) */
  263 + __le16 proberesp_rate; /* Data rate of the response frame */
  264 + __le16 atim; /* ATIM window time, Kus (hostscan only) */
265 265 } __attribute__ ((packed));
266 266  
267 267 /* Same stuff for the Lucent/Agere card.
268 268 * Thanks to h1kari <h1kari AT dachb0den.com> - Jean II */
269 269 struct agere_scan_apinfo {
270   - u16 channel; /* Channel where the AP sits */
271   - u16 noise; /* Noise level */
272   - u16 level; /* Signal level */
  270 + __le16 channel; /* Channel where the AP sits */
  271 + __le16 noise; /* Noise level */
  272 + __le16 level; /* Signal level */
273 273 u8 bssid[ETH_ALEN]; /* MAC address of the Access Point */
274   - u16 beacon_interv; /* Beacon interval */
275   - u16 capabilities; /* Capabilities */
  274 + __le16 beacon_interv; /* Beacon interval */
  275 + __le16 capabilities; /* Capabilities */
276 276 /* bits: 0-ess, 1-ibss, 4-privacy [wep] */
277   - u16 essid_len; /* ESSID length */
  277 + __le16 essid_len; /* ESSID length */
278 278 u8 essid[32]; /* ESSID of the network */
279 279 } __attribute__ ((packed));
280 280  
281 281  
282 282  
283 283  
... ... @@ -282,16 +282,16 @@
282 282 struct symbol_scan_apinfo {
283 283 u8 channel; /* Channel where the AP sits */
284 284 u8 unknown1; /* 8 in 2.9x and 3.9x f/w, 0 otherwise */
285   - u16 noise; /* Noise level */
286   - u16 level; /* Signal level */
  285 + __le16 noise; /* Noise level */
  286 + __le16 level; /* Signal level */
287 287 u8 bssid[ETH_ALEN]; /* MAC address of the Access Point */
288   - u16 beacon_interv; /* Beacon interval */
289   - u16 capabilities; /* Capabilities */
  288 + __le16 beacon_interv; /* Beacon interval */
  289 + __le16 capabilities; /* Capabilities */
290 290 /* bits: 0-ess, 1-ibss, 4-privacy [wep] */
291   - u16 essid_len; /* ESSID length */
  291 + __le16 essid_len; /* ESSID length */
292 292 u8 essid[32]; /* ESSID of the network */
293   - u16 rates[5]; /* Bit rate supported */
294   - u16 basic_rates; /* Basic rates bitmask */
  293 + __le16 rates[5]; /* Bit rate supported */
  294 + __le16 basic_rates; /* Basic rates bitmask */
295 295 u8 unknown2[6]; /* Always FF:FF:FF:FF:00:00 */
296 296 u8 unknown3[8]; /* Always 0, appeared in f/w 3.91-68 */
297 297 } __attribute__ ((packed));
... ... @@ -311,7 +311,7 @@
311 311 #define HERMES_LINKSTATUS_ASSOC_FAILED (0x0006)
312 312  
313 313 struct hermes_linkstatus {
314   - u16 linkstatus; /* Link status */
  314 + __le16 linkstatus; /* Link status */
315 315 } __attribute__ ((packed));
316 316  
317 317 struct hermes_response {
... ... @@ -320,8 +320,8 @@
320 320  
321 321 /* "ID" structure - used for ESSID and station nickname */
322 322 struct hermes_idstring {
323   - u16 len;
324   - u16 val[16];
  323 + __le16 len;
  324 + __le16 val[16];
325 325 } __attribute__ ((packed));
326 326  
327 327 struct hermes_multicast {
... ... @@ -446,7 +446,7 @@
446 446  
447 447 static inline int hermes_read_wordrec(hermes_t *hw, int bap, u16 rid, u16 *word)
448 448 {
449   - u16 rec;
  449 + __le16 rec;
450 450 int err;
451 451  
452 452 err = HERMES_READ_RECORD(hw, bap, rid, &rec);
... ... @@ -456,7 +456,7 @@
456 456  
457 457 static inline int hermes_write_wordrec(hermes_t *hw, int bap, u16 rid, u16 word)
458 458 {
459   - u16 rec = cpu_to_le16(word);
  459 + __le16 rec = cpu_to_le16(word);
460 460 return HERMES_WRITE_RECORD(hw, bap, rid, &rec);
461 461 }
462 462  
drivers/net/wireless/orinoco.c
... ... @@ -202,31 +202,32 @@
202 202 /********************************************************************/
203 203  
204 204 /* Used in Event handling.
205   - * We avoid nested structres as they break on ARM -- Moustafa */
  205 + * We avoid nested structures as they break on ARM -- Moustafa */
206 206 struct hermes_tx_descriptor_802_11 {
207 207 /* hermes_tx_descriptor */
208   - u16 status;
209   - u16 reserved1;
210   - u16 reserved2;
211   - u32 sw_support;
  208 + __le16 status;
  209 + __le16 reserved1;
  210 + __le16 reserved2;
  211 + __le32 sw_support;
212 212 u8 retry_count;
213 213 u8 tx_rate;
214   - u16 tx_control;
  214 + __le16 tx_control;
215 215  
216   - /* ieee802_11_hdr */
217   - u16 frame_ctl;
218   - u16 duration_id;
  216 + /* ieee80211_hdr */
  217 + __le16 frame_ctl;
  218 + __le16 duration_id;
219 219 u8 addr1[ETH_ALEN];
220 220 u8 addr2[ETH_ALEN];
221 221 u8 addr3[ETH_ALEN];
222   - u16 seq_ctl;
  222 + __le16 seq_ctl;
223 223 u8 addr4[ETH_ALEN];
224   - u16 data_len;
225 224  
  225 + __le16 data_len;
  226 +
226 227 /* ethhdr */
227   - unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
228   - unsigned char h_source[ETH_ALEN]; /* source ether addr */
229   - unsigned short h_proto; /* packet type ID field */
  228 + u8 h_dest[ETH_ALEN]; /* destination eth addr */
  229 + u8 h_source[ETH_ALEN]; /* source ether addr */
  230 + __be16 h_proto; /* packet type ID field */
230 231  
231 232 /* p8022_hdr */
232 233 u8 dsap;
233 234  
234 235  
235 236  
236 237  
237 238  
... ... @@ -234,31 +235,31 @@
234 235 u8 ctrl;
235 236 u8 oui[3];
236 237  
237   - u16 ethertype;
  238 + __be16 ethertype;
238 239 } __attribute__ ((packed));
239 240  
240 241 /* Rx frame header except compatibility 802.3 header */
241 242 struct hermes_rx_descriptor {
242 243 /* Control */
243   - u16 status;
244   - u32 time;
  244 + __le16 status;
  245 + __le32 time;
245 246 u8 silence;
246 247 u8 signal;
247 248 u8 rate;
248 249 u8 rxflow;
249   - u32 reserved;
  250 + __le32 reserved;
250 251  
251 252 /* 802.11 header */
252   - u16 frame_ctl;
253   - u16 duration_id;
  253 + __le16 frame_ctl;
  254 + __le16 duration_id;
254 255 u8 addr1[ETH_ALEN];
255 256 u8 addr2[ETH_ALEN];
256 257 u8 addr3[ETH_ALEN];
257   - u16 seq_ctl;
  258 + __le16 seq_ctl;
258 259 u8 addr4[ETH_ALEN];
259 260  
260 261 /* Data length */
261   - u16 data_len;
  262 + __le16 data_len;
262 263 } __attribute__ ((packed));
263 264  
264 265 /********************************************************************/
... ... @@ -389,7 +390,7 @@
389 390 }
390 391 } else {
391 392 struct {
392   - u16 qual, signal, noise;
  393 + __le16 qual, signal, noise;
393 394 } __attribute__ ((packed)) cq;
394 395  
395 396 err = HERMES_READ_RECORD(hw, USER_BAP,
... ... @@ -615,6 +616,7 @@
615 616 struct orinoco_private *priv = netdev_priv(dev);
616 617 struct net_device_stats *stats = &priv->stats;
617 618 u16 fid = hermes_read_regn(hw, TXCOMPLFID);
  619 + u16 status;
618 620 struct hermes_tx_descriptor_802_11 hdr;
619 621 int err = 0;
620 622  
... ... @@ -644,8 +646,8 @@
644 646 * exceeded, because that's the only status that really mean
645 647 * that this particular node went away.
646 648 * Other errors means that *we* screwed up. - Jean II */
647   - hdr.status = le16_to_cpu(hdr.status);
648   - if (hdr.status & (HERMES_TXSTAT_RETRYERR | HERMES_TXSTAT_AGEDERR)) {
  649 + status = le16_to_cpu(hdr.status);
  650 + if (status & (HERMES_TXSTAT_RETRYERR | HERMES_TXSTAT_AGEDERR)) {
649 651 union iwreq_data wrqu;
650 652  
651 653 /* Copy 802.11 dest address.
... ... @@ -1031,7 +1033,7 @@
1031 1033 unsigned long flags;
1032 1034 struct join_req {
1033 1035 u8 bssid[ETH_ALEN];
1034   - u16 channel;
  1036 + __le16 channel;
1035 1037 } __attribute__ ((packed)) req;
1036 1038 const int atom_len = offsetof(struct prism2_scan_apinfo, atim);
1037 1039 struct prism2_scan_apinfo *atom = NULL;
... ... @@ -1128,8 +1130,8 @@
1128 1130 struct orinoco_private *priv = netdev_priv(dev);
1129 1131 u16 infofid;
1130 1132 struct {
1131   - u16 len;
1132   - u16 type;
  1133 + __le16 len;
  1134 + __le16 type;
1133 1135 } __attribute__ ((packed)) info;
1134 1136 int len, type;
1135 1137 int err;
... ... @@ -3905,7 +3907,7 @@
3905 3907 HERMES_HOSTSCAN_SYMBOL_BCAST);
3906 3908 break;
3907 3909 case FIRMWARE_TYPE_INTERSIL: {
3908   - u16 req[3];
  3910 + __le16 req[3];
3909 3911  
3910 3912 req[0] = cpu_to_le16(0x3fff); /* All channels */
3911 3913 req[1] = cpu_to_le16(0x0001); /* rate 1 Mbps */
... ... @@ -3979,7 +3981,7 @@
3979 3981 case FIRMWARE_TYPE_INTERSIL:
3980 3982 offset = 4;
3981 3983 if (priv->has_hostscan) {
3982   - atom_len = le16_to_cpup((u16 *)scan);
  3984 + atom_len = le16_to_cpup((__le16 *)scan);
3983 3985 /* Sanity check for atom_len */
3984 3986 if (atom_len < sizeof(struct prism2_scan_apinfo)) {
3985 3987 printk(KERN_ERR "%s: Invalid atom_len in scan data: %d\n",
drivers/net/wireless/orinoco.h
... ... @@ -27,7 +27,7 @@
27 27 #define ORINOCO_MAX_KEYS 4
28 28  
29 29 struct orinoco_key {
30   - u16 len; /* always stored as little-endian */
  30 + __le16 len; /* always stored as little-endian */
31 31 char data[ORINOCO_MAX_KEY_SIZE];
32 32 } __attribute__ ((packed));
33 33  
34 34  
... ... @@ -35,14 +35,14 @@
35 35 /* 802.3 */
36 36 u8 dest[ETH_ALEN];
37 37 u8 src[ETH_ALEN];
38   - u16 len;
  38 + __be16 len;
39 39 /* 802.2 */
40 40 u8 dsap;
41 41 u8 ssap;
42 42 u8 ctrl;
43 43 /* SNAP */
44 44 u8 oui[3];
45   - u16 ethertype;
  45 + unsigned short ethertype;
46 46 } __attribute__ ((packed));
47 47  
48 48 typedef enum {
drivers/net/wireless/spectrum_cs.c
... ... @@ -138,8 +138,8 @@
138 138 * Each block has the following structure.
139 139 */
140 140 struct dblock {
141   - u32 _addr; /* adapter address where to write the block */
142   - u16 _len; /* length of the data only, in bytes */
  141 + __le32 _addr; /* adapter address where to write the block */
  142 + __le16 _len; /* length of the data only, in bytes */
143 143 char data[0]; /* data to be written */
144 144 } __attribute__ ((packed));
145 145  
... ... @@ -149,9 +149,9 @@
149 149 * items with matching ID should be written.
150 150 */
151 151 struct pdr {
152   - u32 _id; /* record ID */
153   - u32 _addr; /* adapter address where to write the data */
154   - u32 _len; /* expected length of the data, in bytes */
  152 + __le32 _id; /* record ID */
  153 + __le32 _addr; /* adapter address where to write the data */
  154 + __le32 _len; /* expected length of the data, in bytes */
155 155 char next[0]; /* next PDR starts here */
156 156 } __attribute__ ((packed));
157 157  
... ... @@ -162,8 +162,8 @@
162 162 * be plugged into the secondary firmware.
163 163 */
164 164 struct pdi {
165   - u16 _len; /* length of ID and data, in words */
166   - u16 _id; /* record ID */
  165 + __le16 _len; /* length of ID and data, in words */
  166 + __le16 _id; /* record ID */
167 167 char data[0]; /* plug data */
168 168 } __attribute__ ((packed));;
169 169  
... ... @@ -370,7 +370,7 @@
370 370  
371 371 /* Read PDA from the adapter */
372 372 static int
373   -spectrum_read_pda(hermes_t *hw, u16 *pda, int pda_len)
  373 +spectrum_read_pda(hermes_t *hw, __le16 *pda, int pda_len)
374 374 {
375 375 int ret;
376 376 int pda_size;
... ... @@ -401,7 +401,7 @@
401 401 /* Parse PDA and write the records into the adapter */
402 402 static int
403 403 spectrum_apply_pda(hermes_t *hw, const struct dblock *first_block,
404   - u16 *pda)
  404 + __le16 *pda)
405 405 {
406 406 int ret;
407 407 struct pdi *pdi;
... ... @@ -467,7 +467,7 @@
467 467 const struct dblock *first_block;
468 468  
469 469 /* Plug Data Area (PDA) */
470   - u16 pda[PDA_WORDS];
  470 + __le16 pda[PDA_WORDS];
471 471  
472 472 /* Binary block begins after the 0x1A marker */
473 473 ptr = image;