Skip to content

Commit 43e6465

Browse files
Phil Elwellpopcornmix
Phil Elwell
authored andcommitted
brcmfmac: Use original country code as a fallback
Commit 73345fd: brcmfmac: Configure country code using device specific settings prevents region codes from working on devices that lack a region code translation table. In the event of an absent table, preserve the old behaviour of using the provided code as-is. Signed-off-by: Phil Elwell <[email protected]>
1 parent 5c054a9 commit 43e6465

File tree

1 file changed

+15
-5
lines changed
  • drivers/net/wireless/broadcom/brcm80211/brcmfmac

1 file changed

+15
-5
lines changed

drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6516,12 +6516,18 @@ static s32 brcmf_translate_country_code(struct brcmf_pub *drvr, char alpha2[2],
65166516
struct brcmfmac_pd_cc *country_codes;
65176517
struct brcmfmac_pd_cc_entry *cc;
65186518
s32 found_index;
6519+
char ccode[BRCMF_COUNTRY_BUF_SZ];
6520+
int rev;
65196521
int i;
65206522

6523+
memcpy(ccode, alpha2, sizeof(ccode));
6524+
rev = -1;
6525+
65216526
country_codes = drvr->settings->country_codes;
65226527
if (!country_codes) {
6523-
brcmf_dbg(TRACE, "No country codes configured for device\n");
6524-
return -EINVAL;
6528+
brcmf_dbg(TRACE, "No country codes configured for device"
6529+
" - use requested value\n");
6530+
goto use_input_value;
65256531
}
65266532

65276533
if ((alpha2[0] == ccreq->country_abbrev[0]) &&
@@ -6545,10 +6551,14 @@ static s32 brcmf_translate_country_code(struct brcmf_pub *drvr, char alpha2[2],
65456551
brcmf_dbg(TRACE, "No country code match found\n");
65466552
return -EINVAL;
65476553
}
6548-
memset(ccreq, 0, sizeof(*ccreq));
6549-
ccreq->rev = cpu_to_le32(country_codes->table[found_index].rev);
6550-
memcpy(ccreq->ccode, country_codes->table[found_index].cc,
6554+
rev = country_codes->table[found_index].rev;
6555+
memcpy(ccode, country_codes->table[found_index].cc,
65516556
BRCMF_COUNTRY_BUF_SZ);
6557+
6558+
use_input_value:
6559+
memset(ccreq, 0, sizeof(*ccreq));
6560+
ccreq->rev = cpu_to_le32(rev);
6561+
memcpy(ccreq->ccode, ccode, sizeof(ccode));
65526562
ccreq->country_abbrev[0] = alpha2[0];
65536563
ccreq->country_abbrev[1] = alpha2[1];
65546564
ccreq->country_abbrev[2] = 0;

0 commit comments

Comments
 (0)