344-0018-brcmfmac-merge-platform-data-and-module-paramaters.patch 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. From: Hante Meuleman <meuleman@broadcom.com>
  2. Date: Wed, 17 Feb 2016 11:27:08 +0100
  3. Subject: [PATCH] brcmfmac: merge platform data and module paramaters
  4. Merge module parameters and platform data in one struct. This is the
  5. last step to move to the new platform data per device. Now parameters
  6. of platform data will be merged with module parameters per device.
  7. Reviewed-by: Arend Van Spriel <arend@broadcom.com>
  8. Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
  9. Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
  10. Signed-off-by: Hante Meuleman <meuleman@broadcom.com>
  11. Signed-off-by: Arend van Spriel <arend@broadcom.com>
  12. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  13. ---
  14. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
  15. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c
  16. @@ -109,8 +109,8 @@ int brcmf_sdiod_intr_register(struct brc
  17. u32 addr, gpiocontrol;
  18. unsigned long flags;
  19. - pdata = sdiodev->pdata;
  20. - if ((pdata) && (pdata->oob_irq_supported)) {
  21. + pdata = &sdiodev->settings->bus.sdio;
  22. + if (pdata->oob_irq_supported) {
  23. brcmf_dbg(SDIO, "Enter, register OOB IRQ %d\n",
  24. pdata->oob_irq_nr);
  25. ret = request_irq(pdata->oob_irq_nr, brcmf_sdiod_oob_irqhandler,
  26. @@ -177,8 +177,8 @@ int brcmf_sdiod_intr_unregister(struct b
  27. brcmf_dbg(SDIO, "Entering\n");
  28. - pdata = sdiodev->pdata;
  29. - if ((pdata) && (pdata->oob_irq_supported)) {
  30. + pdata = &sdiodev->settings->bus.sdio;
  31. + if (pdata->oob_irq_supported) {
  32. sdio_claim_host(sdiodev->func[1]);
  33. brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, 0, NULL);
  34. brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_IENx, 0, NULL);
  35. @@ -522,7 +522,7 @@ static int brcmf_sdiod_sglist_rw(struct
  36. target_list = pktlist;
  37. /* for host with broken sg support, prepare a page aligned list */
  38. __skb_queue_head_init(&local_list);
  39. - if (sdiodev->pdata && sdiodev->pdata->broken_sg_support && !write) {
  40. + if (!write && sdiodev->settings->bus.sdio.broken_sg_support) {
  41. req_sz = 0;
  42. skb_queue_walk(pktlist, pkt_next)
  43. req_sz += pkt_next->len;
  44. @@ -629,7 +629,7 @@ static int brcmf_sdiod_sglist_rw(struct
  45. }
  46. }
  47. - if (sdiodev->pdata && sdiodev->pdata->broken_sg_support && !write) {
  48. + if (!write && sdiodev->settings->bus.sdio.broken_sg_support) {
  49. local_pkt_next = local_list.next;
  50. orig_offset = 0;
  51. skb_queue_walk(pktlist, pkt_next) {
  52. @@ -900,7 +900,7 @@ void brcmf_sdiod_sgtable_alloc(struct br
  53. return;
  54. nents = max_t(uint, BRCMF_DEFAULT_RXGLOM_SIZE,
  55. - sdiodev->bus_if->drvr->settings->sdiod_txglomsz);
  56. + sdiodev->settings->bus.sdio.txglomsz);
  57. nents += (nents >> 4) + 1;
  58. WARN_ON(nents > sdiodev->max_segment_count);
  59. @@ -912,7 +912,7 @@ void brcmf_sdiod_sgtable_alloc(struct br
  60. sdiodev->sg_support = false;
  61. }
  62. - sdiodev->txglomsz = sdiodev->bus_if->drvr->settings->sdiod_txglomsz;
  63. + sdiodev->txglomsz = sdiodev->settings->bus.sdio.txglomsz;
  64. }
  65. #ifdef CONFIG_PM_SLEEP
  66. @@ -1246,8 +1246,8 @@ static int brcmf_ops_sdio_suspend(struct
  67. sdio_flags = MMC_PM_KEEP_POWER;
  68. if (sdiodev->wowl_enabled) {
  69. - if (sdiodev->pdata->oob_irq_supported)
  70. - enable_irq_wake(sdiodev->pdata->oob_irq_nr);
  71. + if (sdiodev->settings->bus.sdio.oob_irq_supported)
  72. + enable_irq_wake(sdiodev->settings->bus.sdio.oob_irq_nr);
  73. else
  74. sdio_flags |= MMC_PM_WAKE_SDIO_IRQ;
  75. }
  76. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
  77. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
  78. @@ -43,6 +43,8 @@ enum brcmf_bus_protocol_type {
  79. BRCMF_PROTO_MSGBUF
  80. };
  81. +struct brcmf_mp_device;
  82. +
  83. struct brcmf_bus_dcmd {
  84. char *name;
  85. char *param;
  86. @@ -217,7 +219,7 @@ bool brcmf_c_prec_enq(struct device *dev
  87. void brcmf_rx_frame(struct device *dev, struct sk_buff *rxp);
  88. /* Indication from bus module regarding presence/insertion of dongle. */
  89. -int brcmf_attach(struct device *dev);
  90. +int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings);
  91. /* Indication from bus module regarding removal/absence of dongle */
  92. void brcmf_detach(struct device *dev);
  93. /* Indication from bus module that dongle should be reset */
  94. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
  95. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
  96. @@ -243,14 +243,35 @@ static void brcmf_mp_attach(void)
  97. }
  98. }
  99. -struct brcmfmac_sdio_pd *brcmf_get_module_param(struct device *dev,
  100. - enum brcmf_bus_type bus_type,
  101. - u32 chip, u32 chiprev)
  102. +struct brcmf_mp_device *brcmf_get_module_param(struct device *dev,
  103. + enum brcmf_bus_type bus_type,
  104. + u32 chip, u32 chiprev)
  105. {
  106. - struct brcmfmac_sdio_pd *pdata;
  107. + struct brcmf_mp_device *settings;
  108. struct brcmfmac_pd_device *device_pd;
  109. + bool found;
  110. int i;
  111. + brcmf_dbg(INFO, "Enter, bus=%d, chip=%d, rev=%d\n", bus_type, chip,
  112. + chiprev);
  113. + settings = kzalloc(sizeof(*settings), GFP_ATOMIC);
  114. + if (!settings)
  115. + return NULL;
  116. +
  117. + /* start by using the module paramaters */
  118. + settings->p2p_enable = !!brcmf_p2p_enable;
  119. + settings->feature_disable = brcmf_feature_disable;
  120. + settings->fcmode = brcmf_fcmode;
  121. + settings->roamoff = !!brcmf_roamoff;
  122. +#ifdef DEBUG
  123. + settings->ignore_probe_fail = !!brcmf_ignore_probe_fail;
  124. +#endif
  125. +
  126. + if (bus_type == BRCMF_BUSTYPE_SDIO)
  127. + settings->bus.sdio.txglomsz = brcmf_sdiod_txglomsz;
  128. +
  129. + /* See if there is any device specific platform data configured */
  130. + found = false;
  131. if (brcmfmac_pdata) {
  132. for (i = 0; i < brcmfmac_pdata->device_count; i++) {
  133. device_pd = &brcmfmac_pdata->devices[i];
  134. @@ -259,38 +280,29 @@ struct brcmfmac_sdio_pd *brcmf_get_modul
  135. ((device_pd->rev == chiprev) ||
  136. (device_pd->rev == -1))) {
  137. brcmf_dbg(INFO, "Platform data for device found\n");
  138. + settings->country_codes =
  139. + device_pd->country_codes;
  140. if (device_pd->bus_type == BRCMF_BUSTYPE_SDIO)
  141. - return &device_pd->bus.sdio;
  142. + memcpy(&settings->bus.sdio,
  143. + &device_pd->bus.sdio,
  144. + sizeof(settings->bus.sdio));
  145. + found = true;
  146. break;
  147. }
  148. }
  149. }
  150. - pdata = NULL;
  151. - brcmf_of_probe(dev, &pdata);
  152. -
  153. - return pdata;
  154. -}
  155. -
  156. -int brcmf_mp_device_attach(struct brcmf_pub *drvr)
  157. -{
  158. - drvr->settings = kzalloc(sizeof(*drvr->settings), GFP_ATOMIC);
  159. - if (!drvr->settings)
  160. - return -ENOMEM;
  161. -
  162. - drvr->settings->sdiod_txglomsz = brcmf_sdiod_txglomsz;
  163. - drvr->settings->p2p_enable = !!brcmf_p2p_enable;
  164. - drvr->settings->feature_disable = brcmf_feature_disable;
  165. - drvr->settings->fcmode = brcmf_fcmode;
  166. - drvr->settings->roamoff = !!brcmf_roamoff;
  167. -#ifdef DEBUG
  168. - drvr->settings->ignore_probe_fail = !!brcmf_ignore_probe_fail;
  169. -#endif
  170. - return 0;
  171. + if ((bus_type == BRCMF_BUSTYPE_SDIO) && (!found)) {
  172. + /* No platform data for this device. In case of SDIO try OF
  173. + * (Open Firwmare) Device Tree.
  174. + */
  175. + brcmf_of_probe(dev, &settings->bus.sdio);
  176. + }
  177. + return settings;
  178. }
  179. -void brcmf_mp_device_detach(struct brcmf_pub *drvr)
  180. +void brcmf_release_module_param(struct brcmf_mp_device *module_param)
  181. {
  182. - kfree(drvr->settings);
  183. + kfree(module_param);
  184. }
  185. static int __init brcmf_common_pd_probe(struct platform_device *pdev)
  186. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
  187. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h
  188. @@ -45,41 +45,30 @@ extern struct brcmf_mp_global_t brcmf_mp
  189. /**
  190. * struct brcmf_mp_device - Device module paramaters.
  191. *
  192. - * @sdiod_txglomsz: SDIO txglom size.
  193. - * @joinboost_5g_rssi: 5g rssi booost for preferred join selection.
  194. * @p2p_enable: Legacy P2P0 enable (old wpa_supplicant).
  195. * @feature_disable: Feature_disable bitmask.
  196. * @fcmode: FWS flow control.
  197. * @roamoff: Firmware roaming off?
  198. + * @ignore_probe_fail: Ignore probe failure.
  199. * @country_codes: If available, pointer to struct for translating country codes
  200. + * @bus: Bus specific platform data. Only SDIO at the mmoment.
  201. */
  202. struct brcmf_mp_device {
  203. - int sdiod_txglomsz;
  204. - int joinboost_5g_rssi;
  205. - bool p2p_enable;
  206. - int feature_disable;
  207. - int fcmode;
  208. - bool roamoff;
  209. - bool ignore_probe_fail;
  210. + bool p2p_enable;
  211. + unsigned int feature_disable;
  212. + int fcmode;
  213. + bool roamoff;
  214. + bool ignore_probe_fail;
  215. struct brcmfmac_pd_cc *country_codes;
  216. + union {
  217. + struct brcmfmac_sdio_pd sdio;
  218. + } bus;
  219. };
  220. -struct brcmfmac_sdio_pd *brcmf_get_module_param(struct device *dev,
  221. - enum brcmf_bus_type bus_type,
  222. - u32 chip, u32 chiprev);
  223. -int brcmf_mp_device_attach(struct brcmf_pub *drvr);
  224. -void brcmf_mp_device_detach(struct brcmf_pub *drvr);
  225. -#ifdef DEBUG
  226. -static inline bool brcmf_ignoring_probe_fail(struct brcmf_pub *drvr)
  227. -{
  228. - return drvr->settings->ignore_probe_fail;
  229. -}
  230. -#else
  231. -static inline bool brcmf_ignoring_probe_fail(struct brcmf_pub *drvr)
  232. -{
  233. - return false;
  234. -}
  235. -#endif
  236. +struct brcmf_mp_device *brcmf_get_module_param(struct device *dev,
  237. + enum brcmf_bus_type bus_type,
  238. + u32 chip, u32 chiprev);
  239. +void brcmf_release_module_param(struct brcmf_mp_device *module_param);
  240. /* Sets dongle media info (drv_version, mac address). */
  241. int brcmf_c_preinit_dcmds(struct brcmf_if *ifp);
  242. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  243. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  244. @@ -1104,7 +1104,7 @@ static int brcmf_inet6addr_changed(struc
  245. }
  246. #endif
  247. -int brcmf_attach(struct device *dev)
  248. +int brcmf_attach(struct device *dev, struct brcmf_mp_device *settings)
  249. {
  250. struct brcmf_pub *drvr = NULL;
  251. int ret = 0;
  252. @@ -1126,10 +1126,7 @@ int brcmf_attach(struct device *dev)
  253. drvr->hdrlen = 0;
  254. drvr->bus_if = dev_get_drvdata(dev);
  255. drvr->bus_if->drvr = drvr;
  256. -
  257. - /* Initialize device specific settings */
  258. - if (brcmf_mp_device_attach(drvr))
  259. - goto fail;
  260. + drvr->settings = settings;
  261. /* attach debug facilities */
  262. brcmf_debug_attach(drvr);
  263. @@ -1274,7 +1271,7 @@ fail:
  264. brcmf_net_detach(p2p_ifp->ndev);
  265. drvr->iflist[0] = NULL;
  266. drvr->iflist[1] = NULL;
  267. - if (brcmf_ignoring_probe_fail(drvr))
  268. + if (drvr->settings->ignore_probe_fail)
  269. ret = 0;
  270. return ret;
  271. @@ -1350,8 +1347,6 @@ void brcmf_detach(struct device *dev)
  272. brcmf_proto_detach(drvr);
  273. - brcmf_mp_device_detach(drvr);
  274. -
  275. brcmf_debug_detach(drvr);
  276. bus_if->drvr = NULL;
  277. kfree(drvr);
  278. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
  279. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c
  280. @@ -23,7 +23,7 @@
  281. #include "common.h"
  282. #include "of.h"
  283. -void brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_pd **sdio)
  284. +void brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_pd *sdio)
  285. {
  286. struct device_node *np = dev->of_node;
  287. int irq;
  288. @@ -33,12 +33,8 @@ void brcmf_of_probe(struct device *dev,
  289. if (!np || !of_device_is_compatible(np, "brcm,bcm4329-fmac"))
  290. return;
  291. - *sdio = devm_kzalloc(dev, sizeof(*sdio), GFP_KERNEL);
  292. - if (!(*sdio))
  293. - return;
  294. -
  295. if (of_property_read_u32(np, "brcm,drive-strength", &val) == 0)
  296. - (*sdio)->drive_strength = val;
  297. + sdio->drive_strength = val;
  298. /* make sure there are interrupts defined in the node */
  299. if (!of_find_property(np, "interrupts", NULL))
  300. @@ -51,7 +47,7 @@ void brcmf_of_probe(struct device *dev,
  301. }
  302. irqf = irqd_get_trigger_type(irq_get_irq_data(irq));
  303. - (*sdio)->oob_irq_supported = true;
  304. - (*sdio)->oob_irq_nr = irq;
  305. - (*sdio)->oob_irq_flags = irqf;
  306. + sdio->oob_irq_supported = true;
  307. + sdio->oob_irq_nr = irq;
  308. + sdio->oob_irq_flags = irqf;
  309. }
  310. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h
  311. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h
  312. @@ -14,10 +14,9 @@
  313. * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  314. */
  315. #ifdef CONFIG_OF
  316. -void
  317. -brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_pd **sdio);
  318. +void brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_pd *sdio);
  319. #else
  320. -static void brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_pd **sdio)
  321. +static void brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_pd *sdio)
  322. {
  323. }
  324. #endif /* CONFIG_OF */
  325. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  326. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
  327. @@ -37,6 +37,8 @@
  328. #include "pcie.h"
  329. #include "firmware.h"
  330. #include "chip.h"
  331. +#include "core.h"
  332. +#include "common.h"
  333. enum brcmf_pcie_state {
  334. @@ -266,6 +268,7 @@ struct brcmf_pciedev_info {
  335. u16 (*read_ptr)(struct brcmf_pciedev_info *devinfo, u32 mem_offset);
  336. void (*write_ptr)(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
  337. u16 value);
  338. + struct brcmf_mp_device *settings;
  339. };
  340. struct brcmf_pcie_ringbuf {
  341. @@ -1525,16 +1528,16 @@ static void brcmf_pcie_release_resource(
  342. }
  343. -static int brcmf_pcie_attach_bus(struct device *dev)
  344. +static int brcmf_pcie_attach_bus(struct brcmf_pciedev_info *devinfo)
  345. {
  346. int ret;
  347. /* Attach to the common driver interface */
  348. - ret = brcmf_attach(dev);
  349. + ret = brcmf_attach(&devinfo->pdev->dev, devinfo->settings);
  350. if (ret) {
  351. brcmf_err("brcmf_attach failed\n");
  352. } else {
  353. - ret = brcmf_bus_start(dev);
  354. + ret = brcmf_bus_start(&devinfo->pdev->dev);
  355. if (ret)
  356. brcmf_err("dongle is not responding\n");
  357. }
  358. @@ -1672,7 +1675,7 @@ static void brcmf_pcie_setup(struct devi
  359. init_waitqueue_head(&devinfo->mbdata_resp_wait);
  360. brcmf_pcie_intr_enable(devinfo);
  361. - if (brcmf_pcie_attach_bus(bus->dev) == 0)
  362. + if (brcmf_pcie_attach_bus(devinfo) == 0)
  363. return;
  364. brcmf_pcie_bus_console_read(devinfo);
  365. @@ -1716,6 +1719,15 @@ brcmf_pcie_probe(struct pci_dev *pdev, c
  366. goto fail;
  367. }
  368. + devinfo->settings = brcmf_get_module_param(&devinfo->pdev->dev,
  369. + BRCMF_BUSTYPE_PCIE,
  370. + devinfo->ci->chip,
  371. + devinfo->ci->chiprev);
  372. + if (!devinfo->settings) {
  373. + ret = -ENOMEM;
  374. + goto fail;
  375. + }
  376. +
  377. bus = kzalloc(sizeof(*bus), GFP_KERNEL);
  378. if (!bus) {
  379. ret = -ENOMEM;
  380. @@ -1760,6 +1772,8 @@ fail:
  381. brcmf_pcie_release_resource(devinfo);
  382. if (devinfo->ci)
  383. brcmf_chip_detach(devinfo->ci);
  384. + if (devinfo->settings)
  385. + brcmf_release_module_param(devinfo->settings);
  386. kfree(pcie_bus_dev);
  387. kfree(devinfo);
  388. return ret;
  389. @@ -1799,6 +1813,8 @@ brcmf_pcie_remove(struct pci_dev *pdev)
  390. if (devinfo->ci)
  391. brcmf_chip_detach(devinfo->ci);
  392. + if (devinfo->settings)
  393. + brcmf_release_module_param(devinfo->settings);
  394. kfree(devinfo);
  395. dev_set_drvdata(&pdev->dev, NULL);
  396. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
  397. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
  398. @@ -2442,15 +2442,17 @@ static void brcmf_sdio_bus_stop(struct d
  399. static inline void brcmf_sdio_clrintr(struct brcmf_sdio *bus)
  400. {
  401. + struct brcmf_sdio_dev *sdiodev;
  402. unsigned long flags;
  403. - if (bus->sdiodev->oob_irq_requested) {
  404. - spin_lock_irqsave(&bus->sdiodev->irq_en_lock, flags);
  405. - if (!bus->sdiodev->irq_en && !atomic_read(&bus->ipend)) {
  406. - enable_irq(bus->sdiodev->pdata->oob_irq_nr);
  407. - bus->sdiodev->irq_en = true;
  408. + sdiodev = bus->sdiodev;
  409. + if (sdiodev->oob_irq_requested) {
  410. + spin_lock_irqsave(&sdiodev->irq_en_lock, flags);
  411. + if (!sdiodev->irq_en && !atomic_read(&bus->ipend)) {
  412. + enable_irq(sdiodev->settings->bus.sdio.oob_irq_nr);
  413. + sdiodev->irq_en = true;
  414. }
  415. - spin_unlock_irqrestore(&bus->sdiodev->irq_en_lock, flags);
  416. + spin_unlock_irqrestore(&sdiodev->irq_en_lock, flags);
  417. }
  418. }
  419. @@ -3394,9 +3396,7 @@ static int brcmf_sdio_bus_preinit(struct
  420. sizeof(u32));
  421. } else {
  422. /* otherwise, set txglomalign */
  423. - value = 4;
  424. - if (sdiodev->pdata)
  425. - value = sdiodev->pdata->sd_sgentry_align;
  426. + value = sdiodev->settings->bus.sdio.sd_sgentry_align;
  427. /* SDIO ADMA requires at least 32 bit alignment */
  428. value = max_t(u32, value, 4);
  429. err = brcmf_iovar_data_set(dev, "bus:txglomalign", &value,
  430. @@ -3811,21 +3811,25 @@ brcmf_sdio_probe_attach(struct brcmf_sdi
  431. bus->ci = NULL;
  432. goto fail;
  433. }
  434. - sdiodev->pdata = brcmf_get_module_param(sdiodev->dev,
  435. + sdiodev->settings = brcmf_get_module_param(sdiodev->dev,
  436. BRCMF_BUSTYPE_SDIO,
  437. bus->ci->chip,
  438. bus->ci->chiprev);
  439. + if (!sdiodev->settings) {
  440. + brcmf_err("Failed to get device parameters\n");
  441. + goto fail;
  442. + }
  443. /* platform specific configuration:
  444. * alignments must be at least 4 bytes for ADMA
  445. */
  446. bus->head_align = ALIGNMENT;
  447. bus->sgentry_align = ALIGNMENT;
  448. - if (sdiodev->pdata) {
  449. - if (sdiodev->pdata->sd_head_align > ALIGNMENT)
  450. - bus->head_align = sdiodev->pdata->sd_head_align;
  451. - if (sdiodev->pdata->sd_sgentry_align > ALIGNMENT)
  452. - bus->sgentry_align = sdiodev->pdata->sd_sgentry_align;
  453. - }
  454. + if (sdiodev->settings->bus.sdio.sd_head_align > ALIGNMENT)
  455. + bus->head_align = sdiodev->settings->bus.sdio.sd_head_align;
  456. + if (sdiodev->settings->bus.sdio.sd_sgentry_align > ALIGNMENT)
  457. + bus->sgentry_align =
  458. + sdiodev->settings->bus.sdio.sd_sgentry_align;
  459. +
  460. /* allocate scatter-gather table. sg support
  461. * will be disabled upon allocation failure.
  462. */
  463. @@ -3837,7 +3841,7 @@ brcmf_sdio_probe_attach(struct brcmf_sdi
  464. */
  465. if ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_KEEP_POWER) &&
  466. ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_WAKE_SDIO_IRQ) ||
  467. - (sdiodev->pdata && sdiodev->pdata->oob_irq_supported)))
  468. + (sdiodev->settings->bus.sdio.oob_irq_supported)))
  469. sdiodev->bus_if->wowl_supported = true;
  470. #endif
  471. @@ -3846,8 +3850,8 @@ brcmf_sdio_probe_attach(struct brcmf_sdi
  472. goto fail;
  473. }
  474. - if ((sdiodev->pdata) && (sdiodev->pdata->drive_strength))
  475. - drivestrength = sdiodev->pdata->drive_strength;
  476. + if (sdiodev->settings->bus.sdio.drive_strength)
  477. + drivestrength = sdiodev->settings->bus.sdio.drive_strength;
  478. else
  479. drivestrength = DEFAULT_SDIO_DRIVE_STRENGTH;
  480. brcmf_sdio_drivestrengthinit(sdiodev, bus->ci, drivestrength);
  481. @@ -4124,7 +4128,7 @@ struct brcmf_sdio *brcmf_sdio_probe(stru
  482. bus->tx_hdrlen = SDPCM_HWHDR_LEN + SDPCM_SWHDR_LEN;
  483. /* Attach to the common layer, reserve hdr space */
  484. - ret = brcmf_attach(bus->sdiodev->dev);
  485. + ret = brcmf_attach(bus->sdiodev->dev, bus->sdiodev->settings);
  486. if (ret != 0) {
  487. brcmf_err("brcmf_attach failed\n");
  488. goto fail;
  489. @@ -4228,6 +4232,8 @@ void brcmf_sdio_remove(struct brcmf_sdio
  490. }
  491. brcmf_chip_detach(bus->ci);
  492. }
  493. + if (bus->sdiodev->settings)
  494. + brcmf_release_module_param(bus->sdiodev->settings);
  495. kfree(bus->rxbuf);
  496. kfree(bus->hdrbuf);
  497. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h
  498. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.h
  499. @@ -184,7 +184,7 @@ struct brcmf_sdio_dev {
  500. struct brcmf_sdio *bus;
  501. struct device *dev;
  502. struct brcmf_bus *bus_if;
  503. - struct brcmfmac_sdio_pd *pdata;
  504. + struct brcmf_mp_device *settings;
  505. bool oob_irq_requested;
  506. bool irq_en; /* irq enable flags */
  507. spinlock_t irq_en_lock;
  508. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
  509. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
  510. @@ -27,6 +27,8 @@
  511. #include "debug.h"
  512. #include "firmware.h"
  513. #include "usb.h"
  514. +#include "core.h"
  515. +#include "common.h"
  516. #define IOCTL_RESP_TIMEOUT msecs_to_jiffies(2000)
  517. @@ -171,6 +173,7 @@ struct brcmf_usbdev_info {
  518. struct urb *bulk_urb; /* used for FW download */
  519. bool wowl_enabled;
  520. + struct brcmf_mp_device *settings;
  521. };
  522. static void brcmf_usb_rx_refill(struct brcmf_usbdev_info *devinfo,
  523. @@ -1027,6 +1030,9 @@ static void brcmf_usb_detach(struct brcm
  524. kfree(devinfo->tx_reqs);
  525. kfree(devinfo->rx_reqs);
  526. +
  527. + if (devinfo->settings)
  528. + brcmf_release_module_param(devinfo->settings);
  529. }
  530. @@ -1136,7 +1142,7 @@ static int brcmf_usb_bus_setup(struct br
  531. int ret;
  532. /* Attach to the common driver interface */
  533. - ret = brcmf_attach(devinfo->dev);
  534. + ret = brcmf_attach(devinfo->dev, devinfo->settings);
  535. if (ret) {
  536. brcmf_err("brcmf_attach failed\n");
  537. return ret;
  538. @@ -1223,6 +1229,14 @@ static int brcmf_usb_probe_cb(struct brc
  539. bus->wowl_supported = true;
  540. #endif
  541. + devinfo->settings = brcmf_get_module_param(bus->dev, BRCMF_BUSTYPE_USB,
  542. + bus_pub->devid,
  543. + bus_pub->chiprev);
  544. + if (!devinfo->settings) {
  545. + ret = -ENOMEM;
  546. + goto fail;
  547. + }
  548. +
  549. if (!brcmf_usb_dlneeded(devinfo)) {
  550. ret = brcmf_usb_bus_setup(devinfo);
  551. if (ret)