Skip to content

Commit 8ea56be

Browse files
Hante MeulemanKalle Valo
authored andcommitted
brcmfmac: move platform data retrieval code to common
In preparation of module parameters for all devices the module platform data retrieval is moved from sdio to common. It is still only used for sdio devices. Reviewed-by: Arend Van Spriel <[email protected]> Reviewed-by: Franky (Zhenhui) Lin <[email protected]> Reviewed-by: Pieter-Paul Giesberts <[email protected]> Signed-off-by: Hante Meuleman <[email protected]> Signed-off-by: Arend van Spriel <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent 5c22fb8 commit 8ea56be

File tree

5 files changed

+84
-85
lines changed

5 files changed

+84
-85
lines changed

drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcmsdh.c

Lines changed: 17 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
#include <linux/mmc/sdio_func.h>
2828
#include <linux/mmc/card.h>
2929
#include <linux/mmc/host.h>
30-
#include <linux/platform_device.h>
31-
#include <linux/platform_data/brcmfmac-sdio.h>
3230
#include <linux/pm_runtime.h>
3331
#include <linux/suspend.h>
3432
#include <linux/errno.h>
@@ -46,7 +44,6 @@
4644
#include "bus.h"
4745
#include "debug.h"
4846
#include "sdio.h"
49-
#include "of.h"
5047
#include "core.h"
5148
#include "common.h"
5249

@@ -106,18 +103,18 @@ static void brcmf_sdiod_dummy_irqhandler(struct sdio_func *func)
106103

107104
int brcmf_sdiod_intr_register(struct brcmf_sdio_dev *sdiodev)
108105
{
106+
struct brcmfmac_sdio_platform_data *pdata;
109107
int ret = 0;
110108
u8 data;
111109
u32 addr, gpiocontrol;
112110
unsigned long flags;
113111

114-
if ((sdiodev->pdata) && (sdiodev->pdata->oob_irq_supported)) {
112+
pdata = sdiodev->pdata;
113+
if ((pdata) && (pdata->oob_irq_supported)) {
115114
brcmf_dbg(SDIO, "Enter, register OOB IRQ %d\n",
116-
sdiodev->pdata->oob_irq_nr);
117-
ret = request_irq(sdiodev->pdata->oob_irq_nr,
118-
brcmf_sdiod_oob_irqhandler,
119-
sdiodev->pdata->oob_irq_flags,
120-
"brcmf_oob_intr",
115+
pdata->oob_irq_nr);
116+
ret = request_irq(pdata->oob_irq_nr, brcmf_sdiod_oob_irqhandler,
117+
pdata->oob_irq_flags, "brcmf_oob_intr",
121118
&sdiodev->func[1]->dev);
122119
if (ret != 0) {
123120
brcmf_err("request_irq failed %d\n", ret);
@@ -129,7 +126,7 @@ int brcmf_sdiod_intr_register(struct brcmf_sdio_dev *sdiodev)
129126
sdiodev->irq_en = true;
130127
spin_unlock_irqrestore(&sdiodev->irq_en_lock, flags);
131128

132-
ret = enable_irq_wake(sdiodev->pdata->oob_irq_nr);
129+
ret = enable_irq_wake(pdata->oob_irq_nr);
133130
if (ret != 0) {
134131
brcmf_err("enable_irq_wake failed %d\n", ret);
135132
return ret;
@@ -158,7 +155,7 @@ int brcmf_sdiod_intr_register(struct brcmf_sdio_dev *sdiodev)
158155

159156
/* redirect, configure and enable io for interrupt signal */
160157
data = SDIO_SEPINT_MASK | SDIO_SEPINT_OE;
161-
if (sdiodev->pdata->oob_irq_flags & IRQF_TRIGGER_HIGH)
158+
if (pdata->oob_irq_flags & IRQF_TRIGGER_HIGH)
162159
data |= SDIO_SEPINT_ACT_HI;
163160
brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, data, &ret);
164161

@@ -176,9 +173,12 @@ int brcmf_sdiod_intr_register(struct brcmf_sdio_dev *sdiodev)
176173

177174
int brcmf_sdiod_intr_unregister(struct brcmf_sdio_dev *sdiodev)
178175
{
176+
struct brcmfmac_sdio_platform_data *pdata;
177+
179178
brcmf_dbg(SDIO, "Entering\n");
180179

181-
if ((sdiodev->pdata) && (sdiodev->pdata->oob_irq_supported)) {
180+
pdata = sdiodev->pdata;
181+
if ((pdata) && (pdata->oob_irq_supported)) {
182182
sdio_claim_host(sdiodev->func[1]);
183183
brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_BRCM_SEPINT, 0, NULL);
184184
brcmf_sdiod_regwb(sdiodev, SDIO_CCCR_IENx, 0, NULL);
@@ -187,11 +187,10 @@ int brcmf_sdiod_intr_unregister(struct brcmf_sdio_dev *sdiodev)
187187
if (sdiodev->oob_irq_requested) {
188188
sdiodev->oob_irq_requested = false;
189189
if (sdiodev->irq_wake) {
190-
disable_irq_wake(sdiodev->pdata->oob_irq_nr);
190+
disable_irq_wake(pdata->oob_irq_nr);
191191
sdiodev->irq_wake = false;
192192
}
193-
free_irq(sdiodev->pdata->oob_irq_nr,
194-
&sdiodev->func[1]->dev);
193+
free_irq(pdata->oob_irq_nr, &sdiodev->func[1]->dev);
195194
sdiodev->irq_en = false;
196195
}
197196
} else {
@@ -1103,8 +1102,6 @@ static const struct sdio_device_id brcmf_sdmmc_ids[] = {
11031102
};
11041103
MODULE_DEVICE_TABLE(sdio, brcmf_sdmmc_ids);
11051104

1106-
static struct brcmfmac_sdio_platform_data *brcmfmac_sdio_pdata;
1107-
11081105

11091106
static void brcmf_sdiod_acpi_set_power_manageable(struct device *dev,
11101107
int val)
@@ -1167,10 +1164,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
11671164
dev_set_drvdata(&func->dev, bus_if);
11681165
dev_set_drvdata(&sdiodev->func[1]->dev, bus_if);
11691166
sdiodev->dev = &sdiodev->func[1]->dev;
1170-
sdiodev->pdata = brcmfmac_sdio_pdata;
1171-
1172-
if (!sdiodev->pdata)
1173-
brcmf_of_probe(sdiodev);
1167+
sdiodev->pdata = brcmf_get_module_param(sdiodev->dev);
11741168

11751169
#ifdef CONFIG_PM_SLEEP
11761170
/* wowl can be supported when KEEP_POWER is true and (WAKE_SDIO_IRQ
@@ -1296,7 +1290,7 @@ static const struct dev_pm_ops brcmf_sdio_pm_ops = {
12961290
static struct sdio_driver brcmf_sdmmc_driver = {
12971291
.probe = brcmf_ops_sdio_probe,
12981292
.remove = brcmf_ops_sdio_remove,
1299-
.name = BRCMFMAC_SDIO_PDATA_NAME,
1293+
.name = KBUILD_MODNAME,
13001294
.id_table = brcmf_sdmmc_ids,
13011295
.drv = {
13021296
.owner = THIS_MODULE,
@@ -1306,37 +1300,6 @@ static struct sdio_driver brcmf_sdmmc_driver = {
13061300
},
13071301
};
13081302

1309-
static int __init brcmf_sdio_pd_probe(struct platform_device *pdev)
1310-
{
1311-
brcmf_dbg(SDIO, "Enter\n");
1312-
1313-
brcmfmac_sdio_pdata = dev_get_platdata(&pdev->dev);
1314-
1315-
if (brcmfmac_sdio_pdata->power_on)
1316-
brcmfmac_sdio_pdata->power_on();
1317-
1318-
return 0;
1319-
}
1320-
1321-
static int brcmf_sdio_pd_remove(struct platform_device *pdev)
1322-
{
1323-
brcmf_dbg(SDIO, "Enter\n");
1324-
1325-
if (brcmfmac_sdio_pdata->power_off)
1326-
brcmfmac_sdio_pdata->power_off();
1327-
1328-
sdio_unregister_driver(&brcmf_sdmmc_driver);
1329-
1330-
return 0;
1331-
}
1332-
1333-
static struct platform_driver brcmf_sdio_pd = {
1334-
.remove = brcmf_sdio_pd_remove,
1335-
.driver = {
1336-
.name = BRCMFMAC_SDIO_PDATA_NAME,
1337-
}
1338-
};
1339-
13401303
void brcmf_sdio_register(void)
13411304
{
13421305
int ret;
@@ -1350,19 +1313,6 @@ void brcmf_sdio_exit(void)
13501313
{
13511314
brcmf_dbg(SDIO, "Enter\n");
13521315

1353-
if (brcmfmac_sdio_pdata)
1354-
platform_driver_unregister(&brcmf_sdio_pd);
1355-
else
1356-
sdio_unregister_driver(&brcmf_sdmmc_driver);
1316+
sdio_unregister_driver(&brcmf_sdmmc_driver);
13571317
}
13581318

1359-
void __init brcmf_sdio_init(void)
1360-
{
1361-
int ret;
1362-
1363-
brcmf_dbg(SDIO, "Enter\n");
1364-
1365-
ret = platform_driver_probe(&brcmf_sdio_pd, brcmf_sdio_pd_probe);
1366-
if (ret == -ENODEV)
1367-
brcmf_dbg(SDIO, "No platform data available.\n");
1368-
}

drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "fwil_types.h"
2828
#include "tracepoint.h"
2929
#include "common.h"
30+
#include "of.h"
3031

3132
MODULE_AUTHOR("Broadcom Corporation");
3233
MODULE_DESCRIPTION("Broadcom 802.11 wireless LAN fullmac driver.");
@@ -79,6 +80,7 @@ module_param_named(ignore_probe_fail, brcmf_ignore_probe_fail, int, 0);
7980
MODULE_PARM_DESC(ignore_probe_fail, "always succeed probe for debugging");
8081
#endif
8182

83+
static struct brcmfmac_sdio_platform_data *brcmfmac_pdata;
8284
struct brcmf_mp_global_t brcmf_mp_global;
8385

8486
int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
@@ -231,6 +233,13 @@ static void brcmf_mp_attach(void)
231233
BRCMF_FW_ALTPATH_LEN);
232234
}
233235

236+
struct brcmfmac_sdio_platform_data *brcmf_get_module_param(struct device *dev)
237+
{
238+
if (!brcmfmac_pdata)
239+
brcmf_of_probe(dev, &brcmfmac_pdata);
240+
return brcmfmac_pdata;
241+
}
242+
234243
int brcmf_mp_device_attach(struct brcmf_pub *drvr)
235244
{
236245
drvr->settings = kzalloc(sizeof(*drvr->settings), GFP_ATOMIC);
@@ -253,30 +262,66 @@ void brcmf_mp_device_detach(struct brcmf_pub *drvr)
253262
kfree(drvr->settings);
254263
}
255264

265+
static int __init brcmf_common_pd_probe(struct platform_device *pdev)
266+
{
267+
brcmf_dbg(INFO, "Enter\n");
268+
269+
brcmfmac_pdata = dev_get_platdata(&pdev->dev);
270+
271+
if (brcmfmac_pdata->power_on)
272+
brcmfmac_pdata->power_on();
273+
274+
return 0;
275+
}
276+
277+
static int brcmf_common_pd_remove(struct platform_device *pdev)
278+
{
279+
brcmf_dbg(INFO, "Enter\n");
280+
281+
if (brcmfmac_pdata->power_off)
282+
brcmfmac_pdata->power_off();
283+
284+
return 0;
285+
}
286+
287+
static struct platform_driver brcmf_pd = {
288+
.remove = brcmf_common_pd_remove,
289+
.driver = {
290+
.name = BRCMFMAC_SDIO_PDATA_NAME,
291+
}
292+
};
293+
256294
static int __init brcmfmac_module_init(void)
257295
{
258296
int err;
259297

260298
/* Initialize debug system first */
261299
brcmf_debugfs_init();
262300

263-
#ifdef CONFIG_BRCMFMAC_SDIO
264-
brcmf_sdio_init();
265-
#endif
301+
/* Get the platform data (if available) for our devices */
302+
err = platform_driver_probe(&brcmf_pd, brcmf_common_pd_probe);
303+
if (err == -ENODEV)
304+
brcmf_dbg(INFO, "No platform data available.\n");
305+
266306
/* Initialize global module paramaters */
267307
brcmf_mp_attach();
268308

269309
/* Continue the initialization by registering the different busses */
270310
err = brcmf_core_init();
271-
if (err)
311+
if (err) {
272312
brcmf_debugfs_exit();
313+
if (brcmfmac_pdata)
314+
platform_driver_unregister(&brcmf_pd);
315+
}
273316

274317
return err;
275318
}
276319

277320
static void __exit brcmfmac_module_exit(void)
278321
{
279322
brcmf_core_exit();
323+
if (brcmfmac_pdata)
324+
platform_driver_unregister(&brcmf_pd);
280325
brcmf_debugfs_exit();
281326
}
282327

drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#ifndef BRCMFMAC_COMMON_H
1616
#define BRCMFMAC_COMMON_H
1717

18+
#include <linux/platform_device.h>
19+
#include <linux/platform_data/brcmfmac-sdio.h>
1820
#include "fwil_types.h"
1921

2022
extern const u8 ALLFFMAC[ETH_ALEN];
@@ -89,6 +91,7 @@ struct brcmf_mp_device {
8991
struct cc_translate *country_codes;
9092
};
9193

94+
struct brcmfmac_sdio_platform_data *brcmf_get_module_param(struct device *dev);
9295
int brcmf_mp_device_attach(struct brcmf_pub *drvr);
9396
void brcmf_mp_device_detach(struct brcmf_pub *drvr);
9497
#ifdef DEBUG

drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,16 @@
1616
#include <linux/init.h>
1717
#include <linux/of.h>
1818
#include <linux/of_irq.h>
19-
#include <linux/mmc/card.h>
20-
#include <linux/platform_data/brcmfmac-sdio.h>
21-
#include <linux/mmc/sdio_func.h>
2219

2320
#include <defs.h>
2421
#include "debug.h"
25-
#include "sdio.h"
22+
#include "core.h"
23+
#include "common.h"
24+
#include "of.h"
2625

27-
void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev)
26+
void
27+
brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_platform_data **sdio)
2828
{
29-
struct device *dev = sdiodev->dev;
3029
struct device_node *np = dev->of_node;
3130
int irq;
3231
u32 irqf;
@@ -35,12 +34,12 @@ void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev)
3534
if (!np || !of_device_is_compatible(np, "brcm,bcm4329-fmac"))
3635
return;
3736

38-
sdiodev->pdata = devm_kzalloc(dev, sizeof(*sdiodev->pdata), GFP_KERNEL);
39-
if (!sdiodev->pdata)
37+
*sdio = devm_kzalloc(dev, sizeof(*sdio), GFP_KERNEL);
38+
if (!(*sdio))
4039
return;
4140

4241
if (of_property_read_u32(np, "brcm,drive-strength", &val) == 0)
43-
sdiodev->pdata->drive_strength = val;
42+
(*sdio)->drive_strength = val;
4443

4544
/* make sure there are interrupts defined in the node */
4645
if (!of_find_property(np, "interrupts", NULL))
@@ -53,7 +52,7 @@ void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev)
5352
}
5453
irqf = irqd_get_trigger_type(irq_get_irq_data(irq));
5554

56-
sdiodev->pdata->oob_irq_supported = true;
57-
sdiodev->pdata->oob_irq_nr = irq;
58-
sdiodev->pdata->oob_irq_flags = irqf;
55+
(*sdio)->oob_irq_supported = true;
56+
(*sdio)->oob_irq_nr = irq;
57+
(*sdio)->oob_irq_flags = irqf;
5958
}

drivers/net/wireless/broadcom/brcm80211/brcmfmac/of.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1515
*/
1616
#ifdef CONFIG_OF
17-
void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev);
17+
void
18+
brcmf_of_probe(struct device *dev, struct brcmfmac_sdio_platform_data **sdio);
1819
#else
19-
static void brcmf_of_probe(struct brcmf_sdio_dev *sdiodev)
20+
static void brcmf_of_probe(struct device *dev,
21+
struct brcmfmac_sdio_platform_data **sdio)
2022
{
2123
}
2224
#endif /* CONFIG_OF */

0 commit comments

Comments
 (0)