Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit af4e94c5 authored by Luciano Coelho's avatar Luciano Coelho
Browse files

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: default avatarLuciano Coelho <coelho@ti.com>
parent c3552c06
Loading
Loading
Loading
Loading
+32 −23
Original line number Diff line number Diff line
@@ -85,46 +85,55 @@ static int wlcore_validate_fw_ver(struct wl1271 *wl)
{
	unsigned int *fw_ver = wl->chip.fw_ver;
	unsigned int *min_ver = wl->min_fw_ver;
	char min_fw_str[32] = "";
	int i;

	/* 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;

	/* always check the next digit if all previous ones are equal */

	if (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])
	/* the firmware type must be equal */
	if ((min_ver[FW_VER_IF_TYPE] != WLCORE_FW_VER_IGNORE) &&
	    (min_ver[FW_VER_IF_TYPE] != fw_ver[FW_VER_IF_TYPE]))
		goto fail;

	if (min_ver[FW_VER_MAJOR] < fw_ver[FW_VER_MAJOR])
		goto out;
	else if (min_ver[FW_VER_MAJOR] > fw_ver[FW_VER_MAJOR])
	/* the project number must be equal */
	if ((min_ver[FW_VER_SUBTYPE] != WLCORE_FW_VER_IGNORE) &&
	    (min_ver[FW_VER_SUBTYPE] != fw_ver[FW_VER_SUBTYPE]))
		goto fail;

	if (min_ver[FW_VER_SUBTYPE] < fw_ver[FW_VER_SUBTYPE])
		goto out;
	else if (min_ver[FW_VER_SUBTYPE] > fw_ver[FW_VER_SUBTYPE])
	/* the API version must be greater or equal */
	if ((min_ver[FW_VER_MAJOR] != WLCORE_FW_VER_IGNORE) &&
		 (min_ver[FW_VER_MAJOR] > fw_ver[FW_VER_MAJOR]))
		goto fail;

	if (min_ver[FW_VER_MINOR] < fw_ver[FW_VER_MINOR])
		goto out;
	else if (min_ver[FW_VER_MINOR] > fw_ver[FW_VER_MINOR])
	/* if the API version is equal... */
	if (((min_ver[FW_VER_MAJOR] == WLCORE_FW_VER_IGNORE) ||
	     (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;

out:
	return 0;

fail:
	wl1271_error("Your WiFi FW version (%u.%u.%u.%u.%u) is outdated.\n"
		     "Please use at least FW %u.%u.%u.%u.%u.\n"
		     "You can get more information at:\n"
		     "http://wireless.kernel.org/en/users/Drivers/wl12xx",
	for (i = 0; i < NUM_FW_VER; i++)
		if (min_ver[i] == WLCORE_FW_VER_IGNORE)
			snprintf(min_fw_str, sizeof(min_fw_str),
				  "%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_MAJOR], fw_ver[FW_VER_SUBTYPE],
		     fw_ver[FW_VER_MINOR], min_ver[FW_VER_CHIP],
		     min_ver[FW_VER_IF_TYPE], min_ver[FW_VER_MAJOR],
		     min_ver[FW_VER_SUBTYPE], min_ver[FW_VER_MINOR]);
		     fw_ver[FW_VER_MINOR], min_fw_str);
	return -EINVAL;
}

+3 −0
Original line number Diff line number Diff line
@@ -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));
}

/* Tell wlcore not to care about this element when checking the version */
#define WLCORE_FW_VER_IGNORE	-1

static inline void
wlcore_set_min_fw_ver(struct wl1271 *wl, unsigned int chip,
		      unsigned int iftype, unsigned int major,