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