浏览代码

p54: fix EEPROM structure endianness

Since the EEPROM structure is read from hardware, it is
always little endian, annotate that in the struct and
make sure to convert where applicable.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Michael Wu <flamingice@sourmilk.net>
Tested-by: Florian Fainelli <florian.fainelli@telecomint.eu>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Johannes Berg 17 年之前
父节点
当前提交
8c28293f55
共有 2 个文件被更改,包括 5 次插入5 次删除
  1. 1 1
      drivers/net/wireless/p54common.c
  2. 4 4
      drivers/net/wireless/p54common.h

+ 1 - 1
drivers/net/wireless/p54common.c

@@ -172,7 +172,7 @@ int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
 	int err;
 	int err;
 
 
 	wrap = (struct eeprom_pda_wrap *) eeprom;
 	wrap = (struct eeprom_pda_wrap *) eeprom;
-	entry = (void *)wrap->data + wrap->len;
+	entry = (void *)wrap->data + le16_to_cpu(wrap->len);
 	i += 2;
 	i += 2;
 	i += le16_to_cpu(entry->len)*2;
 	i += le16_to_cpu(entry->len)*2;
 	while (i < len) {
 	while (i < len) {

+ 4 - 4
drivers/net/wireless/p54common.h

@@ -53,10 +53,10 @@ struct pda_entry {
 } __attribute__ ((packed));
 } __attribute__ ((packed));
 
 
 struct eeprom_pda_wrap {
 struct eeprom_pda_wrap {
-	u32 magic;
-	u16 pad;
-	u16 len;
-	u32 arm_opcode;
+	__le32 magic;
+	__le16 pad;
+	__le16 len;
+	__le32 arm_opcode;
 	u8 data[0];
 	u8 data[0];
 } __attribute__ ((packed));
 } __attribute__ ((packed));