Skip to content

Commit b46f534

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 e1853c8 commit b46f534

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
@@ -6597,12 +6597,18 @@ static s32 brcmf_translate_country_code(struct brcmf_pub *drvr, char alpha2[2],
65976597
struct brcmfmac_pd_cc *country_codes;
65986598
struct brcmfmac_pd_cc_entry *cc;
65996599
s32 found_index;
6600+
char ccode[BRCMF_COUNTRY_BUF_SZ];
6601+
int rev;
66006602
int i;
66016603

6604+
memcpy(ccode, alpha2, sizeof(ccode));
6605+
rev = -1;
6606+
66026607
country_codes = drvr->settings->country_codes;
66036608
if (!country_codes) {
6604-
brcmf_dbg(TRACE, "No country codes configured for device\n");
6605-
return -EINVAL;
6609+
brcmf_dbg(TRACE, "No country codes configured for device"
6610+
" - use requested value\n");
6611+
goto use_input_value;
66066612
}
66076613

66086614
if ((alpha2[0] == ccreq->country_abbrev[0]) &&
@@ -6626,10 +6632,14 @@ static s32 brcmf_translate_country_code(struct brcmf_pub *drvr, char alpha2[2],
66266632
brcmf_dbg(TRACE, "No country code match found\n");
66276633
return -EINVAL;
66286634
}
6629-
memset(ccreq, 0, sizeof(*ccreq));
6630-
ccreq->rev = cpu_to_le32(country_codes->table[found_index].rev);
6631-
memcpy(ccreq->ccode, country_codes->table[found_index].cc,
6635+
rev = country_codes->table[found_index].rev;
6636+
memcpy(ccode, country_codes->table[found_index].cc,
66326637
BRCMF_COUNTRY_BUF_SZ);
6638+
6639+
use_input_value:
6640+
memset(ccreq, 0, sizeof(*ccreq));
6641+
ccreq->rev = cpu_to_le32(rev);
6642+
memcpy(ccreq->ccode, ccode, sizeof(ccode));
66336643
ccreq->country_abbrev[0] = alpha2[0];
66346644
ccreq->country_abbrev[1] = alpha2[1];
66356645
ccreq->country_abbrev[2] = 0;

0 commit comments

Comments
 (0)