Skip to content

Commit f841504

Browse files
committed
eep6174/9888: fix multibyte fields endians handling
Endians are not accounted for QCA6174/QCA9888 data formats, so we got wrong length/checksum value on a BigEndian CPUs. Error also should manifest themself with BigEndian encoded data on LittleEndian CPUs, but I never saw BigEndian encoded data for these chips. In order to correctly output multibyte field values utilizes the same approach as was used for other EEPROM formats (e.g. AR5416, QCA9880, etc.). Turn field endians to a native CPU endian during data checking stage, before any prints. We still do not know location of the flag, that indicates BigEndian encoded data, so assume that data is always LittleEndian encoded. So we perform endian corrections only on BigEndian hosts. Fixes: d178e35 ("Add stub QCA6174 support") Fixes: 73ecd8c ("Add stub QCA9888 support")
1 parent 446c2bc commit f841504

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

eep_6174.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ static int eep_6174_check(struct atheepmgr *aem)
6161
}
6262

6363
/**
64+
* Data could come in a compressed form, so calc checksum on the private
65+
* copy of the decomressed calibration data *before* endians fix.
66+
*
6467
* NB: take pointer another one time from container to avoid warning
6568
* about a *possible* unaligned access
6669
*/
@@ -71,6 +74,17 @@ static int eep_6174_check(struct atheepmgr *aem)
7174
return false;
7275
}
7376

77+
/**
78+
* NB: we still do not know location of the BigEndian format flag, so
79+
* assume that data is always Little Endian.
80+
*/
81+
if (aem->host_is_be) {
82+
printf("EEPROM Endianness is not native.. Changing.\n");
83+
84+
bswap_16_inplace(pBase->length);
85+
bswap_16_inplace(pBase->checksum);
86+
}
87+
7488
return true;
7589
}
7690

eep_9888.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ static int eep_9888_check(struct atheepmgr *aem)
6161
}
6262

6363
/**
64+
* Data could come in a compressed form, so calc checksum on the private
65+
* copy of the decomressed calibration data *before* endians fix.
66+
*
6467
* NB: take pointer another one time from container to avoid warning
6568
* about a *possible* unaligned access
6669
*/
@@ -71,6 +74,17 @@ static int eep_9888_check(struct atheepmgr *aem)
7174
return false;
7275
}
7376

77+
/**
78+
* NB: we still do not know location of the BigEndian format flag, so
79+
* assume that data is always Little Endian.
80+
*/
81+
if (aem->host_is_be) {
82+
printf("EEPROM Endianness is not native.. Changing.\n");
83+
84+
bswap_16_inplace(pBase->length);
85+
bswap_16_inplace(pBase->checksum);
86+
}
87+
7488
return true;
7589
}
7690

0 commit comments

Comments
 (0)