| .. | .. |
|---|
| 1 | | -/* SPDX-License-Identifier: GPL-2.0 */ |
|---|
| 2 | 1 | /* |
|---|
| 3 | 2 | * Common function shared by Linux WEXT, cfg80211 and p2p drivers |
|---|
| 4 | 3 | * |
|---|
| 5 | | - * Copyright (C) 1999-2019, Broadcom Corporation |
|---|
| 6 | | - * |
|---|
| 4 | + * Portions of this code are copyright (c) 2022 Cypress Semiconductor Corporation |
|---|
| 5 | + * |
|---|
| 6 | + * Copyright (C) 1999-2017, Broadcom Corporation |
|---|
| 7 | + * |
|---|
| 7 | 8 | * Unless you and Broadcom execute a separate written software license |
|---|
| 8 | 9 | * agreement governing use of this software, this software is licensed to you |
|---|
| 9 | 10 | * under the terms of the GNU General Public License version 2 (the "GPL"), |
|---|
| 10 | 11 | * available at http://www.broadcom.com/licenses/GPLv2.php, with the |
|---|
| 11 | 12 | * following added to such license: |
|---|
| 12 | | - * |
|---|
| 13 | + * |
|---|
| 13 | 14 | * As a special exception, the copyright holders of this software give you |
|---|
| 14 | 15 | * permission to link this software with independent modules, and to copy and |
|---|
| 15 | 16 | * distribute the resulting executable under terms of your choice, provided that |
|---|
| .. | .. |
|---|
| 17 | 18 | * the license of that module. An independent module is a module which is not |
|---|
| 18 | 19 | * derived from this software. The special exception does not apply to any |
|---|
| 19 | 20 | * modifications of the software. |
|---|
| 20 | | - * |
|---|
| 21 | + * |
|---|
| 21 | 22 | * Notwithstanding the above, under no circumstances may you combine this |
|---|
| 22 | 23 | * software in any way with any other Broadcom software provided under a license |
|---|
| 23 | 24 | * other than the GPL, without Broadcom's express prior written consent. |
|---|
| .. | .. |
|---|
| 25 | 26 | * |
|---|
| 26 | 27 | * <<Broadcom-WL-IPTag/Open:>> |
|---|
| 27 | 28 | * |
|---|
| 28 | | - * $Id: wldev_common.c 674374 2017-10-20 07:38:00Z $ |
|---|
| 29 | + * $Id: wldev_common.c 698236 2017-05-08 19:41:09Z $ |
|---|
| 29 | 30 | */ |
|---|
| 30 | 31 | |
|---|
| 31 | 32 | #include <osl.h> |
|---|
| .. | .. |
|---|
| 35 | 36 | |
|---|
| 36 | 37 | #include <wldev_common.h> |
|---|
| 37 | 38 | #include <bcmutils.h> |
|---|
| 39 | +#ifdef WL_CFG80211 |
|---|
| 40 | +#include <wl_cfg80211.h> |
|---|
| 41 | +#include <wl_cfgscan.h> |
|---|
| 42 | +#endif /* WL_CFG80211 */ |
|---|
| 38 | 43 | |
|---|
| 39 | 44 | #define htod32(i) (i) |
|---|
| 40 | 45 | #define htod16(i) (i) |
|---|
| .. | .. |
|---|
| 45 | 50 | |
|---|
| 46 | 51 | #define WLDEV_ERROR(args) \ |
|---|
| 47 | 52 | do { \ |
|---|
| 48 | | - printk(KERN_ERR "WLDEV-ERROR) %s : ", __func__); \ |
|---|
| 53 | + printk(KERN_ERR "WLDEV-ERROR) "); \ |
|---|
| 54 | + printk args; \ |
|---|
| 55 | + } while (0) |
|---|
| 56 | + |
|---|
| 57 | +#define WLDEV_INFO(args) \ |
|---|
| 58 | + do { \ |
|---|
| 59 | + printk(KERN_INFO "WLDEV-INFO) "); \ |
|---|
| 49 | 60 | printk args; \ |
|---|
| 50 | 61 | } while (0) |
|---|
| 51 | 62 | |
|---|
| 52 | 63 | extern int dhd_ioctl_entry_local(struct net_device *net, wl_ioctl_t *ioc, int cmd); |
|---|
| 53 | 64 | |
|---|
| 54 | | -s32 wldev_ioctl( |
|---|
| 65 | +static s32 wldev_ioctl( |
|---|
| 55 | 66 | struct net_device *dev, u32 cmd, void *arg, u32 len, u32 set) |
|---|
| 56 | 67 | { |
|---|
| 57 | 68 | s32 ret = 0; |
|---|
| 58 | | - struct wl_ioctl ioc; |
|---|
| 59 | | - |
|---|
| 69 | + struct wl_ioctl ioc; |
|---|
| 60 | 70 | |
|---|
| 61 | 71 | memset(&ioc, 0, sizeof(ioc)); |
|---|
| 62 | 72 | ioc.cmd = cmd; |
|---|
| 63 | 73 | ioc.buf = arg; |
|---|
| 64 | 74 | ioc.len = len; |
|---|
| 65 | 75 | ioc.set = set; |
|---|
| 66 | | - |
|---|
| 67 | | - ret = dhd_ioctl_entry_local(dev, &ioc, cmd); |
|---|
| 76 | + ret = dhd_ioctl_entry_local(dev, (wl_ioctl_t *)&ioc, cmd); |
|---|
| 68 | 77 | |
|---|
| 69 | 78 | return ret; |
|---|
| 79 | +} |
|---|
| 80 | + |
|---|
| 81 | +/* |
|---|
| 82 | +SET commands : |
|---|
| 83 | +cast buffer to non-const and call the GET function |
|---|
| 84 | +*/ |
|---|
| 85 | + |
|---|
| 86 | +s32 wldev_ioctl_set( |
|---|
| 87 | + struct net_device *dev, u32 cmd, const void *arg, u32 len) |
|---|
| 88 | +{ |
|---|
| 89 | + |
|---|
| 90 | +#if defined(STRICT_GCC_WARNINGS) && defined(__GNUC__) |
|---|
| 91 | +#pragma GCC diagnostic push |
|---|
| 92 | +#pragma GCC diagnostic ignored "-Wcast-qual" |
|---|
| 93 | +#endif // endif |
|---|
| 94 | + return wldev_ioctl(dev, cmd, (void *)arg, len, 1); |
|---|
| 95 | +#if defined(STRICT_GCC_WARNINGS) && defined(__GNUC__) |
|---|
| 96 | +#pragma GCC diagnostic pop |
|---|
| 97 | +#endif // endif |
|---|
| 98 | + |
|---|
| 99 | +} |
|---|
| 100 | + |
|---|
| 101 | +s32 wldev_ioctl_get( |
|---|
| 102 | + struct net_device *dev, u32 cmd, void *arg, u32 len) |
|---|
| 103 | +{ |
|---|
| 104 | + return wldev_ioctl(dev, cmd, (void *)arg, len, 0); |
|---|
| 70 | 105 | } |
|---|
| 71 | 106 | |
|---|
| 72 | 107 | /* Format a iovar buffer, not bsscfg indexed. The bsscfg index will be |
|---|
| .. | .. |
|---|
| 74 | 109 | * wl_iw, wl_cfg80211 and wl_cfgp2p |
|---|
| 75 | 110 | */ |
|---|
| 76 | 111 | static s32 wldev_mkiovar( |
|---|
| 77 | | - const s8 *iovar_name, s8 *param, s32 paramlen, |
|---|
| 112 | + const s8 *iovar_name, const s8 *param, s32 paramlen, |
|---|
| 78 | 113 | s8 *iovar_buf, u32 buflen) |
|---|
| 79 | 114 | { |
|---|
| 80 | 115 | s32 iolen = 0; |
|---|
| .. | .. |
|---|
| 85 | 120 | |
|---|
| 86 | 121 | s32 wldev_iovar_getbuf( |
|---|
| 87 | 122 | struct net_device *dev, s8 *iovar_name, |
|---|
| 88 | | - void *param, s32 paramlen, void *buf, s32 buflen, struct mutex* buf_sync) |
|---|
| 123 | + const void *param, s32 paramlen, void *buf, s32 buflen, struct mutex* buf_sync) |
|---|
| 89 | 124 | { |
|---|
| 90 | 125 | s32 ret = 0; |
|---|
| 91 | 126 | if (buf_sync) { |
|---|
| 92 | 127 | mutex_lock(buf_sync); |
|---|
| 93 | 128 | } |
|---|
| 94 | | - wldev_mkiovar(iovar_name, param, paramlen, buf, buflen); |
|---|
| 95 | | - ret = wldev_ioctl(dev, WLC_GET_VAR, buf, buflen, FALSE); |
|---|
| 129 | + |
|---|
| 130 | + if (buf && (buflen > 0)) { |
|---|
| 131 | + /* initialize the response buffer */ |
|---|
| 132 | + memset(buf, 0, buflen); |
|---|
| 133 | + } else { |
|---|
| 134 | + ret = BCME_BADARG; |
|---|
| 135 | + goto exit; |
|---|
| 136 | + } |
|---|
| 137 | + |
|---|
| 138 | + ret = wldev_mkiovar(iovar_name, param, paramlen, buf, buflen); |
|---|
| 139 | + |
|---|
| 140 | + if (!ret) { |
|---|
| 141 | + ret = BCME_BUFTOOSHORT; |
|---|
| 142 | + goto exit; |
|---|
| 143 | + } |
|---|
| 144 | + ret = wldev_ioctl_get(dev, WLC_GET_VAR, buf, buflen); |
|---|
| 145 | +exit: |
|---|
| 96 | 146 | if (buf_sync) |
|---|
| 97 | 147 | mutex_unlock(buf_sync); |
|---|
| 98 | 148 | return ret; |
|---|
| 99 | 149 | } |
|---|
| 100 | 150 | |
|---|
| 101 | | - |
|---|
| 102 | 151 | s32 wldev_iovar_setbuf( |
|---|
| 103 | 152 | struct net_device *dev, s8 *iovar_name, |
|---|
| 104 | | - void *param, s32 paramlen, void *buf, s32 buflen, struct mutex* buf_sync) |
|---|
| 153 | + const void *param, s32 paramlen, void *buf, s32 buflen, struct mutex* buf_sync) |
|---|
| 105 | 154 | { |
|---|
| 106 | 155 | s32 ret = 0; |
|---|
| 107 | 156 | s32 iovar_len; |
|---|
| .. | .. |
|---|
| 110 | 159 | } |
|---|
| 111 | 160 | iovar_len = wldev_mkiovar(iovar_name, param, paramlen, buf, buflen); |
|---|
| 112 | 161 | if (iovar_len > 0) |
|---|
| 113 | | - ret = wldev_ioctl(dev, WLC_SET_VAR, buf, iovar_len, TRUE); |
|---|
| 162 | + ret = wldev_ioctl_set(dev, WLC_SET_VAR, buf, iovar_len); |
|---|
| 114 | 163 | else |
|---|
| 115 | 164 | ret = BCME_BUFTOOSHORT; |
|---|
| 116 | 165 | |
|---|
| .. | .. |
|---|
| 129 | 178 | return wldev_iovar_setbuf(dev, iovar, &val, sizeof(val), iovar_buf, |
|---|
| 130 | 179 | sizeof(iovar_buf), NULL); |
|---|
| 131 | 180 | } |
|---|
| 132 | | - |
|---|
| 133 | 181 | |
|---|
| 134 | 182 | s32 wldev_iovar_getint( |
|---|
| 135 | 183 | struct net_device *dev, s8 *iovar, s32 *pval) |
|---|
| .. | .. |
|---|
| 153 | 201 | * wl_iw, wl_cfg80211 and wl_cfgp2p |
|---|
| 154 | 202 | */ |
|---|
| 155 | 203 | s32 wldev_mkiovar_bsscfg( |
|---|
| 156 | | - const s8 *iovar_name, s8 *param, s32 paramlen, |
|---|
| 204 | + const s8 *iovar_name, const s8 *param, s32 paramlen, |
|---|
| 157 | 205 | s8 *iovar_buf, s32 buflen, s32 bssidx) |
|---|
| 158 | 206 | { |
|---|
| 159 | 207 | const s8 *prefix = "bsscfg:"; |
|---|
| .. | .. |
|---|
| 163 | 211 | u32 iolen; |
|---|
| 164 | 212 | |
|---|
| 165 | 213 | /* initialize buffer */ |
|---|
| 166 | | - if (!iovar_buf || buflen == 0) |
|---|
| 214 | + if (!iovar_buf || buflen <= 0) |
|---|
| 167 | 215 | return BCME_BADARG; |
|---|
| 168 | 216 | memset(iovar_buf, 0, buflen); |
|---|
| 169 | 217 | |
|---|
| .. | .. |
|---|
| 176 | 224 | namelen = (u32) strlen(iovar_name) + 1; /* lengh of iovar name + null */ |
|---|
| 177 | 225 | iolen = prefixlen + namelen + sizeof(u32) + paramlen; |
|---|
| 178 | 226 | |
|---|
| 179 | | - if (buflen < 0 || iolen > (u32)buflen) |
|---|
| 180 | | - { |
|---|
| 227 | + if (iolen > (u32)buflen) { |
|---|
| 181 | 228 | WLDEV_ERROR(("%s: buffer is too short\n", __FUNCTION__)); |
|---|
| 182 | 229 | return BCME_BUFTOOSHORT; |
|---|
| 183 | 230 | } |
|---|
| .. | .. |
|---|
| 215 | 262 | } |
|---|
| 216 | 263 | |
|---|
| 217 | 264 | wldev_mkiovar_bsscfg(iovar_name, param, paramlen, buf, buflen, bsscfg_idx); |
|---|
| 218 | | - ret = wldev_ioctl(dev, WLC_GET_VAR, buf, buflen, FALSE); |
|---|
| 265 | + ret = wldev_ioctl_get(dev, WLC_GET_VAR, buf, buflen); |
|---|
| 219 | 266 | if (buf_sync) { |
|---|
| 220 | 267 | mutex_unlock(buf_sync); |
|---|
| 221 | 268 | } |
|---|
| .. | .. |
|---|
| 224 | 271 | } |
|---|
| 225 | 272 | |
|---|
| 226 | 273 | s32 wldev_iovar_setbuf_bsscfg( |
|---|
| 227 | | - struct net_device *dev, s8 *iovar_name, |
|---|
| 228 | | - void *param, s32 paramlen, void *buf, s32 buflen, s32 bsscfg_idx, struct mutex* buf_sync) |
|---|
| 274 | + struct net_device *dev, const s8 *iovar_name, |
|---|
| 275 | + const void *param, s32 paramlen, |
|---|
| 276 | + void *buf, s32 buflen, s32 bsscfg_idx, struct mutex* buf_sync) |
|---|
| 229 | 277 | { |
|---|
| 230 | 278 | s32 ret = 0; |
|---|
| 231 | 279 | s32 iovar_len; |
|---|
| .. | .. |
|---|
| 234 | 282 | } |
|---|
| 235 | 283 | iovar_len = wldev_mkiovar_bsscfg(iovar_name, param, paramlen, buf, buflen, bsscfg_idx); |
|---|
| 236 | 284 | if (iovar_len > 0) |
|---|
| 237 | | - ret = wldev_ioctl(dev, WLC_SET_VAR, buf, iovar_len, TRUE); |
|---|
| 285 | + ret = wldev_ioctl_set(dev, WLC_SET_VAR, buf, iovar_len); |
|---|
| 238 | 286 | else { |
|---|
| 239 | 287 | ret = BCME_BUFTOOSHORT; |
|---|
| 240 | 288 | } |
|---|
| .. | .. |
|---|
| 255 | 303 | return wldev_iovar_setbuf_bsscfg(dev, iovar, &val, sizeof(val), iovar_buf, |
|---|
| 256 | 304 | sizeof(iovar_buf), bssidx, NULL); |
|---|
| 257 | 305 | } |
|---|
| 258 | | - |
|---|
| 259 | 306 | |
|---|
| 260 | 307 | s32 wldev_iovar_getint_bsscfg( |
|---|
| 261 | 308 | struct net_device *dev, s8 *iovar, s32 *pval, s32 bssidx) |
|---|
| .. | .. |
|---|
| 281 | 328 | |
|---|
| 282 | 329 | if (!plink_speed) |
|---|
| 283 | 330 | return -ENOMEM; |
|---|
| 284 | | - plink_speed = 0; |
|---|
| 285 | | - error = wldev_ioctl(dev, WLC_GET_RATE, plink_speed, sizeof(int), 0); |
|---|
| 331 | + *plink_speed = 0; |
|---|
| 332 | + error = wldev_ioctl_get(dev, WLC_GET_RATE, plink_speed, sizeof(int)); |
|---|
| 286 | 333 | if (unlikely(error)) |
|---|
| 287 | 334 | return error; |
|---|
| 288 | 335 | |
|---|
| .. | .. |
|---|
| 299 | 346 | if (!scb_val) |
|---|
| 300 | 347 | return -ENOMEM; |
|---|
| 301 | 348 | |
|---|
| 302 | | - memset(scb_val, 0, sizeof(scb_val_t)); |
|---|
| 303 | | - error = wldev_ioctl(dev, WLC_GET_RSSI, scb_val, sizeof(scb_val_t), 0); |
|---|
| 349 | + error = wldev_ioctl_get(dev, WLC_GET_RSSI, scb_val, sizeof(scb_val_t)); |
|---|
| 304 | 350 | if (unlikely(error)) |
|---|
| 305 | 351 | return error; |
|---|
| 306 | 352 | |
|---|
| .. | .. |
|---|
| 314 | 360 | |
|---|
| 315 | 361 | if (!pssid) |
|---|
| 316 | 362 | return -ENOMEM; |
|---|
| 317 | | - |
|---|
| 318 | 363 | memset(pssid, 0, sizeof(wlc_ssid_t)); |
|---|
| 319 | | - error = wldev_ioctl(dev, WLC_GET_SSID, pssid, sizeof(wlc_ssid_t), 0); |
|---|
| 364 | + error = wldev_ioctl_get(dev, WLC_GET_SSID, pssid, sizeof(wlc_ssid_t)); |
|---|
| 320 | 365 | if (unlikely(error)) |
|---|
| 321 | 366 | return error; |
|---|
| 322 | 367 | pssid->SSID_len = dtoh32(pssid->SSID_len); |
|---|
| .. | .. |
|---|
| 328 | 373 | { |
|---|
| 329 | 374 | int error; |
|---|
| 330 | 375 | |
|---|
| 331 | | - error = wldev_ioctl(dev, WLC_GET_BAND, pband, sizeof(uint), 0); |
|---|
| 376 | + *pband = 0; |
|---|
| 377 | + error = wldev_ioctl_get(dev, WLC_GET_BAND, pband, sizeof(uint)); |
|---|
| 332 | 378 | return error; |
|---|
| 333 | 379 | } |
|---|
| 334 | 380 | |
|---|
| .. | .. |
|---|
| 338 | 384 | int error = -1; |
|---|
| 339 | 385 | |
|---|
| 340 | 386 | if ((band == WLC_BAND_AUTO) || (band == WLC_BAND_5G) || (band == WLC_BAND_2G)) { |
|---|
| 341 | | - error = wldev_ioctl(dev, WLC_SET_BAND, &band, sizeof(band), true); |
|---|
| 387 | + error = wldev_ioctl_set(dev, WLC_SET_BAND, &band, sizeof(band)); |
|---|
| 342 | 388 | if (!error) |
|---|
| 343 | 389 | dhd_bus_band_set(dev, band); |
|---|
| 344 | 390 | } |
|---|
| .. | .. |
|---|
| 348 | 394 | { |
|---|
| 349 | 395 | int error = 0; |
|---|
| 350 | 396 | |
|---|
| 351 | | - error = wldev_ioctl(dev, WLC_GET_RATE, datarate, sizeof(int), false); |
|---|
| 397 | + error = wldev_ioctl_get(dev, WLC_GET_RATE, datarate, sizeof(int)); |
|---|
| 352 | 398 | if (error) { |
|---|
| 353 | 399 | return -1; |
|---|
| 354 | 400 | } else { |
|---|
| .. | .. |
|---|
| 362 | 408 | wl_chspec_driver_to_host(chanspec_t chanspec); |
|---|
| 363 | 409 | #define WL_EXTRA_BUF_MAX 2048 |
|---|
| 364 | 410 | int wldev_get_mode( |
|---|
| 365 | | - struct net_device *dev, uint8 *cap) |
|---|
| 411 | + struct net_device *dev, uint8 *cap, uint8 caplen) |
|---|
| 366 | 412 | { |
|---|
| 367 | 413 | int error = 0; |
|---|
| 368 | 414 | int chanspec = 0; |
|---|
| 369 | 415 | uint16 band = 0; |
|---|
| 370 | 416 | uint16 bandwidth = 0; |
|---|
| 371 | 417 | wl_bss_info_t *bss = NULL; |
|---|
| 372 | | - char* buf = kzalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL); |
|---|
| 418 | + char* buf = NULL; |
|---|
| 419 | + |
|---|
| 420 | + buf = kzalloc(WL_EXTRA_BUF_MAX, GFP_KERNEL); |
|---|
| 373 | 421 | if (!buf) { |
|---|
| 374 | | - WLDEV_ERROR(("%s:NOMEM\n", __FUNCTION__)); |
|---|
| 422 | + WLDEV_ERROR(("%s:ENOMEM\n", __FUNCTION__)); |
|---|
| 375 | 423 | return -ENOMEM; |
|---|
| 376 | 424 | } |
|---|
| 425 | + |
|---|
| 377 | 426 | *(u32*) buf = htod32(WL_EXTRA_BUF_MAX); |
|---|
| 378 | | - error = wldev_ioctl(dev, WLC_GET_BSS_INFO, (void*)buf, WL_EXTRA_BUF_MAX, false); |
|---|
| 427 | + error = wldev_ioctl_get(dev, WLC_GET_BSS_INFO, (void*)buf, WL_EXTRA_BUF_MAX); |
|---|
| 379 | 428 | if (error) { |
|---|
| 380 | 429 | WLDEV_ERROR(("%s:failed:%d\n", __FUNCTION__, error)); |
|---|
| 381 | 430 | kfree(buf); |
|---|
| 382 | 431 | buf = NULL; |
|---|
| 383 | 432 | return error; |
|---|
| 384 | 433 | } |
|---|
| 385 | | - bss = (struct wl_bss_info *)(buf + 4); |
|---|
| 434 | + bss = (wl_bss_info_t*)(buf + 4); |
|---|
| 386 | 435 | chanspec = wl_chspec_driver_to_host(bss->chanspec); |
|---|
| 387 | 436 | |
|---|
| 388 | 437 | band = chanspec & WL_CHANSPEC_BAND_MASK; |
|---|
| .. | .. |
|---|
| 390 | 439 | |
|---|
| 391 | 440 | if (band == WL_CHANSPEC_BAND_2G) { |
|---|
| 392 | 441 | if (bss->n_cap) |
|---|
| 393 | | - strcpy(cap, "n"); |
|---|
| 442 | + strncpy(cap, "n", caplen); |
|---|
| 394 | 443 | else |
|---|
| 395 | | - strcpy(cap, "bg"); |
|---|
| 444 | + strncpy(cap, "bg", caplen); |
|---|
| 396 | 445 | } else if (band == WL_CHANSPEC_BAND_5G) { |
|---|
| 397 | 446 | if (bandwidth == WL_CHANSPEC_BW_80) |
|---|
| 398 | | - strcpy(cap, "ac"); |
|---|
| 447 | + strncpy(cap, "ac", caplen); |
|---|
| 399 | 448 | else if ((bandwidth == WL_CHANSPEC_BW_40) || (bandwidth == WL_CHANSPEC_BW_20)) { |
|---|
| 400 | 449 | if ((bss->nbss_cap & 0xf00) && (bss->n_cap)) |
|---|
| 401 | | - strcpy(cap, "n|ac"); |
|---|
| 450 | + strncpy(cap, "n|ac", caplen); |
|---|
| 402 | 451 | else if (bss->n_cap) |
|---|
| 403 | | - strcpy(cap, "n"); |
|---|
| 452 | + strncpy(cap, "n", caplen); |
|---|
| 404 | 453 | else if (bss->vht_cap) |
|---|
| 405 | | - strcpy(cap, "ac"); |
|---|
| 454 | + strncpy(cap, "ac", caplen); |
|---|
| 406 | 455 | else |
|---|
| 407 | | - strcpy(cap, "a"); |
|---|
| 456 | + strncpy(cap, "a", caplen); |
|---|
| 408 | 457 | } else { |
|---|
| 409 | 458 | WLDEV_ERROR(("%s:Mode get failed\n", __FUNCTION__)); |
|---|
| 410 | 459 | error = BCME_ERROR; |
|---|
| .. | .. |
|---|
| 422 | 471 | wl_country_t cspec = {{0}, 0, {0}}; |
|---|
| 423 | 472 | scb_val_t scbval; |
|---|
| 424 | 473 | char smbuf[WLC_IOCTL_SMLEN]; |
|---|
| 474 | +#ifdef WL_CFG80211 |
|---|
| 475 | + struct wireless_dev *wdev = ndev_to_wdev(dev); |
|---|
| 476 | + struct wiphy *wiphy = wdev->wiphy; |
|---|
| 477 | + struct bcm_cfg80211 *cfg = wiphy_priv(wiphy); |
|---|
| 478 | +#endif /* WL_CFG80211 */ |
|---|
| 425 | 479 | |
|---|
| 426 | 480 | if (!country_code) |
|---|
| 427 | 481 | return error; |
|---|
| .. | .. |
|---|
| 434 | 488 | } |
|---|
| 435 | 489 | |
|---|
| 436 | 490 | if ((error < 0) || |
|---|
| 437 | | - dhd_force_country_change(dev) || |
|---|
| 438 | | - (strncmp(country_code, cspec.country_abbrev, WLC_CNTRY_BUF_SZ) != 0)) { |
|---|
| 491 | +#ifdef OEM_ANDROID |
|---|
| 492 | + dhd_force_country_change(dev) || |
|---|
| 493 | +#endif /* OEM_ANDROID */ |
|---|
| 494 | + (strncmp(country_code, cspec.ccode, WLC_CNTRY_BUF_SZ) != 0)) { |
|---|
| 439 | 495 | |
|---|
| 496 | +#ifdef WL_CFG80211 |
|---|
| 497 | + if ((user_enforced) && (wl_get_drv_status(cfg, CONNECTED, dev))) { |
|---|
| 498 | +#else |
|---|
| 440 | 499 | if (user_enforced) { |
|---|
| 500 | +#endif /* WL_CFG80211 */ |
|---|
| 441 | 501 | bzero(&scbval, sizeof(scb_val_t)); |
|---|
| 442 | | - error = wldev_ioctl(dev, WLC_DISASSOC, &scbval, sizeof(scb_val_t), true); |
|---|
| 502 | + error = wldev_ioctl_set(dev, WLC_DISASSOC, |
|---|
| 503 | + &scbval, sizeof(scb_val_t)); |
|---|
| 443 | 504 | if (error < 0) { |
|---|
| 444 | 505 | WLDEV_ERROR(("%s: set country failed due to Disassoc error %d\n", |
|---|
| 445 | 506 | __FUNCTION__, error)); |
|---|
| .. | .. |
|---|
| 447 | 508 | } |
|---|
| 448 | 509 | } |
|---|
| 449 | 510 | |
|---|
| 511 | + wl_cfg80211_scan_abort(cfg); |
|---|
| 512 | + |
|---|
| 450 | 513 | cspec.rev = revinfo; |
|---|
| 451 | | - memcpy(cspec.country_abbrev, country_code, WLC_CNTRY_BUF_SZ); |
|---|
| 452 | | - memcpy(cspec.ccode, country_code, WLC_CNTRY_BUF_SZ); |
|---|
| 514 | + strlcpy(cspec.country_abbrev, country_code, WLC_CNTRY_BUF_SZ); |
|---|
| 515 | + strlcpy(cspec.ccode, country_code, WLC_CNTRY_BUF_SZ); |
|---|
| 453 | 516 | dhd_get_customized_country_code(dev, (char *)&cspec.country_abbrev, &cspec); |
|---|
| 454 | 517 | error = wldev_iovar_setbuf(dev, "country", &cspec, sizeof(cspec), |
|---|
| 455 | 518 | smbuf, sizeof(smbuf), NULL); |
|---|
| .. | .. |
|---|
| 459 | 522 | return error; |
|---|
| 460 | 523 | } |
|---|
| 461 | 524 | dhd_bus_country_set(dev, &cspec, notify); |
|---|
| 462 | | - WLDEV_ERROR(("%s: set country for %s as %s rev %d\n", |
|---|
| 525 | + WLDEV_INFO(("%s: set country for %s as %s rev %d\n", |
|---|
| 463 | 526 | __FUNCTION__, country_code, cspec.ccode, cspec.rev)); |
|---|
| 464 | 527 | } |
|---|
| 465 | 528 | return 0; |
|---|