Skip to content

Commit ce7ace9

Browse files
pershootKali-
authored andcommitted
Revert (Partial): net: wireless: newer country_code/custom country_code logic
1 parent 38fe0fa commit ce7ace9

File tree

7 files changed

+49
-109
lines changed

7 files changed

+49
-109
lines changed

drivers/net/wireless/bcm4329/dhd.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ typedef struct dhd_pub {
164164
char * pktfilter[100];
165165
int pktfilter_count;
166166

167-
wl_country_t dhd_cspec; /* Current Locale info */
167+
uint8 country_code[WLC_CNTRY_BUF_SZ];
168168
char eventmask[WL_EVENTING_MASK_LEN];
169169

170170
} dhd_pub_t;

drivers/net/wireless/bcm4329/dhd_common.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -1363,10 +1363,9 @@ dhd_preinit_ioctls(dhd_pub_t *dhd)
13631363
#endif /* SET_RANDOM_MAC_SOFTAP */
13641364

13651365
/* Set Country code */
1366-
if (dhd->dhd_cspec.ccode[0] != 0) {
1367-
bcm_mkiovar("country", (char *)&dhd->dhd_cspec, \
1368-
sizeof(wl_country_t), iovbuf, sizeof(iovbuf));
1369-
if ((ret = dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf, sizeof(iovbuf))) < 0) {
1366+
if (dhd->country_code[0] != 0) {
1367+
if (dhdcdc_set_ioctl(dhd, 0, WLC_SET_COUNTRY,
1368+
dhd->country_code, sizeof(dhd->country_code)) < 0) {
13701369
DHD_ERROR(("%s: country code setting failed\n", __FUNCTION__));
13711370
}
13721371
}

drivers/net/wireless/bcm4329/dhd_custom_gpio.c

-66
Original file line numberDiff line numberDiff line change
@@ -178,69 +178,3 @@ dhd_custom_get_mac_address(unsigned char *buf)
178178
return ret;
179179
}
180180
#endif /* GET_CUSTOM_MAC_ENABLE */
181-
182-
/* Customized Locale table : OPTIONAL feature */
183-
const struct cntry_locales_custom translate_custom_table[] = {
184-
/* Table should be filled out based on custom platform regulatory requirement */
185-
#ifdef EXAMPLE_TABLE
186-
{"", "XY", 4} /* universal */
187-
{"US", "US", 69}, /* input ISO "US" to : US regrev 69 */
188-
{"CA", "US", 69}, /* input ISO "CA" to : US regrev 69 */
189-
{"EU", "EU", 5}, /* input ISO "EU" to : EU regrev 05 */
190-
{"FR", "EU", 5},
191-
{"DE", "EU", 5},
192-
{"IR", "EU", 5},
193-
{"UK", "EU", 5}, /* input ISO "UK" to : EU regrev 05 */
194-
{"KR", "XY", 3},
195-
{"AU", "XY", 3},
196-
{"CN", "XY", 3}, /* input ISO "CN" to : XY regrev 03 */
197-
{"HK", "XY", 3},
198-
{"TW", "XY", 3},
199-
{"BR", "XY", 3},
200-
{"MX", "XY", 3},
201-
{"AR", "XY", 3}
202-
#endif /* EXAMPLE_TABLE */
203-
};
204-
205-
206-
/* Customized Locale convertor
207-
* input : ISO 3166-1 country abbreviation
208-
* output: customized cspec
209-
*/
210-
void get_customized_country_code(char *country_iso_code, wl_country_t *cspec)
211-
{
212-
#ifdef CUSTOMER_HW2
213-
struct cntry_locales_custom *cloc_ptr;
214-
215-
if (!cspec)
216-
return;
217-
218-
cloc_ptr = wifi_get_country_code(country_iso_code);
219-
if (cloc_ptr) {
220-
strlcpy(cspec->ccode, cloc_ptr->custom_locale, WLC_CNTRY_BUF_SZ);
221-
cspec->rev = cloc_ptr->custom_locale_rev;
222-
}
223-
return;
224-
#else
225-
int size, i;
226-
227-
size = ARRAYSIZE(translate_custom_table);
228-
229-
if (cspec == 0)
230-
return;
231-
232-
if (size == 0)
233-
return;
234-
235-
for (i = 0; i < size; i++) {
236-
if (strcmp(country_iso_code, translate_custom_table[i].iso_abbrev) == 0) {
237-
memcpy(cspec->ccode, translate_custom_table[i].custom_locale, WLC_CNTRY_BUF_SZ);
238-
cspec->rev = translate_custom_table[i].custom_locale_rev;
239-
return;
240-
}
241-
}
242-
memcpy(cspec->ccode, translate_custom_table[0].custom_locale, WLC_CNTRY_BUF_SZ);
243-
cspec->rev = translate_custom_table[0].custom_locale_rev;
244-
return;
245-
#endif
246-
}

drivers/net/wireless/bcm4329/dhd_linux.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -3255,20 +3255,20 @@ int net_os_send_hang_message(struct net_device *dev)
32553255
return ret;
32563256
}
32573257

3258-
void dhd_bus_country_set(struct net_device *dev, wl_country_t *cspec)
3258+
void dhd_bus_country_set(struct net_device *dev, char *country_code)
32593259
{
32603260
dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
32613261

32623262
if (dhd && dhd->pub.up)
3263-
memcpy(&dhd->pub.dhd_cspec, cspec, sizeof(wl_country_t));
3263+
strncpy(dhd->pub.country_code, country_code, WLC_CNTRY_BUF_SZ);
32643264
}
32653265

32663266
char *dhd_bus_country_get(struct net_device *dev)
32673267
{
32683268
dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(dev);
32693269

3270-
if (dhd && (dhd->pub.dhd_cspec.ccode[0] != 0))
3271-
return dhd->pub.dhd_cspec.ccode;
3270+
if (dhd && (dhd->pub.country_code[0] != 0))
3271+
return dhd->pub.country_code;
32723272
return NULL;
32733273
}
32743274

drivers/net/wireless/bcm4329/include/wlioctl.h

-6
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,6 @@ typedef struct wl_join_params {
254254

255255
#define WLC_CNTRY_BUF_SZ 4
256256

257-
typedef struct wl_country {
258-
char country_abbrev[WLC_CNTRY_BUF_SZ];
259-
int32 rev;
260-
char ccode[WLC_CNTRY_BUF_SZ];
261-
} wl_country_t;
262-
263257
typedef enum sup_auth_status {
264258

265259
WLC_SUP_DISCONNECTED = 0,

drivers/net/wireless/bcm4329/wl_iw.c

+40-20
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,31 @@ wl_iw_get_macaddr(
647647
return error;
648648
}
649649

650+
static int
651+
wl_iw_set_country_code(struct net_device *dev, char *ccode)
652+
{
653+
char country_code[WLC_CNTRY_BUF_SZ];
654+
int ret = -1;
655+
656+
WL_TRACE(("%s\n", __FUNCTION__));
657+
if (!ccode)
658+
ccode = dhd_bus_country_get(dev);
659+
strncpy(country_code, ccode, sizeof(country_code));
660+
if (ccode && (country_code[0] != 0)) {
661+
#ifdef CONFIG_US_NON_DFS_CHANNELS_ONLY
662+
if (use_non_dfs_channels && !strncmp(country_code, "US", 2))
663+
strncpy(country_code, "Q2", WLC_CNTRY_BUF_SZ);
664+
if (!use_non_dfs_channels && !strncmp(country_code, "Q2", 2))
665+
strncpy(country_code, "US", WLC_CNTRY_BUF_SZ);
666+
#endif
667+
ret = dev_wlc_ioctl(dev, WLC_SET_COUNTRY, &country_code, sizeof(country_code));
668+
if (ret >= 0) {
669+
WL_TRACE(("%s: set country %s OK\n", __FUNCTION__, country_code));
670+
dhd_bus_country_set(dev, &country_code[0]);
671+
}
672+
}
673+
return ret;
674+
}
650675

651676
static int
652677
wl_iw_set_country(
@@ -661,38 +686,25 @@ wl_iw_set_country(
661686
char *p = extra;
662687
int country_offset;
663688
int country_code_size;
664-
wl_country_t cspec = {{0}, 0, {0}};
665-
char smbuf[WLC_IOCTL_SMLEN];
666689

667-
cspec.rev = -1;
690+
WL_TRACE(("%s\n", __FUNCTION__));
668691
memset(country_code, 0, sizeof(country_code));
669-
memset(smbuf, 0, sizeof(smbuf));
670692

671693
country_offset = strcspn(extra, " ");
672694
country_code_size = strlen(extra) - country_offset;
673695

674696
if (country_offset != 0) {
675697
strncpy(country_code, extra + country_offset +1,
676698
MIN(country_code_size, sizeof(country_code)));
677-
678-
679-
memcpy(cspec.country_abbrev, country_code, WLC_CNTRY_BUF_SZ);
680-
memcpy(cspec.ccode, country_code, WLC_CNTRY_BUF_SZ);
681-
682-
get_customized_country_code((char *)&cspec.country_abbrev, &cspec);
683-
684-
if ((error = dev_iw_iovar_setbuf(dev, "country", &cspec, \
685-
sizeof(cspec), smbuf, sizeof(smbuf))) >= 0) {
699+
error = wl_iw_set_country_code(dev, country_code);
700+
if (error >= 0) {
686701
p += snprintf(p, MAX_WX_STRING, "OK");
687-
WL_ERROR(("%s: set country for %s as %s rev %d is OK\n", \
688-
__FUNCTION__, country_code, cspec.ccode, cspec.rev));
689-
dhd_bus_country_set(dev, &cspec);
702+
WL_TRACE(("%s: set country %s OK\n", __FUNCTION__, country_code));
690703
goto exit;
691704
}
692705
}
693706

694-
WL_ERROR(("%s: set country for %s as %s rev %d failed\n", \
695-
__FUNCTION__, country_code, cspec.ccode, cspec.rev));
707+
WL_ERROR(("%s: set country %s failed code %d\n", __FUNCTION__, country_code, error));
696708

697709
p += snprintf(p, MAX_WX_STRING, "FAIL");
698710

@@ -6413,8 +6425,16 @@ static int set_ap_cfg(struct net_device *dev, struct ap_profile *ap)
64136425
}
64146426

64156427
if (strlen(ap->country_code)) {
6416-
WL_ERROR(("%s: Igonored: Country MUST be specified \
6417-
COUNTRY command with \n", __FUNCTION__));
6428+
int error = 0;
6429+
if ((error = dev_wlc_ioctl(dev, WLC_SET_COUNTRY,
6430+
ap->country_code, sizeof(ap->country_code))) >= 0) {
6431+
WL_SOFTAP(("%s: set country %s OK\n",
6432+
__FUNCTION__, ap->country_code));
6433+
dhd_bus_country_set(dev, &ap->country_code[0]);
6434+
} else {
6435+
WL_ERROR(("%s: ERROR:%d setting country %s\n",
6436+
__FUNCTION__, error, ap->country_code));
6437+
}
64186438
} else {
64196439
WL_SOFTAP(("%s: Country code is not specified,"
64206440
" will use Radio's default\n",

drivers/net/wireless/bcm4329/wl_iw.h

+1-8
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ typedef struct wl_iw_extra_params {
6565
int target_channel;
6666
} wl_iw_extra_params_t;
6767

68-
struct cntry_locales_custom {
69-
char iso_abbrev[WLC_CNTRY_BUF_SZ];
70-
char custom_locale[WLC_CNTRY_BUF_SZ];
71-
int32 custom_locale_rev;
72-
};
73-
7468
#define WL_IW_RSSI_MINVAL -200
7569
#define WL_IW_RSSI_NO_SIGNAL -91
7670
#define WL_IW_RSSI_VERY_LOW -80
@@ -208,7 +202,7 @@ extern int net_os_set_suspend_disable(struct net_device *dev, int val);
208202
extern int net_os_set_suspend(struct net_device *dev, int val);
209203
extern int net_os_set_dtim_skip(struct net_device *dev, int val);
210204
extern int net_os_set_packet_filter(struct net_device *dev, int val);
211-
extern void get_customized_country_code(char *country_iso_code, wl_country_t *cspec);
205+
extern void dhd_bus_country_set(struct net_device *dev, char *country_code);
212206
extern char *dhd_bus_country_get(struct net_device *dev);
213207
extern int dhd_get_dtim_skip(dhd_pub_t *dhd);
214208

@@ -238,7 +232,6 @@ extern int dhd_dev_pno_set(struct net_device *dev, wlc_ssid_t* ssids_local, \
238232
int nssid, ushort scan_fr, int pno_repeat, int pno_freq_expo_max);
239233
extern int dhd_dev_pno_enable(struct net_device *dev, int pfn_enabled);
240234
extern int dhd_dev_get_pno_status(struct net_device *dev);
241-
extern void dhd_bus_country_set(struct net_device *dev, wl_country_t *cspec);
242235

243236
#define PNO_TLV_PREFIX 'S'
244237
#define PNO_TLV_VERSION '1'

0 commit comments

Comments
 (0)