diff options
author | Felipe Balbi <balbi@ti.com> | 2011-10-05 02:00:12 -0400 |
---|---|---|
committer | Luciano Coelho <coelho@ti.com> | 2011-10-11 09:00:55 -0400 |
commit | 025aef8fcfbdf680376c4f7aa31b9ac85cebc700 (patch) | |
tree | 0fe8a6bc80b86ddc4be8a3822e10f8c11e443bff /drivers/net/wireless/wl12xx/sdio.c | |
parent | b65019f661733ece3be0680be307d238d4dec68e (diff) |
wl12xx: add a platform device to the sdio module
The platform device will be used to match the platform driver that
will be implemented by the core module.
Signed-off-by: Felipe Balbi <balbi@ti.com>
[forward-ported, cleaned-up and rephrased commit message]
[call platform_device_add() instead of platform_device_register()]
[store alloc'ed device platform directly in glue->core]
[fixed the length of memset(res...)]
Signed-off-by: Luciano Coelho <coelho@ti.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx/sdio.c')
-rw-r--r-- | drivers/net/wireless/wl12xx/sdio.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c index 5a4268012da4..e7ee5d155d34 100644 --- a/drivers/net/wireless/wl12xx/sdio.c +++ b/drivers/net/wireless/wl12xx/sdio.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/irq.h> | 24 | #include <linux/irq.h> |
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/vmalloc.h> | 26 | #include <linux/vmalloc.h> |
27 | #include <linux/platform_device.h> | ||
27 | #include <linux/mmc/sdio_func.h> | 28 | #include <linux/mmc/sdio_func.h> |
28 | #include <linux/mmc/sdio_ids.h> | 29 | #include <linux/mmc/sdio_ids.h> |
29 | #include <linux/mmc/card.h> | 30 | #include <linux/mmc/card.h> |
@@ -47,6 +48,7 @@ | |||
47 | struct wl12xx_sdio_glue { | 48 | struct wl12xx_sdio_glue { |
48 | struct device *dev; | 49 | struct device *dev; |
49 | struct wl1271 *wl; | 50 | struct wl1271 *wl; |
51 | struct platform_device *core; | ||
50 | }; | 52 | }; |
51 | 53 | ||
52 | static const struct sdio_device_id wl1271_devices[] __devinitconst = { | 54 | static const struct sdio_device_id wl1271_devices[] __devinitconst = { |
@@ -234,6 +236,7 @@ static int __devinit wl1271_probe(struct sdio_func *func, | |||
234 | const struct wl12xx_platform_data *wlan_data; | 236 | const struct wl12xx_platform_data *wlan_data; |
235 | struct wl1271 *wl; | 237 | struct wl1271 *wl; |
236 | struct wl12xx_sdio_glue *glue; | 238 | struct wl12xx_sdio_glue *glue; |
239 | struct resource res[1]; | ||
237 | unsigned long irqflags; | 240 | unsigned long irqflags; |
238 | mmc_pm_flag_t mmcflags; | 241 | mmc_pm_flag_t mmcflags; |
239 | int ret = -ENOMEM; | 242 | int ret = -ENOMEM; |
@@ -321,8 +324,47 @@ static int __devinit wl1271_probe(struct sdio_func *func, | |||
321 | /* Tell PM core that we don't need the card to be powered now */ | 324 | /* Tell PM core that we don't need the card to be powered now */ |
322 | pm_runtime_put_noidle(&func->dev); | 325 | pm_runtime_put_noidle(&func->dev); |
323 | 326 | ||
327 | glue->core = platform_device_alloc("wl12xx-sdio", -1); | ||
328 | if (!glue->core) { | ||
329 | wl1271_error("can't allocate platform_device"); | ||
330 | ret = -ENOMEM; | ||
331 | goto out_unreg_hw; | ||
332 | } | ||
333 | |||
334 | glue->core->dev.parent = &func->dev; | ||
335 | |||
336 | memset(res, 0x00, sizeof(res)); | ||
337 | |||
338 | res[0].start = wlan_data->irq; | ||
339 | res[0].flags = IORESOURCE_IRQ; | ||
340 | res[0].name = "irq"; | ||
341 | |||
342 | ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res)); | ||
343 | if (ret) { | ||
344 | wl1271_error("can't add resources"); | ||
345 | goto out_dev_put; | ||
346 | } | ||
347 | |||
348 | ret = platform_device_add_data(glue->core, wlan_data, | ||
349 | sizeof(*wlan_data)); | ||
350 | if (ret) { | ||
351 | wl1271_error("can't add platform data"); | ||
352 | goto out_dev_put; | ||
353 | } | ||
354 | |||
355 | ret = platform_device_add(glue->core); | ||
356 | if (ret) { | ||
357 | wl1271_error("can't add platform device"); | ||
358 | goto out_dev_put; | ||
359 | } | ||
324 | return 0; | 360 | return 0; |
325 | 361 | ||
362 | out_dev_put: | ||
363 | platform_device_put(glue->core); | ||
364 | |||
365 | out_unreg_hw: | ||
366 | wl1271_unregister_hw(wl); | ||
367 | |||
326 | out_irq: | 368 | out_irq: |
327 | free_irq(wl->irq, wl); | 369 | free_irq(wl->irq, wl); |
328 | 370 | ||
@@ -350,6 +392,8 @@ static void __devexit wl1271_remove(struct sdio_func *func) | |||
350 | } | 392 | } |
351 | free_irq(wl->irq, wl); | 393 | free_irq(wl->irq, wl); |
352 | wl1271_free_hw(wl); | 394 | wl1271_free_hw(wl); |
395 | platform_device_del(glue->core); | ||
396 | platform_device_put(glue->core); | ||
353 | kfree(glue); | 397 | kfree(glue); |
354 | } | 398 | } |
355 | 399 | ||