forked from Minki/linux
brcmfmac: simplify check finding NVRAM v1 device path
With a simple use of snprintf and small buffer we can compare NVRAM entry value with a full string. This way we avoid checking random chars at magic offsets. Tested on BCM43602 with NVRAM hacked to use v1 format. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
parent
ae8c2366d7
commit
5d08408b6f
@ -222,6 +222,10 @@ static int brcmf_init_nvram_parser(struct nvram_parser *nvp,
|
|||||||
static void brcmf_fw_strip_multi_v1(struct nvram_parser *nvp, u16 domain_nr,
|
static void brcmf_fw_strip_multi_v1(struct nvram_parser *nvp, u16 domain_nr,
|
||||||
u16 bus_nr)
|
u16 bus_nr)
|
||||||
{
|
{
|
||||||
|
/* Device path with a leading '=' key-value separator */
|
||||||
|
char pcie_path[] = "=pcie/?/?";
|
||||||
|
size_t pcie_len;
|
||||||
|
|
||||||
u32 i, j;
|
u32 i, j;
|
||||||
bool found;
|
bool found;
|
||||||
u8 *nvram;
|
u8 *nvram;
|
||||||
@ -238,6 +242,9 @@ static void brcmf_fw_strip_multi_v1(struct nvram_parser *nvp, u16 domain_nr,
|
|||||||
/* First search for the devpathX and see if it is the configuration
|
/* First search for the devpathX and see if it is the configuration
|
||||||
* for domain_nr/bus_nr. Search complete nvp
|
* for domain_nr/bus_nr. Search complete nvp
|
||||||
*/
|
*/
|
||||||
|
snprintf(pcie_path, sizeof(pcie_path), "=pcie/%d/%d", domain_nr,
|
||||||
|
bus_nr);
|
||||||
|
pcie_len = strlen(pcie_path);
|
||||||
found = false;
|
found = false;
|
||||||
i = 0;
|
i = 0;
|
||||||
while (i < nvp->nvram_len - BRCMF_FW_NVRAM_DEVPATH_LEN) {
|
while (i < nvp->nvram_len - BRCMF_FW_NVRAM_DEVPATH_LEN) {
|
||||||
@ -245,13 +252,10 @@ static void brcmf_fw_strip_multi_v1(struct nvram_parser *nvp, u16 domain_nr,
|
|||||||
* Y = domain_nr, Z = bus_nr, X = virtual ID
|
* Y = domain_nr, Z = bus_nr, X = virtual ID
|
||||||
*/
|
*/
|
||||||
if ((strncmp(&nvp->nvram[i], "devpath", 7) == 0) &&
|
if ((strncmp(&nvp->nvram[i], "devpath", 7) == 0) &&
|
||||||
(strncmp(&nvp->nvram[i + 8], "=pcie/", 6) == 0)) {
|
(strncmp(&nvp->nvram[i + 8], pcie_path, pcie_len) == 0)) {
|
||||||
if (((nvp->nvram[i + 14] - '0') == domain_nr) &&
|
id = nvp->nvram[i + 7] - '0';
|
||||||
((nvp->nvram[i + 16] - '0') == bus_nr)) {
|
found = true;
|
||||||
id = nvp->nvram[i + 7] - '0';
|
break;
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
while (nvp->nvram[i] != 0)
|
while (nvp->nvram[i] != 0)
|
||||||
i++;
|
i++;
|
||||||
|
Loading…
Reference in New Issue
Block a user