| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: ISC |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (c) 2010 Broadcom Corporation |
|---|
| 3 | | - * |
|---|
| 4 | | - * Permission to use, copy, modify, and/or distribute this software for any |
|---|
| 5 | | - * purpose with or without fee is hereby granted, provided that the above |
|---|
| 6 | | - * copyright notice and this permission notice appear in all copies. |
|---|
| 7 | | - * |
|---|
| 8 | | - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|---|
| 9 | | - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|---|
| 10 | | - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY |
|---|
| 11 | | - * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|---|
| 12 | | - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION |
|---|
| 13 | | - * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN |
|---|
| 14 | | - * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|---|
| 15 | 4 | */ |
|---|
| 16 | 5 | |
|---|
| 17 | 6 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 90 | 79 | |
|---|
| 91 | 80 | void brcmf_c_set_joinpref_default(struct brcmf_if *ifp) |
|---|
| 92 | 81 | { |
|---|
| 82 | + struct brcmf_pub *drvr = ifp->drvr; |
|---|
| 93 | 83 | struct brcmf_join_pref_params join_pref_params[2]; |
|---|
| 94 | 84 | int err; |
|---|
| 95 | 85 | |
|---|
| .. | .. |
|---|
| 106 | 96 | err = brcmf_fil_iovar_data_set(ifp, "join_pref", join_pref_params, |
|---|
| 107 | 97 | sizeof(join_pref_params)); |
|---|
| 108 | 98 | if (err) |
|---|
| 109 | | - brcmf_err("Set join_pref error (%d)\n", err); |
|---|
| 99 | + bphy_err(drvr, "Set join_pref error (%d)\n", err); |
|---|
| 110 | 100 | } |
|---|
| 111 | 101 | |
|---|
| 112 | 102 | static int brcmf_c_download(struct brcmf_if *ifp, u16 flag, |
|---|
| .. | .. |
|---|
| 129 | 119 | |
|---|
| 130 | 120 | static int brcmf_c_process_clm_blob(struct brcmf_if *ifp) |
|---|
| 131 | 121 | { |
|---|
| 132 | | - struct brcmf_bus *bus = ifp->drvr->bus_if; |
|---|
| 122 | + struct brcmf_pub *drvr = ifp->drvr; |
|---|
| 123 | + struct brcmf_bus *bus = drvr->bus_if; |
|---|
| 133 | 124 | struct brcmf_dload_data_le *chunk_buf; |
|---|
| 134 | 125 | const struct firmware *clm = NULL; |
|---|
| 135 | 126 | u8 clm_name[BRCMF_FW_NAME_LEN]; |
|---|
| .. | .. |
|---|
| 145 | 136 | memset(clm_name, 0, sizeof(clm_name)); |
|---|
| 146 | 137 | err = brcmf_bus_get_fwname(bus, ".clm_blob", clm_name); |
|---|
| 147 | 138 | if (err) { |
|---|
| 148 | | - brcmf_err("get CLM blob file name failed (%d)\n", err); |
|---|
| 139 | + bphy_err(drvr, "get CLM blob file name failed (%d)\n", err); |
|---|
| 149 | 140 | return err; |
|---|
| 150 | 141 | } |
|---|
| 151 | 142 | |
|---|
| .. | .. |
|---|
| 182 | 173 | } while ((datalen > 0) && (err == 0)); |
|---|
| 183 | 174 | |
|---|
| 184 | 175 | if (err) { |
|---|
| 185 | | - brcmf_err("clmload (%zu byte file) failed (%d); ", |
|---|
| 186 | | - clm->size, err); |
|---|
| 176 | + bphy_err(drvr, "clmload (%zu byte file) failed (%d)\n", |
|---|
| 177 | + clm->size, err); |
|---|
| 187 | 178 | /* Retrieve clmload_status and print */ |
|---|
| 188 | 179 | err = brcmf_fil_iovar_int_get(ifp, "clmload_status", &status); |
|---|
| 189 | 180 | if (err) |
|---|
| 190 | | - brcmf_err("get clmload_status failed (%d)\n", err); |
|---|
| 181 | + bphy_err(drvr, "get clmload_status failed (%d)\n", err); |
|---|
| 191 | 182 | else |
|---|
| 192 | 183 | brcmf_dbg(INFO, "clmload_status=%d\n", status); |
|---|
| 193 | 184 | err = -EIO; |
|---|
| .. | .. |
|---|
| 201 | 192 | |
|---|
| 202 | 193 | int brcmf_c_preinit_dcmds(struct brcmf_if *ifp) |
|---|
| 203 | 194 | { |
|---|
| 195 | + struct brcmf_pub *drvr = ifp->drvr; |
|---|
| 204 | 196 | s8 eventmask[BRCMF_EVENTING_MASK_LEN]; |
|---|
| 205 | 197 | u8 buf[BRCMF_DCMD_SMLEN]; |
|---|
| 206 | 198 | struct brcmf_bus *bus; |
|---|
| .. | .. |
|---|
| 214 | 206 | err = brcmf_fil_iovar_data_get(ifp, "cur_etheraddr", ifp->mac_addr, |
|---|
| 215 | 207 | sizeof(ifp->mac_addr)); |
|---|
| 216 | 208 | if (err < 0) { |
|---|
| 217 | | - brcmf_err("Retreiving cur_etheraddr failed, %d\n", err); |
|---|
| 209 | + bphy_err(drvr, "Retrieving cur_etheraddr failed, %d\n", err); |
|---|
| 218 | 210 | goto done; |
|---|
| 219 | 211 | } |
|---|
| 220 | | - memcpy(ifp->drvr->wiphy->perm_addr, ifp->drvr->mac, ETH_ALEN); |
|---|
| 221 | 212 | memcpy(ifp->drvr->mac, ifp->mac_addr, sizeof(ifp->drvr->mac)); |
|---|
| 213 | + memcpy(ifp->drvr->wiphy->perm_addr, ifp->drvr->mac, ETH_ALEN); |
|---|
| 222 | 214 | |
|---|
| 223 | 215 | bus = ifp->drvr->bus_if; |
|---|
| 224 | 216 | ri = &ifp->drvr->revinfo; |
|---|
| .. | .. |
|---|
| 226 | 218 | err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_REVINFO, |
|---|
| 227 | 219 | &revinfo, sizeof(revinfo)); |
|---|
| 228 | 220 | if (err < 0) { |
|---|
| 229 | | - brcmf_err("retrieving revision info failed, %d\n", err); |
|---|
| 221 | + bphy_err(drvr, "retrieving revision info failed, %d\n", err); |
|---|
| 230 | 222 | strlcpy(ri->chipname, "UNKNOWN", sizeof(ri->chipname)); |
|---|
| 231 | 223 | } else { |
|---|
| 232 | 224 | ri->vendorid = le32_to_cpu(revinfo.vendorid); |
|---|
| .. | .. |
|---|
| 260 | 252 | /* Do any CLM downloading */ |
|---|
| 261 | 253 | err = brcmf_c_process_clm_blob(ifp); |
|---|
| 262 | 254 | if (err < 0) { |
|---|
| 263 | | - brcmf_err("download CLM blob file failed, %d\n", err); |
|---|
| 255 | + bphy_err(drvr, "download CLM blob file failed, %d\n", err); |
|---|
| 264 | 256 | goto done; |
|---|
| 265 | 257 | } |
|---|
| 266 | 258 | |
|---|
| 267 | 259 | /* query for 'ver' to get version info from firmware */ |
|---|
| 268 | 260 | memset(buf, 0, sizeof(buf)); |
|---|
| 269 | | - strcpy(buf, "ver"); |
|---|
| 270 | 261 | err = brcmf_fil_iovar_data_get(ifp, "ver", buf, sizeof(buf)); |
|---|
| 271 | 262 | if (err < 0) { |
|---|
| 272 | | - brcmf_err("Retreiving version information failed, %d\n", |
|---|
| 273 | | - err); |
|---|
| 263 | + bphy_err(drvr, "Retrieving version information failed, %d\n", |
|---|
| 264 | + err); |
|---|
| 274 | 265 | goto done; |
|---|
| 275 | 266 | } |
|---|
| 276 | 267 | ptr = (char *)buf; |
|---|
| .. | .. |
|---|
| 304 | 295 | /* set mpc */ |
|---|
| 305 | 296 | err = brcmf_fil_iovar_int_set(ifp, "mpc", 1); |
|---|
| 306 | 297 | if (err) { |
|---|
| 307 | | - brcmf_err("failed setting mpc\n"); |
|---|
| 298 | + bphy_err(drvr, "failed setting mpc\n"); |
|---|
| 308 | 299 | goto done; |
|---|
| 309 | 300 | } |
|---|
| 310 | 301 | |
|---|
| .. | .. |
|---|
| 314 | 305 | err = brcmf_fil_iovar_data_get(ifp, "event_msgs", eventmask, |
|---|
| 315 | 306 | BRCMF_EVENTING_MASK_LEN); |
|---|
| 316 | 307 | if (err) { |
|---|
| 317 | | - brcmf_err("Get event_msgs error (%d)\n", err); |
|---|
| 308 | + bphy_err(drvr, "Get event_msgs error (%d)\n", err); |
|---|
| 318 | 309 | goto done; |
|---|
| 319 | 310 | } |
|---|
| 320 | 311 | setbit(eventmask, BRCMF_E_IF); |
|---|
| 321 | 312 | err = brcmf_fil_iovar_data_set(ifp, "event_msgs", eventmask, |
|---|
| 322 | 313 | BRCMF_EVENTING_MASK_LEN); |
|---|
| 323 | 314 | if (err) { |
|---|
| 324 | | - brcmf_err("Set event_msgs error (%d)\n", err); |
|---|
| 315 | + bphy_err(drvr, "Set event_msgs error (%d)\n", err); |
|---|
| 325 | 316 | goto done; |
|---|
| 326 | 317 | } |
|---|
| 327 | 318 | |
|---|
| .. | .. |
|---|
| 329 | 320 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_CHANNEL_TIME, |
|---|
| 330 | 321 | BRCMF_DEFAULT_SCAN_CHANNEL_TIME); |
|---|
| 331 | 322 | if (err) { |
|---|
| 332 | | - brcmf_err("BRCMF_C_SET_SCAN_CHANNEL_TIME error (%d)\n", |
|---|
| 333 | | - err); |
|---|
| 323 | + bphy_err(drvr, "BRCMF_C_SET_SCAN_CHANNEL_TIME error (%d)\n", |
|---|
| 324 | + err); |
|---|
| 334 | 325 | goto done; |
|---|
| 335 | 326 | } |
|---|
| 336 | 327 | |
|---|
| .. | .. |
|---|
| 338 | 329 | err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_UNASSOC_TIME, |
|---|
| 339 | 330 | BRCMF_DEFAULT_SCAN_UNASSOC_TIME); |
|---|
| 340 | 331 | if (err) { |
|---|
| 341 | | - brcmf_err("BRCMF_C_SET_SCAN_UNASSOC_TIME error (%d)\n", |
|---|
| 342 | | - err); |
|---|
| 332 | + bphy_err(drvr, "BRCMF_C_SET_SCAN_UNASSOC_TIME error (%d)\n", |
|---|
| 333 | + err); |
|---|
| 343 | 334 | goto done; |
|---|
| 344 | 335 | } |
|---|
| 345 | 336 | |
|---|
| .. | .. |
|---|
| 350 | 341 | } |
|---|
| 351 | 342 | |
|---|
| 352 | 343 | #ifndef CONFIG_BRCM_TRACING |
|---|
| 353 | | -void __brcmf_err(const char *func, const char *fmt, ...) |
|---|
| 344 | +void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...) |
|---|
| 354 | 345 | { |
|---|
| 355 | 346 | struct va_format vaf; |
|---|
| 356 | 347 | va_list args; |
|---|
| .. | .. |
|---|
| 359 | 350 | |
|---|
| 360 | 351 | vaf.fmt = fmt; |
|---|
| 361 | 352 | vaf.va = &args; |
|---|
| 362 | | - pr_err("%s: %pV", func, &vaf); |
|---|
| 353 | + if (bus) |
|---|
| 354 | + dev_err(bus->dev, "%s: %pV", func, &vaf); |
|---|
| 355 | + else |
|---|
| 356 | + pr_err("%s: %pV", func, &vaf); |
|---|
| 363 | 357 | |
|---|
| 364 | 358 | va_end(args); |
|---|
| 365 | 359 | } |
|---|
| .. | .. |
|---|
| 448 | 442 | } |
|---|
| 449 | 443 | } |
|---|
| 450 | 444 | if (!found) { |
|---|
| 451 | | - /* No platform data for this device, try OF (Open Firwmare) */ |
|---|
| 445 | + /* No platform data for this device, try OF and DMI data */ |
|---|
| 446 | + brcmf_dmi_probe(settings, chip, chiprev); |
|---|
| 452 | 447 | brcmf_of_probe(dev, bus_type, settings); |
|---|
| 453 | 448 | } |
|---|
| 454 | 449 | return settings; |
|---|