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

Unverified Commit 794b511a authored by Peter Cai's avatar Peter Cai
Browse files

drivers: qcacld: reverse fw-provided mac addr

* When wlan_mac.bin is missing for whatever reason, qcacld will fall
  back to loading mac address from firmware. The OnePlus firmware can
  provide a correct mac address, but it is in reverse, breaking the
  qcacld logic.
* Just reverse it back in qcacld. Although wlan_mac.bin should not be
  missing at all, we have seen some rare cases where it could not be
  generated properly for some reason, and the qcacld fallback is broken
  because of byte-ordering. Let's at least make the fallback path work.

Change-Id: Iccdc4657debec1375939dca7a4ce4df5e76f255f
parent ca530582
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -10541,6 +10541,14 @@ static int hdd_update_mac_addr_to_fw(struct hdd_context *hdd_ctx)
	return 0;
}

static void reverse_byte_array(uint8_t *arr, int len) {
	for (int i = 0; i < len / 2; i++) {
		char temp = arr[i];
		arr[i] = arr[len - i - 1];
		arr[len - i - 1] = temp;
	}
}

/**
 * hdd_initialize_mac_address() - API to get wlan mac addresses
 * @hdd_ctx: HDD Context
@@ -10573,6 +10581,7 @@ static int hdd_initialize_mac_address(struct hdd_context *hdd_ctx)

	/* Use fw provided MAC */
	if (!qdf_is_macaddr_zero(&hdd_ctx->hw_macaddr)) {
		reverse_byte_array(&hdd_ctx->hw_macaddr.bytes[0], 6);
		hdd_update_macaddr(hdd_ctx, hdd_ctx->hw_macaddr, false);
		update_mac_addr_to_fw = false;
		return 0;