linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Felipe Balbi <balbi@ti.com>
To: Luciano Coelho <coelho@ti.com>
Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, Felipe Balbi <balbi@ti.com>
Subject: [RFC/PATCH 08/13] net: wl12xx: spi: add a platform_device
Date: Sat, 14 May 2011 00:26:25 +0300	[thread overview]
Message-ID: <1305321990-22041-9-git-send-email-balbi@ti.com> (raw)
In-Reply-To: <1305321990-22041-1-git-send-email-balbi@ti.com>

that device will match with a driver to
be added to the core driver.

that driver will be added once the other
glue layer (sdio.c) is converted to this
new scheme.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/net/wireless/wl12xx/spi.c |   50 ++++++++++++++++++++++++++++++++++--
 1 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c
index 5dbd5b3..6644996 100644
--- a/drivers/net/wireless/wl12xx/spi.c
+++ b/drivers/net/wireless/wl12xx/spi.c
@@ -26,6 +26,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"
@@ -69,8 +70,9 @@
 #define WSPI_MAX_NUM_OF_CHUNKS (WL1271_AGGR_BUFFER_SIZE / WSPI_MAX_CHUNK_SIZE)
 
 struct wl12xx_spi_glue {
-	struct device	*dev;
-	struct wl1271	*wl;
+	struct device		*dev;
+	struct wl1271		*wl;
+	struct platform_device	*core;
 };
 
 static inline struct wl12xx_spi_glue *wl_to_glue(struct wl1271 *wl)
@@ -377,6 +379,8 @@ static struct wl1271_if_operations spi_ops = {
 static int __devinit wl1271_probe(struct spi_device *spi)
 {
 	struct wl12xx_platform_data	*pdata;
+	struct platform_device		*core;
+	struct resource			res[1];
 
 	struct wl12xx_spi_glue		*glue;
 	struct ieee80211_hw		*hw;
@@ -456,8 +460,47 @@ static int __devinit wl1271_probe(struct spi_device *spi)
 	if (ret)
 		goto err3;
 
+	core = platform_device_alloc("wl12xx-spi", -1);
+	if (!core) {
+		dev_err(&spi->dev, "can't allocate platform_device\n");
+		ret = -ENOMEM;
+		goto err4;
+	}
+
+	core->dev.parent = &spi->dev;
+
+	memset(res, 0x00, sizeof(res) * ARRAY_SIZE(res));
+
+	res[0].start	= spi->irq;
+	res[0].flags	= IORESOURCE_IRQ;
+	res[0].name	= "irq";
+
+	ret = platform_device_add_resources(core, res, ARRAY_SIZE(res));
+	if (ret) {
+		dev_err(&spi->dev, "can't add resources\n");
+		goto err5;
+	}
+
+	ret = platform_device_add_data(core, pdata, sizeof(*pdata));
+	if (ret) {
+		dev_err(&spi->dev, "can't add platform data\n");
+		goto err5;
+	}
+
+	ret = platform_device_register(core);
+	if (ret) {
+		dev_err(&spi->dev, "can't register platform device\n");
+		goto err5;
+	}
+
 	return 0;
 
+err5:
+	platform_device_put(core);
+
+err4:
+	wl1271_unregister_hw(wl);
+
 err3:
 	free_irq(wl->irq, wl);
 
@@ -479,12 +522,13 @@ 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;
 }
 
-
 static struct spi_driver wl1271_spi_driver = {
 	.driver = {
 		.name		= "wl1271_spi",
-- 
1.7.4.1.343.ga91df


  parent reply	other threads:[~2011-05-13 21:27 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-13 21:26 [RFC/PATCH 00/13] wl12xx re-factor Felipe Balbi
2011-05-13 21:26 ` [RFC/PATCH 01/13] net: wl12xx: sdio: id_tables should be __devinitconst Felipe Balbi
2011-05-20 12:02   ` Luciano Coelho
2011-05-20 16:02   ` Ohad Ben-Cohen
2011-05-20 16:14     ` Michał Mirosław
2011-05-13 21:26 ` [RFC/PATCH 02/13] net: wl12xx: sdio: add a context structure Felipe Balbi
2011-05-13 21:26 ` [RFC/PATCH 03/13] net: wl12xx: remove some unnecessary prints Felipe Balbi
2011-05-20 12:03   ` Luciano Coelho
2011-05-22 12:34   ` Eliad Peller
2011-05-22 12:37     ` Eliad Peller
2011-05-22 17:30       ` Luciano Coelho
2011-05-22 21:57         ` Eliad Peller
2011-05-23  5:32           ` Luciano Coelho
2011-05-23  6:07             ` Felipe Balbi
2011-05-13 21:26 ` [RFC/PATCH 04/13] net: wl12xx: care for optional operations Felipe Balbi
2011-05-20 12:03   ` Luciano Coelho
2011-05-13 21:26 ` [RFC/PATCH 05/13] net: wl12xx: remove the nops Felipe Balbi
2011-05-20 12:04   ` Luciano Coelho
2011-05-13 21:26 ` [RFC/PATCH 06/13] net: wl12xx: remove unnecessary prints Felipe Balbi
2011-05-20 12:04   ` Luciano Coelho
2011-05-13 21:26 ` [RFC/PATCH 07/13] net: wl12xx: spi: add a context structure Felipe Balbi
2011-05-13 21:26 ` Felipe Balbi [this message]
2011-05-13 21:26 ` [RFC/PATCH 09/13] net: wl12xx: sdio: add a platform_device Felipe Balbi
2011-05-13 21:26 ` [RFC/PATCH 10/13] net: wl12xx: main: add platform device Felipe Balbi
2011-05-13 21:26 ` [RFC/PATCH 11/13] net: wireless: wl12xx: re-factor all drivers Felipe Balbi
2011-05-13 21:26 ` [RFC/PATCH 12/13] net: wireless: wl12xx: mark some symbols static Felipe Balbi
2011-05-13 21:26 ` [RFC/PATCH 13/13] net: wl12xx: main: drop unneded plat_dev Felipe Balbi
2011-05-19 12:49 ` [RFC/PATCH 00/13] wl12xx re-factor Luciano Coelho
2011-05-19 14:06   ` Felipe Balbi

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=1305321990-22041-9-git-send-email-balbi@ti.com \
    --to=balbi@ti.com \
    --cc=coelho@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@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;
as well as URLs for NNTP newsgroup(s).