From: Luciano Coelho <coelho@ti.com>
To: coelho@ti.com
Cc: linux-wireless@vger.kernel.org
Subject: [PATCH 4/8] wl12xx: add a platform device to the spi module
Date: Thu, 6 Oct 2011 22:10:55 +0300 [thread overview]
Message-ID: <1317928259-26437-5-git-send-email-coelho@ti.com> (raw)
In-Reply-To: <1317928259-26437-1-git-send-email-coelho@ti.com>
From: Felipe Balbi <balbi@ti.com>
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>
---
drivers/net/wireless/wl12xx/spi.c | 44 +++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c
index 16f0c71..e075d69 100644
--- a/drivers/net/wireless/wl12xx/spi.c
+++ b/drivers/net/wireless/wl12xx/spi.c
@@ -27,6 +27,7 @@
#include <linux/crc7.h>
#include <linux/spi/spi.h>
#include <linux/wl12xx.h>
+#include <linux/platform_device.h>
#include <linux/slab.h>
#include "wl12xx.h"
@@ -72,6 +73,7 @@
struct wl12xx_spi_glue {
struct device *dev;
struct wl1271 *wl;
+ struct platform_device *core;
};
static inline struct wl12xx_spi_glue *wl_to_glue(struct wl1271 *wl)
@@ -376,6 +378,7 @@ static int __devinit wl1271_probe(struct spi_device *spi)
struct wl12xx_platform_data *pdata;
struct ieee80211_hw *hw;
struct wl1271 *wl;
+ struct resource res[1];
unsigned long irqflags;
int ret = -ENOMEM;
@@ -458,8 +461,47 @@ static int __devinit wl1271_probe(struct spi_device *spi)
if (ret)
goto out_irq;
+ glue->core = platform_device_alloc("wl12xx-spi", -1);
+ if (!glue->core) {
+ dev_err(&spi->dev, "can't allocate platform_device\n");
+ ret = -ENOMEM;
+ goto out_unreg_hw;
+ }
+
+ glue->core->dev.parent = &spi->dev;
+
+ memset(res, 0x00, sizeof(res));
+
+ res[0].start = spi->irq;
+ res[0].flags = IORESOURCE_IRQ;
+ res[0].name = "irq";
+
+ ret = platform_device_add_resources(glue->core, res, ARRAY_SIZE(res));
+ if (ret) {
+ wl1271_error("can't add resources");
+ goto out_dev_put;
+ }
+
+ ret = platform_device_add_data(glue->core, pdata, sizeof(*pdata));
+ if (ret) {
+ wl1271_error("can't add platform data");
+ goto out_dev_put;
+ }
+
+ ret = platform_device_add(glue->core);
+ if (ret) {
+ wl1271_error("can't register platform device");
+ goto out_dev_put;
+ }
+
return 0;
+out_dev_put:
+ platform_device_put(glue->core);
+
+out_unreg_hw:
+ wl1271_unregister_hw(wl);
+
out_irq:
free_irq(wl->irq, wl);
@@ -480,6 +522,8 @@ static int __devexit wl1271_remove(struct spi_device *spi)
wl1271_unregister_hw(wl);
free_irq(wl->irq, wl);
wl1271_free_hw(wl);
+ platform_device_del(glue->core);
+ platform_device_put(glue->core);
kfree(glue);
return 0;
--
1.7.1
next prev parent reply other threads:[~2011-10-06 19:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-06 19:10 [PATCH 0/8] wl12xx: forward ported Balbi's bus driver refactor Luciano Coelho
2011-10-06 19:10 ` [PATCH 1/8] wl12xx: add an sdio glue struct to keep wl and device side-by-side Luciano Coelho
2011-10-06 19:10 ` [PATCH 2/8] wl12xx: add an spi " Luciano Coelho
2011-10-06 19:10 ` [PATCH 3/8] wl12xx: add a platform device to the sdio module Luciano Coelho
2011-10-06 19:10 ` Luciano Coelho [this message]
2011-10-06 19:10 ` [PATCH 5/8] wl12xx: add platform driver to the core module Luciano Coelho
2011-10-06 19:10 ` [PATCH 6/8] wl12xx: move common init code from bus modules to main Luciano Coelho
2011-10-06 19:10 ` [PATCH 7/8] wl12xx: mark some symbols static Luciano Coelho
2011-10-06 19:10 ` [PATCH 8/8] wl12xx: drop unneeded plat_dev Luciano Coelho
2011-10-11 13:05 ` [PATCH 0/8] wl12xx: forward ported Balbi's bus driver refactor Luciano Coelho
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1317928259-26437-5-git-send-email-coelho@ti.com \
--to=coelho@ti.com \
--cc=linux-wireless@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox