wlcore: change way of checking the firmware version
The firmwares version string contain 5 integers. We used to consider all the digits (except for the first one, which indicates the chip) as linearly increasing version numbers. This is not correct, because some of the integers indicate type of firmware (eg. single-role vs. multi-role) or the internal project it was created for. Besides, this varies a bit from chip to chip, so we need to make the firmware version checks more flexible (eg. allow the lower driver to ignore some of the integers). Additionally, we need to change the code so that we only check for a linearly increasing number on the fields where this actually makes sense. Signed-off-by: Luciano Coelho <coelho@ti.com>
This commit is contained in:
parent
c3552c0625
commit
af4e94c565
2 changed files with 35 additions and 23 deletions
|
@ -85,46 +85,55 @@ static int wlcore_validate_fw_ver(struct wl1271 *wl)
|
||||||
{
|
{
|
||||||
unsigned int *fw_ver = wl->chip.fw_ver;
|
unsigned int *fw_ver = wl->chip.fw_ver;
|
||||||
unsigned int *min_ver = wl->min_fw_ver;
|
unsigned int *min_ver = wl->min_fw_ver;
|
||||||
|
char min_fw_str[32] = "";
|
||||||
|
int i;
|
||||||
|
|
||||||
/* the chip must be exactly equal */
|
/* the chip must be exactly equal */
|
||||||
if (min_ver[FW_VER_CHIP] != fw_ver[FW_VER_CHIP])
|
if ((min_ver[FW_VER_CHIP] != WLCORE_FW_VER_IGNORE) &&
|
||||||
|
(min_ver[FW_VER_CHIP] != fw_ver[FW_VER_CHIP]))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* always check the next digit if all previous ones are equal */
|
/* the firmware type must be equal */
|
||||||
|
if ((min_ver[FW_VER_IF_TYPE] != WLCORE_FW_VER_IGNORE) &&
|
||||||
if (min_ver[FW_VER_IF_TYPE] < fw_ver[FW_VER_IF_TYPE])
|
(min_ver[FW_VER_IF_TYPE] != fw_ver[FW_VER_IF_TYPE]))
|
||||||
goto out;
|
|
||||||
else if (min_ver[FW_VER_IF_TYPE] > fw_ver[FW_VER_IF_TYPE])
|
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (min_ver[FW_VER_MAJOR] < fw_ver[FW_VER_MAJOR])
|
/* the project number must be equal */
|
||||||
goto out;
|
if ((min_ver[FW_VER_SUBTYPE] != WLCORE_FW_VER_IGNORE) &&
|
||||||
else if (min_ver[FW_VER_MAJOR] > fw_ver[FW_VER_MAJOR])
|
(min_ver[FW_VER_SUBTYPE] != fw_ver[FW_VER_SUBTYPE]))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (min_ver[FW_VER_SUBTYPE] < fw_ver[FW_VER_SUBTYPE])
|
/* the API version must be greater or equal */
|
||||||
goto out;
|
if ((min_ver[FW_VER_MAJOR] != WLCORE_FW_VER_IGNORE) &&
|
||||||
else if (min_ver[FW_VER_SUBTYPE] > fw_ver[FW_VER_SUBTYPE])
|
(min_ver[FW_VER_MAJOR] > fw_ver[FW_VER_MAJOR]))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (min_ver[FW_VER_MINOR] < fw_ver[FW_VER_MINOR])
|
/* if the API version is equal... */
|
||||||
goto out;
|
if (((min_ver[FW_VER_MAJOR] == WLCORE_FW_VER_IGNORE) ||
|
||||||
else if (min_ver[FW_VER_MINOR] > fw_ver[FW_VER_MINOR])
|
(min_ver[FW_VER_MAJOR] == fw_ver[FW_VER_MAJOR])) &&
|
||||||
|
/* ...the minor must be greater or equal */
|
||||||
|
((min_ver[FW_VER_MINOR] != WLCORE_FW_VER_IGNORE) &&
|
||||||
|
(min_ver[FW_VER_MINOR] > fw_ver[FW_VER_MINOR])))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
out:
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
wl1271_error("Your WiFi FW version (%u.%u.%u.%u.%u) is outdated.\n"
|
for (i = 0; i < NUM_FW_VER; i++)
|
||||||
"Please use at least FW %u.%u.%u.%u.%u.\n"
|
if (min_ver[i] == WLCORE_FW_VER_IGNORE)
|
||||||
"You can get more information at:\n"
|
snprintf(min_fw_str, sizeof(min_fw_str),
|
||||||
"http://wireless.kernel.org/en/users/Drivers/wl12xx",
|
"%s*.", min_fw_str);
|
||||||
|
else
|
||||||
|
snprintf(min_fw_str, sizeof(min_fw_str),
|
||||||
|
"%s%u.", min_fw_str, min_ver[i]);
|
||||||
|
|
||||||
|
wl1271_error("Your WiFi FW version (%u.%u.%u.%u.%u) is invalid.\n"
|
||||||
|
"Please use at least FW %s\n"
|
||||||
|
"You can get the latest firmwares at:\n"
|
||||||
|
"git://github.com/TI-OpenLink/firmwares.git",
|
||||||
fw_ver[FW_VER_CHIP], fw_ver[FW_VER_IF_TYPE],
|
fw_ver[FW_VER_CHIP], fw_ver[FW_VER_IF_TYPE],
|
||||||
fw_ver[FW_VER_MAJOR], fw_ver[FW_VER_SUBTYPE],
|
fw_ver[FW_VER_MAJOR], fw_ver[FW_VER_SUBTYPE],
|
||||||
fw_ver[FW_VER_MINOR], min_ver[FW_VER_CHIP],
|
fw_ver[FW_VER_MINOR], min_fw_str);
|
||||||
min_ver[FW_VER_IF_TYPE], min_ver[FW_VER_MAJOR],
|
|
||||||
min_ver[FW_VER_SUBTYPE], min_ver[FW_VER_MINOR]);
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -466,6 +466,9 @@ wlcore_set_ht_cap(struct wl1271 *wl, enum ieee80211_band band,
|
||||||
memcpy(&wl->ht_cap[band], ht_cap, sizeof(*ht_cap));
|
memcpy(&wl->ht_cap[band], ht_cap, sizeof(*ht_cap));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Tell wlcore not to care about this element when checking the version */
|
||||||
|
#define WLCORE_FW_VER_IGNORE -1
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
wlcore_set_min_fw_ver(struct wl1271 *wl, unsigned int chip,
|
wlcore_set_min_fw_ver(struct wl1271 *wl, unsigned int chip,
|
||||||
unsigned int iftype, unsigned int major,
|
unsigned int iftype, unsigned int major,
|
||||||
|
|
Loading…
Add table
Reference in a new issue