提交 a1dd8187 编写于 作者: J Juuso Oikarinen 提交者: John W. Linville

wl1271: Move platform device registration from _spi to _main

In order to get the platform device for both SPI and SDIO, move the platform
device registration to wl1271_main.c from wl1271_spi.c.
Signed-off-by: NJuuso Oikarinen <juuso.oikarinen@nokia.com>
Reviewed-by: NTeemu Paasikivi <ext-teemu.3.paasikivi@nokia.com>
Signed-off-by: NLuciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 1b00f546
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <linux/inetdevice.h> #include <linux/inetdevice.h>
#include <linux/platform_device.h>
#include "wl1271.h" #include "wl1271.h"
#include "wl12xx_80211.h" #include "wl12xx_80211.h"
...@@ -280,6 +281,21 @@ static struct conf_drv_settings default_conf = { ...@@ -280,6 +281,21 @@ static struct conf_drv_settings default_conf = {
} }
}; };
static void wl1271_device_release(struct device *dev)
{
}
static struct platform_device wl1271_device = {
.name = "wl1271",
.id = -1,
/* device model insists to have a release function */
.dev = {
.release = wl1271_device_release,
},
};
static LIST_HEAD(wl_list); static LIST_HEAD(wl_list);
static void wl1271_conf_init(struct wl1271 *wl) static void wl1271_conf_init(struct wl1271 *wl)
...@@ -2025,12 +2041,13 @@ struct ieee80211_hw *wl1271_alloc_hw(void) ...@@ -2025,12 +2041,13 @@ struct ieee80211_hw *wl1271_alloc_hw(void)
{ {
struct ieee80211_hw *hw; struct ieee80211_hw *hw;
struct wl1271 *wl; struct wl1271 *wl;
int i; int i, ret;
hw = ieee80211_alloc_hw(sizeof(*wl), &wl1271_ops); hw = ieee80211_alloc_hw(sizeof(*wl), &wl1271_ops);
if (!hw) { if (!hw) {
wl1271_error("could not alloc ieee80211_hw"); wl1271_error("could not alloc ieee80211_hw");
return ERR_PTR(-ENOMEM); ret = -ENOMEM;
goto err;
} }
wl = hw->priv; wl = hw->priv;
...@@ -2070,12 +2087,28 @@ struct ieee80211_hw *wl1271_alloc_hw(void) ...@@ -2070,12 +2087,28 @@ struct ieee80211_hw *wl1271_alloc_hw(void)
wl1271_debugfs_init(wl); wl1271_debugfs_init(wl);
/* Register platform device */
ret = platform_device_register(&wl1271_device);
if (ret) {
wl1271_error("couldn't register platform device");
goto err_hw;
}
dev_set_drvdata(&wl1271_device.dev, wl);
return hw; return hw;
err_hw:
ieee80211_unregister_hw(wl->hw);
err:
return ERR_PTR(ret);
} }
EXPORT_SYMBOL_GPL(wl1271_alloc_hw); EXPORT_SYMBOL_GPL(wl1271_alloc_hw);
int wl1271_free_hw(struct wl1271 *wl) int wl1271_free_hw(struct wl1271 *wl)
{ {
platform_device_unregister(&wl1271_device);
ieee80211_unregister_hw(wl->hw); ieee80211_unregister_hw(wl->hw);
wl1271_debugfs_exit(wl); wl1271_debugfs_exit(wl);
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/crc7.h> #include <linux/crc7.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/spi/wl12xx.h> #include <linux/spi/wl12xx.h>
...@@ -332,21 +331,6 @@ static irqreturn_t wl1271_irq(int irq, void *cookie) ...@@ -332,21 +331,6 @@ static irqreturn_t wl1271_irq(int irq, void *cookie)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static void wl1271_device_release(struct device *dev)
{
}
static struct platform_device wl1271_device = {
.name = "wl1271",
.id = -1,
/* device model insists to have a release function */
.dev = {
.release = wl1271_device_release,
},
};
static void wl1271_spi_set_power(struct wl1271 *wl, bool enable) static void wl1271_spi_set_power(struct wl1271 *wl, bool enable)
{ {
if (wl->set_power) if (wl->set_power)
...@@ -422,28 +406,18 @@ static int __devinit wl1271_probe(struct spi_device *spi) ...@@ -422,28 +406,18 @@ static int __devinit wl1271_probe(struct spi_device *spi)
disable_irq(wl->irq); disable_irq(wl->irq);
ret = platform_device_register(&wl1271_device);
if (ret) {
wl1271_error("couldn't register platform device");
goto out_irq;
}
dev_set_drvdata(&wl1271_device.dev, wl);
ret = wl1271_init_ieee80211(wl); ret = wl1271_init_ieee80211(wl);
if (ret) if (ret)
goto out_platform; goto out_irq;
ret = wl1271_register_hw(wl); ret = wl1271_register_hw(wl);
if (ret) if (ret)
goto out_platform; goto out_irq;
wl1271_notice("initialized"); wl1271_notice("initialized");
return 0; return 0;
out_platform:
platform_device_unregister(&wl1271_device);
out_irq: out_irq:
free_irq(wl->irq, wl); free_irq(wl->irq, wl);
...@@ -457,7 +431,6 @@ static int __devexit wl1271_remove(struct spi_device *spi) ...@@ -457,7 +431,6 @@ static int __devexit wl1271_remove(struct spi_device *spi)
{ {
struct wl1271 *wl = dev_get_drvdata(&spi->dev); struct wl1271 *wl = dev_get_drvdata(&spi->dev);
platform_device_unregister(&wl1271_device);
free_irq(wl->irq, wl); free_irq(wl->irq, wl);
wl1271_free_hw(wl); wl1271_free_hw(wl);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册