Skip to content
This repository has been archived by the owner on Jul 7, 2021. It is now read-only.

Commit

Permalink
qcacld-3.0: Fix mac address fallback when generation fails
Browse files Browse the repository at this point in the history
Adapted from LineageOS/android_kernel_oneplus_sm8150@794b511

Recently, Chinese users have reported inline qcacld-3.0 failures
(although it's possible that this may pertain to a minority
of other users as well). This occurs as a result of wlan_mac.bin
failing to generate. Under normal circumstances, qcacld-3.0 would
fallback to a firmware provided mac address. However, OnePlus'
firmware byte-ordering results in a reversed address being fed to
the driver, breaking fallback logic and preventing WLAN from
getting off the ground entirely.

This reworks the original LineageOS patch to correct improper
in-loop variable declaration which triggers the following
compilation error not only on GCC, but current LLVM toolchains as
well:

../drivers/staging/qcacld-3.0/core/hdd/src/wlan_hdd_main.c:11006:7: error: GCC does not allow variable declarations in for loop initializers before C99 [-Werror,-Wgcc-compat]
        for (int i = 0; i < len / 2; i++) {
             ^

Co-authored-by: Peter Cai <peter@typeblog.net>
Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
  • Loading branch information
0ctobot and PeterCxy committed Feb 5, 2020
1 parent 6db11b1 commit 7f35ad4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions drivers/staging/qcacld-3.0/core/hdd/src/wlan_hdd_main.c
Expand Up @@ -11002,6 +11002,17 @@ 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)
{
int i;

for (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
Expand Down Expand Up @@ -11034,6 +11045,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;
Expand Down

0 comments on commit 7f35ad4

Please sign in to comment.