aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelipe Balbi <balbi@ti.com>2011-10-05 02:29:13 -0400
committerLuciano Coelho <coelho@ti.com>2011-10-11 09:01:00 -0400
commit0969d6793f4899a4c5f56443d50f272068b97142 (patch)
tree0d72f046bc36bdda2b4afbc2904f480874588e17
parent025aef8fcfbdf680376c4f7aa31b9ac85cebc700 (diff)
wl12xx: add a platform device to the spi 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>
-rw-r--r--drivers/net/wireless/wl12xx/spi.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c
index 16f0c71f6d4c..2dd659886a04 100644
--- a/drivers/net/wireless/wl12xx/spi.c
+++ b/drivers/net/wireless/wl12xx/spi.c
@@ -27,6 +27,7 @@
27#include <linux/crc7.h> 27#include <linux/crc7.h>
28#include <linux/spi/spi.h> 28#include <linux/spi/spi.h>
29#include <linux/wl12xx.h> 29#include <linux/wl12xx.h>
30#include <linux/platform_device.h>
30#include <linux/slab.h> 31#include <linux/slab.h>
31 32
32#include "wl12xx.h" 33#include "wl12xx.h"
@@ -72,6 +73,7 @@
72struct wl12xx_spi_glue { 73struct wl12xx_spi_glue {
73 struct device *dev; 74 struct device *dev;
74 struct wl1271 *wl; 75 struct wl1271 *wl;
76 struct platform_device *core;
75}; 77};
76 78
77static inline struct wl12xx_spi_glue *wl_to_glue(struct wl1271 *wl) 79static inline struct wl12xx_spi_glue *wl_to_glue(struct wl1271 *wl)
@@ -376,6 +378,7 @@ static int __devinit wl1271_probe(struct spi_device *spi)
376 struct wl12xx_platform_data *pdata; 378 struct wl12xx_platform_data *pdata;
377 struct ieee80211_hw *hw; 379 struct ieee80211_hw *hw;
378 struct wl1271 *wl; 380 struct wl1271 *wl;
381 struct resource res[1];
379 unsigned long irqflags; 382 unsigned long irqflags;
380 int ret = -ENOMEM; 383 int ret = -ENOMEM;
381 384
@@ -458,8 +461,47 @@ static int __devinit wl1271_probe(struct spi_device *spi)
458 if (ret) 461 if (ret)
459 goto out_irq; 462 goto out_irq;
460 463
464 glue->core = platform_device_alloc("wl12xx-spi", -1);
465 if (!glue->core) {
466 wl1271_error("can't allocate platform_device");
467 ret = -ENOMEM;
468 goto out_unreg_hw;
469 }
470
471 glue->core->dev.parent = &spi->dev;
472
473 memset(res, 0x00, sizeof(res));
474
475 res[0].start = spi->irq;
476 res[0].flags = IORESOURCE_IRQ;
477 res[0].name = "irq";
478
479 ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res));
480 if (ret) {
481 wl1271_error("can't add resources");
482 goto out_dev_put;
483 }
484
485 ret = platform_device_add_data(glue->core, pdata, sizeof(*pdata));
486 if (ret) {
487 wl1271_error("can't add platform data");
488 goto out_dev_put;
489 }
490
491 ret = platform_device_add(glue->core);
492 if (ret) {
493 wl1271_error("can't register platform device");
494 goto out_dev_put;
495 }
496
461 return 0; 497 return 0;
462 498
499out_dev_put:
500 platform_device_put(glue->core);
501
502out_unreg_hw:
503 wl1271_unregister_hw(wl);
504
463out_irq: 505out_irq:
464 free_irq(wl->irq, wl); 506 free_irq(wl->irq, wl);
465 507
@@ -480,6 +522,8 @@ static int __devexit wl1271_remove(struct spi_device *spi)
480 wl1271_unregister_hw(wl); 522 wl1271_unregister_hw(wl);
481 free_irq(wl->irq, wl); 523 free_irq(wl->irq, wl);
482 wl1271_free_hw(wl); 524 wl1271_free_hw(wl);
525 platform_device_del(glue->core);
526 platform_device_put(glue->core);
483 kfree(glue); 527 kfree(glue);
484 528
485 return 0; 529 return 0;