* [PATCH 0/8] wl12xx: forward ported Balbi's bus driver refactor
@ 2011-10-06 19:10 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
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Luciano Coelho @ 2011-10-06 19:10 UTC (permalink / raw)
To: coelho; +Cc: linux-wireless
Hi,
Felipe sent this series of patches a long time ago with very good
suggestion on how to avoid the duplicate code we have in the sdio and
spi drivers.
With this, we create a platform device that is handled by a platform
driver. The bus-specific module, creates a platform device and the
core module implements the driver that supports both platform devices
(namely "wl12xx-sdio" and "wl12xx-spi").
I didn't apply this earlier because I had concerns about the change in
the platform data, but now I'm convinced it's not a real problem. It
may affect compat-wireless, but it's easy to solve.
I have now forward-ported the patches, fixed some bugs, removed some
style changes and moved some other things around. For the changes I
made, see the commit message of each patch. Some changes are not in
the commit message, but are explained in the patch emails, after the
Signed-off-by area.
I'm keeping Felipe as the author, since most of the work is his. I
have just tested and fixed it up.
Cheers,
Luca.
Felipe Balbi (8):
wl12xx: add an sdio glue struct to keep wl and device side-by-side
wl12xx: add an spi glue struct to keep wl and device side-by-side
wl12xx: add a platform device to the sdio module
wl12xx: add a platform device to the spi module
wl12xx: add platform driver to the core module
wl12xx: move common init code from bus modules to main
wl12xx: mark some symbols static
wl12xx: drop unneeded plat_dev
drivers/net/wireless/wl12xx/io.c | 11 +-
drivers/net/wireless/wl12xx/io.h | 23 +--
drivers/net/wireless/wl12xx/main.c | 271 +++++++++++++-------
drivers/net/wireless/wl12xx/sdio.c | 217 +++++++----------
drivers/net/wireless/wl12xx/spi.c | 194 ++++++---------
drivers/net/wireless/wl12xx/wl12xx.h | 18 +-
drivers/net/wireless/wl12xx/wl12xx_platform_data.c | 4 +-
include/linux/wl12xx.h | 5 +-
8 files changed, 370 insertions(+), 373 deletions(-)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/8] wl12xx: add an sdio glue struct to keep wl and device side-by-side
2011-10-06 19:10 [PATCH 0/8] wl12xx: forward ported Balbi's bus driver refactor Luciano Coelho
@ 2011-10-06 19:10 ` Luciano Coelho
2011-10-06 19:10 ` [PATCH 2/8] wl12xx: add an spi " Luciano Coelho
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Luciano Coelho @ 2011-10-06 19:10 UTC (permalink / raw)
To: coelho; +Cc: linux-wireless
From: Felipe Balbi <balbi@ti.com>
In order to fully abstract the bus, we need to save the device
structure *beside* wl1271, instead of inside it.
This will help re-structuring the driver so that we avoid the
duplicated code in the bus modules.
Signed-off-by: Felipe Balbi <balbi@ti.com>
[forward-ported and cleaned up and rephrased commit message]
Signed-off-by: Luciano Coelho <coelho@ti.com>
---
drivers/net/wireless/wl12xx/sdio.c | 59 ++++++++++++++++++++++++++----------
1 files changed, 43 insertions(+), 16 deletions(-)
diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c
index 516a898..c3ddaa6 100644
--- a/drivers/net/wireless/wl12xx/sdio.c
+++ b/drivers/net/wireless/wl12xx/sdio.c
@@ -44,6 +44,11 @@
#define SDIO_DEVICE_ID_TI_WL1271 0x4076
#endif
+struct wl12xx_sdio_glue {
+ struct device *dev;
+ struct wl1271 *wl;
+};
+
static const struct sdio_device_id wl1271_devices[] __devinitconst = {
{ SDIO_DEVICE(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271) },
{}
@@ -57,14 +62,14 @@ static void wl1271_sdio_set_block_size(struct wl1271 *wl, unsigned int blksz)
sdio_release_host(wl->if_priv);
}
-static inline struct sdio_func *wl_to_func(struct wl1271 *wl)
+static inline struct wl12xx_sdio_glue *wl_to_glue(struct wl1271 *wl)
{
return wl->if_priv;
}
static struct device *wl1271_sdio_wl_to_dev(struct wl1271 *wl)
{
- return &(wl_to_func(wl)->dev);
+ return wl_to_glue(wl)->dev;
}
static irqreturn_t wl1271_hardirq(int irq, void *cookie)
@@ -110,7 +115,8 @@ static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf,
size_t len, bool fixed)
{
int ret;
- struct sdio_func *func = wl_to_func(wl);
+ struct wl12xx_sdio_glue *glue = wl_to_glue(wl);
+ struct sdio_func *func = dev_to_sdio_func(glue->dev);
if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) {
((u8 *)buf)[0] = sdio_f0_readb(func, addr, &ret);
@@ -135,7 +141,8 @@ static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf,
size_t len, bool fixed)
{
int ret;
- struct sdio_func *func = wl_to_func(wl);
+ struct wl12xx_sdio_glue *glue = wl_to_glue(wl);
+ struct sdio_func *func = dev_to_sdio_func(glue->dev);
if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) {
sdio_f0_writeb(func, ((u8 *)buf)[0], addr, &ret);
@@ -158,8 +165,9 @@ static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf,
static int wl1271_sdio_power_on(struct wl1271 *wl)
{
- struct sdio_func *func = wl_to_func(wl);
int ret;
+ struct wl12xx_sdio_glue *glue = wl_to_glue(wl);
+ struct sdio_func *func = dev_to_sdio_func(glue->dev);
/* If enabled, tell runtime PM not to power off the card */
if (pm_runtime_enabled(&func->dev)) {
@@ -182,8 +190,9 @@ out:
static int wl1271_sdio_power_off(struct wl1271 *wl)
{
- struct sdio_func *func = wl_to_func(wl);
int ret;
+ struct wl12xx_sdio_glue *glue = wl_to_glue(wl);
+ struct sdio_func *func = dev_to_sdio_func(glue->dev);
sdio_disable_func(func);
sdio_release_host(func);
@@ -224,21 +233,34 @@ static int __devinit wl1271_probe(struct sdio_func *func,
struct ieee80211_hw *hw;
const struct wl12xx_platform_data *wlan_data;
struct wl1271 *wl;
+ struct wl12xx_sdio_glue *glue;
unsigned long irqflags;
mmc_pm_flag_t mmcflags;
- int ret;
+ int ret = -ENOMEM;
/* We are only able to handle the wlan function */
if (func->num != 0x02)
return -ENODEV;
+ glue = kzalloc(sizeof(*glue), GFP_KERNEL);
+ if (!glue) {
+ wl1271_error("can't allocate glue");
+ goto out;
+ }
+
hw = wl1271_alloc_hw();
- if (IS_ERR(hw))
- return PTR_ERR(hw);
+ if (IS_ERR(hw)) {
+ wl1271_error("can't allocate hw");
+ ret = PTR_ERR(hw);
+ goto out_free_glue;
+ }
wl = hw->priv;
- wl->if_priv = func;
+ glue->dev = &func->dev;
+ glue->wl = wl;
+
+ wl->if_priv = glue;
wl->if_ops = &sdio_ops;
/* Grab access to FN0 for ELP reg. */
@@ -251,7 +273,7 @@ static int __devinit wl1271_probe(struct sdio_func *func,
if (IS_ERR(wlan_data)) {
ret = PTR_ERR(wlan_data);
wl1271_error("missing wlan platform data: %d", ret);
- goto out_free;
+ goto out_free_hw;
}
wl->irq = wlan_data->irq;
@@ -269,7 +291,7 @@ static int __devinit wl1271_probe(struct sdio_func *func,
DRIVER_NAME, wl);
if (ret < 0) {
wl1271_error("request_irq() failed: %d", ret);
- goto out_free;
+ goto out_free_hw;
}
ret = enable_irq_wake(wl->irq);
@@ -294,25 +316,29 @@ static int __devinit wl1271_probe(struct sdio_func *func,
if (ret)
goto out_irq;
- sdio_set_drvdata(func, wl);
+ sdio_set_drvdata(func, glue);
/* Tell PM core that we don't need the card to be powered now */
pm_runtime_put_noidle(&func->dev);
return 0;
- out_irq:
+out_irq:
free_irq(wl->irq, wl);
- out_free:
+out_free_hw:
wl1271_free_hw(wl);
+out_free_glue:
+ kfree(glue);
+out:
return ret;
}
static void __devexit wl1271_remove(struct sdio_func *func)
{
- struct wl1271 *wl = sdio_get_drvdata(func);
+ struct wl12xx_sdio_glue *glue= sdio_get_drvdata(func);
+ struct wl1271 *wl = glue->wl;
/* Undo decrement done above in wl1271_probe */
pm_runtime_get_noresume(&func->dev);
@@ -324,6 +350,7 @@ static void __devexit wl1271_remove(struct sdio_func *func)
}
free_irq(wl->irq, wl);
wl1271_free_hw(wl);
+ kfree(glue);
}
#ifdef CONFIG_PM
--
1.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/8] wl12xx: add an spi glue struct to keep wl and device side-by-side
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 ` Luciano Coelho
2011-10-06 19:10 ` [PATCH 3/8] wl12xx: add a platform device to the sdio module Luciano Coelho
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Luciano Coelho @ 2011-10-06 19:10 UTC (permalink / raw)
To: coelho; +Cc: linux-wireless
From: Felipe Balbi <balbi@ti.com>
In order to fully abstract the bus, we need to save the device
structure *beside* wl1271, instead of inside it.
This will help re-structuring the driver so that we avoid the
duplicated code in the bus modules.
Signed-off-by: Felipe Balbi <balbi@ti.com>
[forward-ported and cleaned up and rephrased commit message]
Signed-off-by: Luciano Coelho <coelho@ti.com>
---
drivers/net/wireless/wl12xx/spi.c | 67 ++++++++++++++++++++++++++-----------
1 files changed, 47 insertions(+), 20 deletions(-)
diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c
index 0f97186..16f0c71 100644
--- a/drivers/net/wireless/wl12xx/spi.c
+++ b/drivers/net/wireless/wl12xx/spi.c
@@ -69,14 +69,19 @@
#define WSPI_MAX_NUM_OF_CHUNKS (WL1271_AGGR_BUFFER_SIZE / WSPI_MAX_CHUNK_SIZE)
-static inline struct spi_device *wl_to_spi(struct wl1271 *wl)
+struct wl12xx_spi_glue {
+ struct device *dev;
+ struct wl1271 *wl;
+};
+
+static inline struct wl12xx_spi_glue *wl_to_glue(struct wl1271 *wl)
{
return wl->if_priv;
}
static struct device *wl1271_spi_wl_to_dev(struct wl1271 *wl)
{
- return &(wl_to_spi(wl)->dev);
+ return wl_to_glue(wl)->dev;
}
static void wl1271_spi_disable_interrupts(struct wl1271 *wl)
@@ -91,6 +96,7 @@ static void wl1271_spi_enable_interrupts(struct wl1271 *wl)
static void wl1271_spi_reset(struct wl1271 *wl)
{
+ struct wl12xx_spi_glue *glue = wl_to_glue(wl);
u8 *cmd;
struct spi_transfer t;
struct spi_message m;
@@ -110,7 +116,7 @@ static void wl1271_spi_reset(struct wl1271 *wl)
t.len = WSPI_INIT_CMD_LEN;
spi_message_add_tail(&t, &m);
- spi_sync(wl_to_spi(wl), &m);
+ spi_sync(to_spi_device(glue->dev), &m);
wl1271_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN);
kfree(cmd);
@@ -118,6 +124,7 @@ static void wl1271_spi_reset(struct wl1271 *wl)
static void wl1271_spi_init(struct wl1271 *wl)
{
+ struct wl12xx_spi_glue *glue = wl_to_glue(wl);
u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd;
struct spi_transfer t;
struct spi_message m;
@@ -165,7 +172,7 @@ static void wl1271_spi_init(struct wl1271 *wl)
t.len = WSPI_INIT_CMD_LEN;
spi_message_add_tail(&t, &m);
- spi_sync(wl_to_spi(wl), &m);
+ spi_sync(to_spi_device(glue->dev), &m);
wl1271_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN);
kfree(cmd);
}
@@ -174,6 +181,7 @@ static void wl1271_spi_init(struct wl1271 *wl)
static int wl1271_spi_read_busy(struct wl1271 *wl)
{
+ struct wl12xx_spi_glue *glue = wl_to_glue(wl);
struct spi_transfer t[1];
struct spi_message m;
u32 *busy_buf;
@@ -194,7 +202,7 @@ static int wl1271_spi_read_busy(struct wl1271 *wl)
t[0].len = sizeof(u32);
t[0].cs_change = true;
spi_message_add_tail(&t[0], &m);
- spi_sync(wl_to_spi(wl), &m);
+ spi_sync(to_spi_device(glue->dev), &m);
if (*busy_buf & 0x1)
return 0;
@@ -208,6 +216,7 @@ static int wl1271_spi_read_busy(struct wl1271 *wl)
static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf,
size_t len, bool fixed)
{
+ struct wl12xx_spi_glue *glue = wl_to_glue(wl);
struct spi_transfer t[2];
struct spi_message m;
u32 *busy_buf;
@@ -243,7 +252,7 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf,
t[1].cs_change = true;
spi_message_add_tail(&t[1], &m);
- spi_sync(wl_to_spi(wl), &m);
+ spi_sync(to_spi_device(glue->dev), &m);
if (!(busy_buf[WL1271_BUSY_WORD_CNT - 1] & 0x1) &&
wl1271_spi_read_busy(wl)) {
@@ -259,7 +268,7 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf,
t[0].cs_change = true;
spi_message_add_tail(&t[0], &m);
- spi_sync(wl_to_spi(wl), &m);
+ spi_sync(to_spi_device(glue->dev), &m);
wl1271_dump(DEBUG_SPI, "spi_read cmd -> ", cmd, sizeof(*cmd));
wl1271_dump(DEBUG_SPI, "spi_read buf <- ", buf, chunk_len);
@@ -274,6 +283,7 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf,
static void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf,
size_t len, bool fixed)
{
+ struct wl12xx_spi_glue *glue = wl_to_glue(wl);
struct spi_transfer t[2 * WSPI_MAX_NUM_OF_CHUNKS];
struct spi_message m;
u32 commands[WSPI_MAX_NUM_OF_CHUNKS];
@@ -318,7 +328,7 @@ static void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf,
cmd++;
}
- spi_sync(wl_to_spi(wl), &m);
+ spi_sync(to_spi_device(glue->dev), &m);
}
static irqreturn_t wl1271_hardirq(int irq, void *cookie)
@@ -362,11 +372,12 @@ static struct wl1271_if_operations spi_ops = {
static int __devinit wl1271_probe(struct spi_device *spi)
{
+ struct wl12xx_spi_glue *glue;
struct wl12xx_platform_data *pdata;
struct ieee80211_hw *hw;
struct wl1271 *wl;
unsigned long irqflags;
- int ret;
+ int ret = -ENOMEM;
pdata = spi->dev.platform_data;
if (!pdata) {
@@ -374,14 +385,25 @@ static int __devinit wl1271_probe(struct spi_device *spi)
return -ENODEV;
}
+ glue = kzalloc(sizeof(*glue), GFP_KERNEL);
+ if (!glue) {
+ wl1271_error("can't allocate glue");
+ goto out;
+ }
+
hw = wl1271_alloc_hw();
- if (IS_ERR(hw))
- return PTR_ERR(hw);
+ if (IS_ERR(hw)) {
+ ret = PTR_ERR(hw);
+ goto out_free_glue;
+ }
wl = hw->priv;
- dev_set_drvdata(&spi->dev, wl);
- wl->if_priv = spi;
+ glue->dev = &spi->dev;
+ glue->wl = wl;
+
+ spi_set_drvdata(spi, glue);
+ wl->if_priv = glue;
wl->if_ops = &spi_ops;
@@ -392,14 +414,14 @@ static int __devinit wl1271_probe(struct spi_device *spi)
ret = spi_setup(spi);
if (ret < 0) {
wl1271_error("spi_setup failed");
- goto out_free;
+ goto out_free_hw;
}
wl->set_power = pdata->set_power;
if (!wl->set_power) {
wl1271_error("set power function missing in platform data");
ret = -ENODEV;
- goto out_free;
+ goto out_free_hw;
}
wl->ref_clock = pdata->board_ref_clock;
@@ -415,7 +437,7 @@ static int __devinit wl1271_probe(struct spi_device *spi)
if (wl->irq < 0) {
wl1271_error("irq missing in platform data");
ret = -ENODEV;
- goto out_free;
+ goto out_free_hw;
}
ret = request_threaded_irq(wl->irq, wl1271_hardirq, wl1271_irq,
@@ -423,7 +445,7 @@ static int __devinit wl1271_probe(struct spi_device *spi)
DRIVER_NAME, wl);
if (ret < 0) {
wl1271_error("request_irq() failed: %d", ret);
- goto out_free;
+ goto out_free_hw;
}
disable_irq(wl->irq);
@@ -438,22 +460,27 @@ static int __devinit wl1271_probe(struct spi_device *spi)
return 0;
- out_irq:
+out_irq:
free_irq(wl->irq, wl);
- out_free:
+out_free_hw:
wl1271_free_hw(wl);
+out_free_glue:
+ kfree(glue);
+out:
return ret;
}
static int __devexit wl1271_remove(struct spi_device *spi)
{
- struct wl1271 *wl = dev_get_drvdata(&spi->dev);
+ struct wl12xx_spi_glue *glue = spi_get_drvdata(spi);
+ struct wl1271 *wl = glue->wl;
wl1271_unregister_hw(wl);
free_irq(wl->irq, wl);
wl1271_free_hw(wl);
+ kfree(glue);
return 0;
}
--
1.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/8] wl12xx: add a platform device to the sdio module
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 ` Luciano Coelho
2011-10-06 19:10 ` [PATCH 4/8] wl12xx: add a platform device to the spi module Luciano Coelho
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Luciano Coelho @ 2011-10-06 19:10 UTC (permalink / raw)
To: coelho; +Cc: linux-wireless
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/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 c3ddaa6..500704f 100644
--- a/drivers/net/wireless/wl12xx/sdio.c
+++ b/drivers/net/wireless/wl12xx/sdio.c
@@ -24,6 +24,7 @@
#include <linux/irq.h>
#include <linux/module.h>
#include <linux/vmalloc.h>
+#include <linux/platform_device.h>
#include <linux/mmc/sdio_func.h>
#include <linux/mmc/sdio_ids.h>
#include <linux/mmc/card.h>
@@ -47,6 +48,7 @@
struct wl12xx_sdio_glue {
struct device *dev;
struct wl1271 *wl;
+ struct platform_device *core;
};
static const struct sdio_device_id wl1271_devices[] __devinitconst = {
@@ -234,6 +236,7 @@ static int __devinit wl1271_probe(struct sdio_func *func,
const struct wl12xx_platform_data *wlan_data;
struct wl1271 *wl;
struct wl12xx_sdio_glue *glue;
+ struct resource res[1];
unsigned long irqflags;
mmc_pm_flag_t mmcflags;
int ret = -ENOMEM;
@@ -321,8 +324,47 @@ static int __devinit wl1271_probe(struct sdio_func *func,
/* Tell PM core that we don't need the card to be powered now */
pm_runtime_put_noidle(&func->dev);
+ glue->core = platform_device_alloc("wl12xx-sdio", -1);
+ if (!glue->core) {
+ wl1271_error("can't allocate platform_device");
+ ret = -ENOMEM;
+ goto out_unreg_hw;
+ }
+
+ glue->core->dev.parent = &func->dev;
+
+ memset(res, 0x00, sizeof(res));
+
+ res[0].start = wlan_data->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, wlan_data,
+ sizeof(*wlan_data));
+ 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 add 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);
@@ -350,6 +392,8 @@ static void __devexit wl1271_remove(struct sdio_func *func)
}
free_irq(wl->irq, wl);
wl1271_free_hw(wl);
+ platform_device_del(glue->core);
+ platform_device_put(glue->core);
kfree(glue);
}
--
1.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/8] wl12xx: add a platform device to the spi module
2011-10-06 19:10 [PATCH 0/8] wl12xx: forward ported Balbi's bus driver refactor Luciano Coelho
` (2 preceding siblings ...)
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
2011-10-06 19:10 ` [PATCH 5/8] wl12xx: add platform driver to the core module Luciano Coelho
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Luciano Coelho @ 2011-10-06 19:10 UTC (permalink / raw)
To: coelho; +Cc: linux-wireless
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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/8] wl12xx: add platform driver to the core module
2011-10-06 19:10 [PATCH 0/8] wl12xx: forward ported Balbi's bus driver refactor Luciano Coelho
` (3 preceding siblings ...)
2011-10-06 19:10 ` [PATCH 4/8] wl12xx: add a platform device to the spi module Luciano Coelho
@ 2011-10-06 19:10 ` Luciano Coelho
2011-10-06 19:10 ` [PATCH 6/8] wl12xx: move common init code from bus modules to main Luciano Coelho
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Luciano Coelho @ 2011-10-06 19:10 UTC (permalink / raw)
To: coelho; +Cc: linux-wireless
From: Felipe Balbi <balbi@ti.com>
Nnow that we have a platform_device on both glue layers, add a
platform_driver to the core driver.
It's currently an empty platform_driver but more functionality will be
added on later patches.
Signed-off-by: Felipe Balbi <balbi@ti.com>
[forward-ported, cleaned-up and rephrased commit message]
[added platform_driver.driver initialization]
Signed-off-by: Luciano Coelho <coelho@ti.com>
---
drivers/net/wireless/wl12xx/main.c | 39 ++++++++++++++++++++++++++++++++++++
1 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index 194d7cc..84904bd 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -5041,6 +5041,45 @@ int wl1271_free_hw(struct wl1271 *wl)
}
EXPORT_SYMBOL_GPL(wl1271_free_hw);
+static int __devinit wl12xx_probe(struct platform_device *pdev)
+{
+ return 0;
+}
+
+static int __devexit wl12xx_remove(struct platform_device *pdev)
+{
+ return 0;
+}
+
+static const struct platform_device_id wl12xx_id_table[] __devinitconst = {
+ { "wl12xx-sdio", 0 },
+ { "wl12xx-spi", 0 },
+ { } /* Terminating Entry */
+};
+MODULE_DEVICE_TABLE(platform, wl12xx_id_table);
+
+static struct platform_driver wl12xx_driver = {
+ .probe = wl12xx_probe,
+ .remove = __devexit_p(wl12xx_remove),
+ .id_table = wl12xx_id_table,
+ .driver = {
+ .name = "wl12xx",
+ .owner = THIS_MODULE,
+ }
+};
+
+static int __init wl12xx_init(void)
+{
+ return platform_driver_register(&wl12xx_driver);
+}
+module_init(wl12xx_init);
+
+static void __exit wl12xx_exit(void)
+{
+ platform_driver_unregister(&wl12xx_driver);
+}
+module_exit(wl12xx_exit);
+
u32 wl12xx_debug_level = DEBUG_NONE;
EXPORT_SYMBOL_GPL(wl12xx_debug_level);
module_param_named(debug_level, wl12xx_debug_level, uint, S_IRUSR | S_IWUSR);
--
1.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/8] wl12xx: move common init code from bus modules to main
2011-10-06 19:10 [PATCH 0/8] wl12xx: forward ported Balbi's bus driver refactor Luciano Coelho
` (4 preceding siblings ...)
2011-10-06 19:10 ` [PATCH 5/8] wl12xx: add platform driver to the core module Luciano Coelho
@ 2011-10-06 19:10 ` Luciano Coelho
2011-10-06 19:10 ` [PATCH 7/8] wl12xx: mark some symbols static Luciano Coelho
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Luciano Coelho @ 2011-10-06 19:10 UTC (permalink / raw)
To: coelho; +Cc: linux-wireless
From: Felipe Balbi <balbi@ti.com>
Move all common parts from sdio.c and spi.c to main.c, since they now
can be handled as part of the platform driver.
Signed-off-by: Felipe Balbi <balbi@ti.com>
[forward-ported, cleaned-up and rephrased commit message]
[added a bunch of fixes and a new pdata element]
[moved some new code into main.c as well]
Signed-off-by: Luciano Coelho <coelho@ti.com>
---
A list of my changes, besides the ones mentioned above:
* added some missing #includes;
* added new code from sdio hardirq to main;
* assign some wl elements directly instead of copying from a local;
* added wl->if_ops assignment, which was missing;
* added a new pdata element to pass info whether power on during
suspend is supported;
* removed one unused label in wl12xx_probe().
drivers/net/wireless/wl12xx/io.c | 11 +-
drivers/net/wireless/wl12xx/io.h | 14 +-
drivers/net/wireless/wl12xx/main.c | 110 ++++++++++++-
drivers/net/wireless/wl12xx/sdio.c | 174 ++++----------------
drivers/net/wireless/wl12xx/spi.c | 161 +++----------------
drivers/net/wireless/wl12xx/wl12xx.h | 17 +-
drivers/net/wireless/wl12xx/wl12xx_platform_data.c | 4 +-
include/linux/wl12xx.h | 5 +-
8 files changed, 184 insertions(+), 312 deletions(-)
diff --git a/drivers/net/wireless/wl12xx/io.c b/drivers/net/wireless/wl12xx/io.c
index c2da66f..1a7df8a 100644
--- a/drivers/net/wireless/wl12xx/io.c
+++ b/drivers/net/wireless/wl12xx/io.c
@@ -24,6 +24,7 @@
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/spi/spi.h>
+#include <linux/interrupt.h>
#include "wl12xx.h"
#include "wl12xx_80211.h"
@@ -46,7 +47,7 @@
bool wl1271_set_block_size(struct wl1271 *wl)
{
if (wl->if_ops->set_block_size) {
- wl->if_ops->set_block_size(wl, WL12XX_BUS_BLOCK_SIZE);
+ wl->if_ops->set_block_size(wl->dev, WL12XX_BUS_BLOCK_SIZE);
return true;
}
@@ -55,12 +56,12 @@ bool wl1271_set_block_size(struct wl1271 *wl)
void wl1271_disable_interrupts(struct wl1271 *wl)
{
- wl->if_ops->disable_irq(wl);
+ disable_irq(wl->irq);
}
void wl1271_enable_interrupts(struct wl1271 *wl)
{
- wl->if_ops->enable_irq(wl);
+ enable_irq(wl->irq);
}
/* Set the SPI partitions to access the chip addresses
@@ -128,13 +129,13 @@ EXPORT_SYMBOL_GPL(wl1271_set_partition);
void wl1271_io_reset(struct wl1271 *wl)
{
if (wl->if_ops->reset)
- wl->if_ops->reset(wl);
+ wl->if_ops->reset(wl->dev);
}
void wl1271_io_init(struct wl1271 *wl)
{
if (wl->if_ops->init)
- wl->if_ops->init(wl);
+ wl->if_ops->init(wl->dev);
}
void wl1271_top_reg_write(struct wl1271 *wl, int addr, u16 val)
diff --git a/drivers/net/wireless/wl12xx/io.h b/drivers/net/wireless/wl12xx/io.h
index e839341..e82dad1 100644
--- a/drivers/net/wireless/wl12xx/io.h
+++ b/drivers/net/wireless/wl12xx/io.h
@@ -51,23 +51,17 @@ void wl1271_enable_interrupts(struct wl1271 *wl);
void wl1271_io_reset(struct wl1271 *wl);
void wl1271_io_init(struct wl1271 *wl);
-static inline struct device *wl1271_wl_to_dev(struct wl1271 *wl)
-{
- return wl->if_ops->dev(wl);
-}
-
-
/* Raw target IO, address is not translated */
static inline void wl1271_raw_write(struct wl1271 *wl, int addr, void *buf,
size_t len, bool fixed)
{
- wl->if_ops->write(wl, addr, buf, len, fixed);
+ wl->if_ops->write(wl->dev, addr, buf, len, fixed);
}
static inline void wl1271_raw_read(struct wl1271 *wl, int addr, void *buf,
size_t len, bool fixed)
{
- wl->if_ops->read(wl, addr, buf, len, fixed);
+ wl->if_ops->read(wl->dev, addr, buf, len, fixed);
}
static inline u32 wl1271_raw_read32(struct wl1271 *wl, int addr)
@@ -155,13 +149,13 @@ static inline void wl1271_write32(struct wl1271 *wl, int addr, u32 val)
static inline void wl1271_power_off(struct wl1271 *wl)
{
- wl->if_ops->power(wl, false);
+ wl->if_ops->power(wl->dev, false);
clear_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
}
static inline int wl1271_power_on(struct wl1271 *wl)
{
- int ret = wl->if_ops->power(wl, true);
+ int ret = wl->if_ops->power(wl->dev, true);
if (ret == 0)
set_bit(WL1271_FLAG_GPIO_POWER, &wl->flags);
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index 84904bd..e84948d 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -32,6 +32,7 @@
#include <linux/slab.h>
#include <linux/wl12xx.h>
#include <linux/sched.h>
+#include <linux/interrupt.h>
#include "wl12xx.h"
#include "wl12xx_80211.h"
@@ -1058,7 +1059,7 @@ static int wl1271_fetch_firmware(struct wl1271 *wl)
wl1271_debug(DEBUG_BOOT, "booting firmware %s", fw_name);
- ret = request_firmware(&fw, fw_name, wl1271_wl_to_dev(wl));
+ ret = request_firmware(&fw, fw_name, wl->dev);
if (ret < 0) {
wl1271_error("could not get firmware: %d", ret);
@@ -1096,7 +1097,7 @@ static int wl1271_fetch_nvs(struct wl1271 *wl)
const struct firmware *fw;
int ret;
- ret = request_firmware(&fw, WL12XX_NVS_NAME, wl1271_wl_to_dev(wl));
+ ret = request_firmware(&fw, WL12XX_NVS_NAME, wl->dev);
if (ret < 0) {
wl1271_error("could not get nvs file: %d", ret);
@@ -4807,7 +4808,7 @@ int wl1271_init_ieee80211(struct wl1271 *wl)
wl->hw->wiphy->reg_notifier = wl1271_reg_notify;
- SET_IEEE80211_DEV(wl->hw, wl1271_wl_to_dev(wl));
+ SET_IEEE80211_DEV(wl->hw, wl->dev);
wl->hw->sta_data_size = sizeof(struct wl1271_station);
wl->hw->vif_data_size = sizeof(struct wl12xx_vif);
@@ -5041,13 +5042,116 @@ int wl1271_free_hw(struct wl1271 *wl)
}
EXPORT_SYMBOL_GPL(wl1271_free_hw);
+static irqreturn_t wl12xx_hardirq(int irq, void *cookie)
+{
+ struct wl1271 *wl = cookie;
+ unsigned long flags;
+
+ wl1271_debug(DEBUG_IRQ, "IRQ");
+
+ /* complete the ELP completion */
+ spin_lock_irqsave(&wl->wl_lock, flags);
+ set_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags);
+ if (wl->elp_compl) {
+ complete(wl->elp_compl);
+ wl->elp_compl = NULL;
+ }
+
+ if (test_bit(WL1271_FLAG_SUSPENDED, &wl->flags)) {
+ /* don't enqueue a work right now. mark it as pending */
+ set_bit(WL1271_FLAG_PENDING_WORK, &wl->flags);
+ wl1271_debug(DEBUG_IRQ, "should not enqueue work");
+ disable_irq_nosync(wl->irq);
+ pm_wakeup_event(wl->dev, 0);
+ spin_unlock_irqrestore(&wl->wl_lock, flags);
+ return IRQ_HANDLED;
+ }
+ spin_unlock_irqrestore(&wl->wl_lock, flags);
+
+ return IRQ_WAKE_THREAD;
+}
+
static int __devinit wl12xx_probe(struct platform_device *pdev)
{
+ struct wl12xx_platform_data *pdata = pdev->dev.platform_data;
+ struct ieee80211_hw *hw;
+ struct wl1271 *wl;
+ unsigned long irqflags;
+ int ret = -ENODEV;
+
+ hw = wl1271_alloc_hw();
+ if (IS_ERR(hw)) {
+ wl1271_error("can't allocate hw");
+ ret = PTR_ERR(hw);
+ goto out;
+ }
+
+ wl = hw->priv;
+ wl->irq = platform_get_irq(pdev, 0);
+ wl->ref_clock = pdata->board_ref_clock;
+ wl->tcxo_clock = pdata->board_tcxo_clock;
+ wl->platform_quirks = pdata->platform_quirks;
+ wl->set_power = pdata->set_power;
+ wl->dev = &pdev->dev;
+ wl->if_ops = pdata->ops;
+
+ platform_set_drvdata(pdev, wl);
+
+ if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ)
+ irqflags = IRQF_TRIGGER_RISING;
+ else
+ irqflags = IRQF_TRIGGER_HIGH | IRQF_ONESHOT;
+
+ ret = request_threaded_irq(wl->irq, wl12xx_hardirq, wl1271_irq,
+ irqflags,
+ pdev->name, wl);
+ if (ret < 0) {
+ wl1271_error("request_irq() failed: %d", ret);
+ goto out_free_hw;
+ }
+
+ ret = enable_irq_wake(wl->irq);
+ if (!ret) {
+ wl->irq_wake_enabled = true;
+ device_init_wakeup(wl->dev, 1);
+ if (pdata->pwr_in_suspend)
+ hw->wiphy->wowlan.flags = WIPHY_WOWLAN_ANY;
+
+ }
+ disable_irq(wl->irq);
+
+ ret = wl1271_init_ieee80211(wl);
+ if (ret)
+ goto out_irq;
+
+ ret = wl1271_register_hw(wl);
+ if (ret)
+ goto out_irq;
+
return 0;
+
+out_irq:
+ free_irq(wl->irq, wl);
+
+out_free_hw:
+ wl1271_free_hw(wl);
+
+out:
+ return ret;
}
static int __devexit wl12xx_remove(struct platform_device *pdev)
{
+ struct wl1271 *wl = platform_get_drvdata(pdev);
+
+ if (wl->irq_wake_enabled) {
+ device_init_wakeup(wl->dev, 0);
+ disable_irq_wake(wl->irq);
+ }
+ wl1271_unregister_hw(wl);
+ free_irq(wl->irq, wl);
+ wl1271_free_hw(wl);
+
return 0;
}
diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c
index 500704f..0374bcd 100644
--- a/drivers/net/wireless/wl12xx/sdio.c
+++ b/drivers/net/wireless/wl12xx/sdio.c
@@ -47,7 +47,6 @@
struct wl12xx_sdio_glue {
struct device *dev;
- struct wl1271 *wl;
struct platform_device *core;
};
@@ -57,67 +56,22 @@ static const struct sdio_device_id wl1271_devices[] __devinitconst = {
};
MODULE_DEVICE_TABLE(sdio, wl1271_devices);
-static void wl1271_sdio_set_block_size(struct wl1271 *wl, unsigned int blksz)
+static void wl1271_sdio_set_block_size(struct device *child,
+ unsigned int blksz)
{
- sdio_claim_host(wl->if_priv);
- sdio_set_block_size(wl->if_priv, blksz);
- sdio_release_host(wl->if_priv);
-}
-
-static inline struct wl12xx_sdio_glue *wl_to_glue(struct wl1271 *wl)
-{
- return wl->if_priv;
-}
-
-static struct device *wl1271_sdio_wl_to_dev(struct wl1271 *wl)
-{
- return wl_to_glue(wl)->dev;
-}
-
-static irqreturn_t wl1271_hardirq(int irq, void *cookie)
-{
- struct wl1271 *wl = cookie;
- unsigned long flags;
-
- wl1271_debug(DEBUG_IRQ, "IRQ");
-
- /* complete the ELP completion */
- spin_lock_irqsave(&wl->wl_lock, flags);
- set_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags);
- if (wl->elp_compl) {
- complete(wl->elp_compl);
- wl->elp_compl = NULL;
- }
-
- if (test_bit(WL1271_FLAG_SUSPENDED, &wl->flags)) {
- /* don't enqueue a work right now. mark it as pending */
- set_bit(WL1271_FLAG_PENDING_WORK, &wl->flags);
- wl1271_debug(DEBUG_IRQ, "should not enqueue work");
- disable_irq_nosync(wl->irq);
- pm_wakeup_event(wl1271_sdio_wl_to_dev(wl), 0);
- spin_unlock_irqrestore(&wl->wl_lock, flags);
- return IRQ_HANDLED;
- }
- spin_unlock_irqrestore(&wl->wl_lock, flags);
-
- return IRQ_WAKE_THREAD;
-}
-
-static void wl1271_sdio_disable_interrupts(struct wl1271 *wl)
-{
- disable_irq(wl->irq);
-}
+ struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent);
+ struct sdio_func *func = dev_to_sdio_func(glue->dev);
-static void wl1271_sdio_enable_interrupts(struct wl1271 *wl)
-{
- enable_irq(wl->irq);
+ sdio_claim_host(func);
+ sdio_set_block_size(func, blksz);
+ sdio_release_host(func);
}
-static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf,
+static void wl12xx_sdio_raw_read(struct device *child, int addr, void *buf,
size_t len, bool fixed)
{
int ret;
- struct wl12xx_sdio_glue *glue = wl_to_glue(wl);
+ struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent);
struct sdio_func *func = dev_to_sdio_func(glue->dev);
if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) {
@@ -139,11 +93,11 @@ static void wl1271_sdio_raw_read(struct wl1271 *wl, int addr, void *buf,
wl1271_error("sdio read failed (%d)", ret);
}
-static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf,
+static void wl12xx_sdio_raw_write(struct device *child, int addr, void *buf,
size_t len, bool fixed)
{
int ret;
- struct wl12xx_sdio_glue *glue = wl_to_glue(wl);
+ struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent);
struct sdio_func *func = dev_to_sdio_func(glue->dev);
if (unlikely(addr == HW_ACCESS_ELP_CTRL_REG_ADDR)) {
@@ -165,10 +119,9 @@ static void wl1271_sdio_raw_write(struct wl1271 *wl, int addr, void *buf,
wl1271_error("sdio write failed (%d)", ret);
}
-static int wl1271_sdio_power_on(struct wl1271 *wl)
+static int wl12xx_sdio_power_on(struct wl12xx_sdio_glue *glue)
{
int ret;
- struct wl12xx_sdio_glue *glue = wl_to_glue(wl);
struct sdio_func *func = dev_to_sdio_func(glue->dev);
/* If enabled, tell runtime PM not to power off the card */
@@ -190,10 +143,9 @@ out:
return ret;
}
-static int wl1271_sdio_power_off(struct wl1271 *wl)
+static int wl12xx_sdio_power_off(struct wl12xx_sdio_glue *glue)
{
int ret;
- struct wl12xx_sdio_glue *glue = wl_to_glue(wl);
struct sdio_func *func = dev_to_sdio_func(glue->dev);
sdio_disable_func(func);
@@ -211,33 +163,29 @@ static int wl1271_sdio_power_off(struct wl1271 *wl)
return ret;
}
-static int wl1271_sdio_set_power(struct wl1271 *wl, bool enable)
+static int wl12xx_sdio_set_power(struct device *child, bool enable)
{
+ struct wl12xx_sdio_glue *glue = dev_get_drvdata(child->parent);
+
if (enable)
- return wl1271_sdio_power_on(wl);
+ return wl12xx_sdio_power_on(glue);
else
- return wl1271_sdio_power_off(wl);
+ return wl12xx_sdio_power_off(glue);
}
static struct wl1271_if_operations sdio_ops = {
- .read = wl1271_sdio_raw_read,
- .write = wl1271_sdio_raw_write,
- .power = wl1271_sdio_set_power,
- .dev = wl1271_sdio_wl_to_dev,
- .enable_irq = wl1271_sdio_enable_interrupts,
- .disable_irq = wl1271_sdio_disable_interrupts,
+ .read = wl12xx_sdio_raw_read,
+ .write = wl12xx_sdio_raw_write,
+ .power = wl12xx_sdio_set_power,
.set_block_size = wl1271_sdio_set_block_size,
};
static int __devinit wl1271_probe(struct sdio_func *func,
const struct sdio_device_id *id)
{
- struct ieee80211_hw *hw;
- const struct wl12xx_platform_data *wlan_data;
- struct wl1271 *wl;
+ struct wl12xx_platform_data *wlan_data;
struct wl12xx_sdio_glue *glue;
struct resource res[1];
- unsigned long irqflags;
mmc_pm_flag_t mmcflags;
int ret = -ENOMEM;
@@ -251,20 +199,7 @@ static int __devinit wl1271_probe(struct sdio_func *func,
goto out;
}
- hw = wl1271_alloc_hw();
- if (IS_ERR(hw)) {
- wl1271_error("can't allocate hw");
- ret = PTR_ERR(hw);
- goto out_free_glue;
- }
-
- wl = hw->priv;
-
glue->dev = &func->dev;
- glue->wl = wl;
-
- wl->if_priv = glue;
- wl->if_ops = &sdio_ops;
/* Grab access to FN0 for ELP reg. */
func->card->quirks |= MMC_QUIRK_LENIENT_FN0;
@@ -276,48 +211,17 @@ static int __devinit wl1271_probe(struct sdio_func *func,
if (IS_ERR(wlan_data)) {
ret = PTR_ERR(wlan_data);
wl1271_error("missing wlan platform data: %d", ret);
- goto out_free_hw;
- }
-
- wl->irq = wlan_data->irq;
- wl->ref_clock = wlan_data->board_ref_clock;
- wl->tcxo_clock = wlan_data->board_tcxo_clock;
- wl->platform_quirks = wlan_data->platform_quirks;
-
- if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ)
- irqflags = IRQF_TRIGGER_RISING;
- else
- irqflags = IRQF_TRIGGER_HIGH | IRQF_ONESHOT;
-
- ret = request_threaded_irq(wl->irq, wl1271_hardirq, wl1271_irq,
- irqflags,
- DRIVER_NAME, wl);
- if (ret < 0) {
- wl1271_error("request_irq() failed: %d", ret);
- goto out_free_hw;
+ goto out_free_glue;
}
- ret = enable_irq_wake(wl->irq);
- if (!ret) {
- wl->irq_wake_enabled = true;
- device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 1);
+ /* if sdio can keep power while host is suspended, enable wow */
+ mmcflags = sdio_get_host_pm_caps(func);
+ wl1271_debug(DEBUG_SDIO, "sdio PM caps = 0x%x", mmcflags);
- /* if sdio can keep power while host is suspended, enable wow */
- mmcflags = sdio_get_host_pm_caps(func);
- wl1271_debug(DEBUG_SDIO, "sdio PM caps = 0x%x", mmcflags);
+ if (mmcflags & MMC_PM_KEEP_POWER)
+ wlan_data->pwr_in_suspend = true;
- if (mmcflags & MMC_PM_KEEP_POWER)
- hw->wiphy->wowlan.flags = WIPHY_WOWLAN_ANY;
- }
- disable_irq(wl->irq);
-
- ret = wl1271_init_ieee80211(wl);
- if (ret)
- goto out_irq;
-
- ret = wl1271_register_hw(wl);
- if (ret)
- goto out_irq;
+ wlan_data->ops = &sdio_ops;
sdio_set_drvdata(func, glue);
@@ -328,7 +232,7 @@ static int __devinit wl1271_probe(struct sdio_func *func,
if (!glue->core) {
wl1271_error("can't allocate platform_device");
ret = -ENOMEM;
- goto out_unreg_hw;
+ goto out_free_glue;
}
glue->core->dev.parent = &func->dev;
@@ -362,17 +266,9 @@ static int __devinit wl1271_probe(struct sdio_func *func,
out_dev_put:
platform_device_put(glue->core);
-out_unreg_hw:
- wl1271_unregister_hw(wl);
-
-out_irq:
- free_irq(wl->irq, wl);
-
-out_free_hw:
- wl1271_free_hw(wl);
-
out_free_glue:
kfree(glue);
+
out:
return ret;
}
@@ -380,18 +276,10 @@ out:
static void __devexit wl1271_remove(struct sdio_func *func)
{
struct wl12xx_sdio_glue *glue= sdio_get_drvdata(func);
- struct wl1271 *wl = glue->wl;
/* Undo decrement done above in wl1271_probe */
pm_runtime_get_noresume(&func->dev);
- wl1271_unregister_hw(wl);
- if (wl->irq_wake_enabled) {
- device_init_wakeup(wl1271_sdio_wl_to_dev(wl), 0);
- disable_irq_wake(wl->irq);
- }
- free_irq(wl->irq, wl);
- wl1271_free_hw(wl);
platform_device_del(glue->core);
platform_device_put(glue->core);
kfree(glue);
diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/spi.c
index e075d69..54ee9c1 100644
--- a/drivers/net/wireless/wl12xx/spi.c
+++ b/drivers/net/wireless/wl12xx/spi.c
@@ -72,33 +72,12 @@
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)
+static void wl12xx_spi_reset(struct device *child)
{
- return wl->if_priv;
-}
-
-static struct device *wl1271_spi_wl_to_dev(struct wl1271 *wl)
-{
- return wl_to_glue(wl)->dev;
-}
-
-static void wl1271_spi_disable_interrupts(struct wl1271 *wl)
-{
- disable_irq(wl->irq);
-}
-
-static void wl1271_spi_enable_interrupts(struct wl1271 *wl)
-{
- enable_irq(wl->irq);
-}
-
-static void wl1271_spi_reset(struct wl1271 *wl)
-{
- struct wl12xx_spi_glue *glue = wl_to_glue(wl);
+ struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent);
u8 *cmd;
struct spi_transfer t;
struct spi_message m;
@@ -124,9 +103,9 @@ static void wl1271_spi_reset(struct wl1271 *wl)
kfree(cmd);
}
-static void wl1271_spi_init(struct wl1271 *wl)
+static void wl12xx_spi_init(struct device *child)
{
- struct wl12xx_spi_glue *glue = wl_to_glue(wl);
+ struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent);
u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd;
struct spi_transfer t;
struct spi_message m;
@@ -181,9 +160,10 @@ static void wl1271_spi_init(struct wl1271 *wl)
#define WL1271_BUSY_WORD_TIMEOUT 1000
-static int wl1271_spi_read_busy(struct wl1271 *wl)
+static int wl12xx_spi_read_busy(struct device *child)
{
- struct wl12xx_spi_glue *glue = wl_to_glue(wl);
+ struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent);
+ struct wl1271 *wl = dev_get_drvdata(child);
struct spi_transfer t[1];
struct spi_message m;
u32 *busy_buf;
@@ -215,10 +195,11 @@ static int wl1271_spi_read_busy(struct wl1271 *wl)
return -ETIMEDOUT;
}
-static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf,
+static void wl12xx_spi_raw_read(struct device *child, int addr, void *buf,
size_t len, bool fixed)
{
- struct wl12xx_spi_glue *glue = wl_to_glue(wl);
+ struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent);
+ struct wl1271 *wl = dev_get_drvdata(child);
struct spi_transfer t[2];
struct spi_message m;
u32 *busy_buf;
@@ -257,7 +238,7 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf,
spi_sync(to_spi_device(glue->dev), &m);
if (!(busy_buf[WL1271_BUSY_WORD_CNT - 1] & 0x1) &&
- wl1271_spi_read_busy(wl)) {
+ wl12xx_spi_read_busy(child)) {
memset(buf, 0, chunk_len);
return;
}
@@ -282,10 +263,10 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf,
}
}
-static void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf,
- size_t len, bool fixed)
+static void wl12xx_spi_raw_write(struct device *child, int addr, void *buf,
+ size_t len, bool fixed)
{
- struct wl12xx_spi_glue *glue = wl_to_glue(wl);
+ struct wl12xx_spi_glue *glue = dev_get_drvdata(child->parent);
struct spi_transfer t[2 * WSPI_MAX_NUM_OF_CHUNKS];
struct spi_message m;
u32 commands[WSPI_MAX_NUM_OF_CHUNKS];
@@ -333,42 +314,11 @@ static void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf,
spi_sync(to_spi_device(glue->dev), &m);
}
-static irqreturn_t wl1271_hardirq(int irq, void *cookie)
-{
- struct wl1271 *wl = cookie;
- unsigned long flags;
-
- wl1271_debug(DEBUG_IRQ, "IRQ");
-
- /* complete the ELP completion */
- spin_lock_irqsave(&wl->wl_lock, flags);
- set_bit(WL1271_FLAG_IRQ_RUNNING, &wl->flags);
- if (wl->elp_compl) {
- complete(wl->elp_compl);
- wl->elp_compl = NULL;
- }
- spin_unlock_irqrestore(&wl->wl_lock, flags);
-
- return IRQ_WAKE_THREAD;
-}
-
-static int wl1271_spi_set_power(struct wl1271 *wl, bool enable)
-{
- if (wl->set_power)
- wl->set_power(enable);
-
- return 0;
-}
-
static struct wl1271_if_operations spi_ops = {
- .read = wl1271_spi_raw_read,
- .write = wl1271_spi_raw_write,
- .reset = wl1271_spi_reset,
- .init = wl1271_spi_init,
- .power = wl1271_spi_set_power,
- .dev = wl1271_spi_wl_to_dev,
- .enable_irq = wl1271_spi_enable_interrupts,
- .disable_irq = wl1271_spi_disable_interrupts,
+ .read = wl12xx_spi_raw_read,
+ .write = wl12xx_spi_raw_write,
+ .reset = wl12xx_spi_reset,
+ .init = wl12xx_spi_init,
.set_block_size = NULL,
};
@@ -376,10 +326,7 @@ static int __devinit wl1271_probe(struct spi_device *spi)
{
struct wl12xx_spi_glue *glue;
struct wl12xx_platform_data *pdata;
- struct ieee80211_hw *hw;
- struct wl1271 *wl;
struct resource res[1];
- unsigned long irqflags;
int ret = -ENOMEM;
pdata = spi->dev.platform_data;
@@ -388,27 +335,17 @@ static int __devinit wl1271_probe(struct spi_device *spi)
return -ENODEV;
}
+ pdata->ops = &spi_ops;
+
glue = kzalloc(sizeof(*glue), GFP_KERNEL);
if (!glue) {
wl1271_error("can't allocate glue");
goto out;
}
- hw = wl1271_alloc_hw();
- if (IS_ERR(hw)) {
- ret = PTR_ERR(hw);
- goto out_free_glue;
- }
-
- wl = hw->priv;
-
glue->dev = &spi->dev;
- glue->wl = wl;
spi_set_drvdata(spi, glue);
- wl->if_priv = glue;
-
- wl->if_ops = &spi_ops;
/* This is the only SPI value that we need to set here, the rest
* comes from the board-peripherals file */
@@ -417,55 +354,14 @@ static int __devinit wl1271_probe(struct spi_device *spi)
ret = spi_setup(spi);
if (ret < 0) {
wl1271_error("spi_setup failed");
- goto out_free_hw;
- }
-
- wl->set_power = pdata->set_power;
- if (!wl->set_power) {
- wl1271_error("set power function missing in platform data");
- ret = -ENODEV;
- goto out_free_hw;
- }
-
- wl->ref_clock = pdata->board_ref_clock;
- wl->tcxo_clock = pdata->board_tcxo_clock;
- wl->platform_quirks = pdata->platform_quirks;
-
- if (wl->platform_quirks & WL12XX_PLATFORM_QUIRK_EDGE_IRQ)
- irqflags = IRQF_TRIGGER_RISING;
- else
- irqflags = IRQF_TRIGGER_HIGH | IRQF_ONESHOT;
-
- wl->irq = spi->irq;
- if (wl->irq < 0) {
- wl1271_error("irq missing in platform data");
- ret = -ENODEV;
- goto out_free_hw;
- }
-
- ret = request_threaded_irq(wl->irq, wl1271_hardirq, wl1271_irq,
- irqflags,
- DRIVER_NAME, wl);
- if (ret < 0) {
- wl1271_error("request_irq() failed: %d", ret);
- goto out_free_hw;
+ goto out_free_glue;
}
- disable_irq(wl->irq);
-
- ret = wl1271_init_ieee80211(wl);
- if (ret)
- goto out_irq;
-
- ret = wl1271_register_hw(wl);
- 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;
+ goto out_free_glue;
}
glue->core->dev.parent = &spi->dev;
@@ -499,15 +395,6 @@ static int __devinit wl1271_probe(struct spi_device *spi)
out_dev_put:
platform_device_put(glue->core);
-out_unreg_hw:
- wl1271_unregister_hw(wl);
-
-out_irq:
- free_irq(wl->irq, wl);
-
-out_free_hw:
- wl1271_free_hw(wl);
-
out_free_glue:
kfree(glue);
out:
@@ -517,11 +404,7 @@ out:
static int __devexit wl1271_remove(struct spi_device *spi)
{
struct wl12xx_spi_glue *glue = spi_get_drvdata(spi);
- struct wl1271 *wl = glue->wl;
- 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);
diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h
index 074de4e..091fdd2 100644
--- a/drivers/net/wireless/wl12xx/wl12xx.h
+++ b/drivers/net/wireless/wl12xx/wl12xx.h
@@ -286,17 +286,14 @@ struct wl1271_scan {
};
struct wl1271_if_operations {
- void (*read)(struct wl1271 *wl, int addr, void *buf, size_t len,
+ void (*read)(struct device *child, int addr, void *buf, size_t len,
bool fixed);
- void (*write)(struct wl1271 *wl, int addr, void *buf, size_t len,
+ void (*write)(struct device *child, int addr, void *buf, size_t len,
bool fixed);
- void (*reset)(struct wl1271 *wl);
- void (*init)(struct wl1271 *wl);
- int (*power)(struct wl1271 *wl, bool enable);
- struct device* (*dev)(struct wl1271 *wl);
- void (*enable_irq)(struct wl1271 *wl);
- void (*disable_irq)(struct wl1271 *wl);
- void (*set_block_size) (struct wl1271 *wl, unsigned int blksz);
+ void (*reset)(struct device *child);
+ void (*init)(struct device *child);
+ int (*power)(struct device *child, bool enable);
+ void (*set_block_size) (struct device *child, unsigned int blksz);
};
#define MAX_NUM_KEYS 14
@@ -357,6 +354,8 @@ struct wl1271 {
struct ieee80211_hw *hw;
bool mac80211_registered;
+ struct device *dev;
+
void *if_priv;
struct wl1271_if_operations *if_ops;
diff --git a/drivers/net/wireless/wl12xx/wl12xx_platform_data.c b/drivers/net/wireless/wl12xx/wl12xx_platform_data.c
index 973b110..3c96b33 100644
--- a/drivers/net/wireless/wl12xx/wl12xx_platform_data.c
+++ b/drivers/net/wireless/wl12xx/wl12xx_platform_data.c
@@ -2,7 +2,7 @@
#include <linux/err.h>
#include <linux/wl12xx.h>
-static const struct wl12xx_platform_data *platform_data;
+static struct wl12xx_platform_data *platform_data;
int __init wl12xx_set_platform_data(const struct wl12xx_platform_data *data)
{
@@ -18,7 +18,7 @@ int __init wl12xx_set_platform_data(const struct wl12xx_platform_data *data)
return 0;
}
-const struct wl12xx_platform_data *wl12xx_get_platform_data(void)
+struct wl12xx_platform_data *wl12xx_get_platform_data(void)
{
if (!platform_data)
return ERR_PTR(-ENODEV);
diff --git a/include/linux/wl12xx.h b/include/linux/wl12xx.h
index 4b69739..0d63731 100644
--- a/include/linux/wl12xx.h
+++ b/include/linux/wl12xx.h
@@ -54,6 +54,9 @@ struct wl12xx_platform_data {
int board_ref_clock;
int board_tcxo_clock;
unsigned long platform_quirks;
+ bool pwr_in_suspend;
+
+ struct wl1271_if_operations *ops;
};
/* Platform does not support level trigger interrupts */
@@ -73,6 +76,6 @@ int wl12xx_set_platform_data(const struct wl12xx_platform_data *data)
#endif
-const struct wl12xx_platform_data *wl12xx_get_platform_data(void);
+struct wl12xx_platform_data *wl12xx_get_platform_data(void);
#endif
--
1.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 7/8] wl12xx: mark some symbols static
2011-10-06 19:10 [PATCH 0/8] wl12xx: forward ported Balbi's bus driver refactor Luciano Coelho
` (5 preceding siblings ...)
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 ` 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
8 siblings, 0 replies; 10+ messages in thread
From: Luciano Coelho @ 2011-10-06 19:10 UTC (permalink / raw)
To: coelho; +Cc: linux-wireless
From: Felipe Balbi <balbi@ti.com>
after re-factoring a bunch of symbols are only
used inside main.c which allows us to mark
them as static.
Signed-off-by: Felipe Balbi <balbi@ti.com>
[forward-ported]
Signed-off-by: Luciano Coelho <coelho@ti.com>
---
drivers/net/wireless/wl12xx/io.h | 9 ++-------
drivers/net/wireless/wl12xx/main.c | 18 ++++++------------
2 files changed, 8 insertions(+), 19 deletions(-)
diff --git a/drivers/net/wireless/wl12xx/io.h b/drivers/net/wireless/wl12xx/io.h
index e82dad1..d398cbc 100644
--- a/drivers/net/wireless/wl12xx/io.h
+++ b/drivers/net/wireless/wl12xx/io.h
@@ -170,15 +170,10 @@ u16 wl1271_top_reg_read(struct wl1271 *wl, int addr);
int wl1271_set_partition(struct wl1271 *wl,
struct wl1271_partition_set *p);
+bool wl1271_set_block_size(struct wl1271 *wl);
+
/* Functions from wl1271_main.c */
-int wl1271_register_hw(struct wl1271 *wl);
-void wl1271_unregister_hw(struct wl1271 *wl);
-int wl1271_init_ieee80211(struct wl1271 *wl);
-struct ieee80211_hw *wl1271_alloc_hw(void);
-int wl1271_free_hw(struct wl1271 *wl);
-irqreturn_t wl1271_irq(int irq, void *data);
-bool wl1271_set_block_size(struct wl1271 *wl);
int wl1271_tx_dummy_packet(struct wl1271 *wl);
#endif
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index e84948d..18f87f0 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -922,7 +922,7 @@ static void wl1271_netstack_work(struct work_struct *work)
#define WL1271_IRQ_MAX_LOOPS 256
-irqreturn_t wl1271_irq(int irq, void *cookie)
+static irqreturn_t wl1271_irq(int irq, void *cookie)
{
int ret;
u32 intr;
@@ -1044,7 +1044,6 @@ out:
return IRQ_HANDLED;
}
-EXPORT_SYMBOL_GPL(wl1271_irq);
static int wl1271_fetch_firmware(struct wl1271 *wl)
{
@@ -4676,7 +4675,7 @@ static struct bin_attribute fwlog_attr = {
.read = wl1271_sysfs_read_fwlog,
};
-int wl1271_register_hw(struct wl1271 *wl)
+static int wl1271_register_hw(struct wl1271 *wl)
{
int ret;
@@ -4717,9 +4716,8 @@ int wl1271_register_hw(struct wl1271 *wl)
return 0;
}
-EXPORT_SYMBOL_GPL(wl1271_register_hw);
-void wl1271_unregister_hw(struct wl1271 *wl)
+static void wl1271_unregister_hw(struct wl1271 *wl)
{
if (wl->state == WL1271_STATE_PLT)
__wl1271_plt_stop(wl);
@@ -4729,9 +4727,8 @@ void wl1271_unregister_hw(struct wl1271 *wl)
wl->mac80211_registered = false;
}
-EXPORT_SYMBOL_GPL(wl1271_unregister_hw);
-int wl1271_init_ieee80211(struct wl1271 *wl)
+static int wl1271_init_ieee80211(struct wl1271 *wl)
{
static const u32 cipher_suites[] = {
WLAN_CIPHER_SUITE_WEP40,
@@ -4817,11 +4814,10 @@ int wl1271_init_ieee80211(struct wl1271 *wl)
return 0;
}
-EXPORT_SYMBOL_GPL(wl1271_init_ieee80211);
#define WL1271_DEFAULT_CHANNEL 0
-struct ieee80211_hw *wl1271_alloc_hw(void)
+static struct ieee80211_hw *wl1271_alloc_hw(void)
{
struct ieee80211_hw *hw;
struct platform_device *plat_dev = NULL;
@@ -5003,9 +4999,8 @@ err_hw_alloc:
return ERR_PTR(ret);
}
-EXPORT_SYMBOL_GPL(wl1271_alloc_hw);
-int wl1271_free_hw(struct wl1271 *wl)
+static int wl1271_free_hw(struct wl1271 *wl)
{
/* Unblock any fwlog readers */
mutex_lock(&wl->mutex);
@@ -5040,7 +5035,6 @@ int wl1271_free_hw(struct wl1271 *wl)
return 0;
}
-EXPORT_SYMBOL_GPL(wl1271_free_hw);
static irqreturn_t wl12xx_hardirq(int irq, void *cookie)
{
--
1.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 8/8] wl12xx: drop unneeded plat_dev
2011-10-06 19:10 [PATCH 0/8] wl12xx: forward ported Balbi's bus driver refactor Luciano Coelho
` (6 preceding siblings ...)
2011-10-06 19:10 ` [PATCH 7/8] wl12xx: mark some symbols static Luciano Coelho
@ 2011-10-06 19:10 ` Luciano Coelho
2011-10-11 13:05 ` [PATCH 0/8] wl12xx: forward ported Balbi's bus driver refactor Luciano Coelho
8 siblings, 0 replies; 10+ messages in thread
From: Luciano Coelho @ 2011-10-06 19:10 UTC (permalink / raw)
To: coelho; +Cc: linux-wireless
From: Felipe Balbi <balbi@ti.com>
now that useless plat_dev is unnecessary,
we can remove it.
Signed-off-by: Felipe Balbi <balbi@ti.com>
[forward ported and fixed sysfs file creation]
Signed-off-by: Luciano Coelho <coelho@ti.com>
---
Moved sysfs file creation to the end of the probe function instead of
doing it in the hw_alloc() function. It's too early to do it in
hw_alloc, because we don't have wl->dev at that point yet.
drivers/net/wireless/wl12xx/main.c | 104 ++++++++++------------------------
drivers/net/wireless/wl12xx/wl12xx.h | 1 -
2 files changed, 30 insertions(+), 75 deletions(-)
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index 18f87f0..63ff36c 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -382,22 +382,6 @@ static void __wl1271_op_remove_interface(struct wl1271 *wl,
bool reset_tx_queues);
static void wl1271_free_ap_keys(struct wl1271 *wl, struct wl12xx_vif *wlvif);
-
-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 DEFINE_MUTEX(wl_list_mutex);
static LIST_HEAD(wl_list);
@@ -4820,7 +4804,6 @@ static int wl1271_init_ieee80211(struct wl1271 *wl)
static struct ieee80211_hw *wl1271_alloc_hw(void)
{
struct ieee80211_hw *hw;
- struct platform_device *plat_dev = NULL;
struct wl1271 *wl;
int i, j, ret;
unsigned int order;
@@ -4834,20 +4817,12 @@ static struct ieee80211_hw *wl1271_alloc_hw(void)
goto err_hw_alloc;
}
- plat_dev = kmemdup(&wl1271_device, sizeof(wl1271_device), GFP_KERNEL);
- if (!plat_dev) {
- wl1271_error("could not allocate platform_device");
- ret = -ENOMEM;
- goto err_plat_alloc;
- }
-
wl = hw->priv;
memset(wl, 0, sizeof(*wl));
INIT_LIST_HEAD(&wl->list);
wl->hw = hw;
- wl->plat_dev = plat_dev;
for (i = 0; i < NUM_TX_QUEUES; i++)
skb_queue_head_init(&wl->tx_queue[i]);
@@ -4936,49 +4911,8 @@ static struct ieee80211_hw *wl1271_alloc_hw(void)
goto err_dummy_packet;
}
- /* Register platform device */
- ret = platform_device_register(wl->plat_dev);
- if (ret) {
- wl1271_error("couldn't register platform device");
- goto err_fwlog;
- }
- dev_set_drvdata(&wl->plat_dev->dev, wl);
-
- /* Create sysfs file to control bt coex state */
- ret = device_create_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state);
- if (ret < 0) {
- wl1271_error("failed to create sysfs file bt_coex_state");
- goto err_platform;
- }
-
- /* Create sysfs file to get HW PG version */
- ret = device_create_file(&wl->plat_dev->dev, &dev_attr_hw_pg_ver);
- if (ret < 0) {
- wl1271_error("failed to create sysfs file hw_pg_ver");
- goto err_bt_coex_state;
- }
-
- /* Create sysfs file for the FW log */
- ret = device_create_bin_file(&wl->plat_dev->dev, &fwlog_attr);
- if (ret < 0) {
- wl1271_error("failed to create sysfs file fwlog");
- goto err_hw_pg_ver;
- }
-
return hw;
-err_hw_pg_ver:
- device_remove_file(&wl->plat_dev->dev, &dev_attr_hw_pg_ver);
-
-err_bt_coex_state:
- device_remove_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state);
-
-err_platform:
- platform_device_unregister(wl->plat_dev);
-
-err_fwlog:
- free_page((unsigned long)wl->fwlog);
-
err_dummy_packet:
dev_kfree_skb(wl->dummy_packet);
@@ -4990,9 +4924,6 @@ err_wq:
err_hw:
wl1271_debugfs_exit(wl);
- kfree(plat_dev);
-
-err_plat_alloc:
ieee80211_free_hw(hw);
err_hw_alloc:
@@ -5008,17 +4939,15 @@ static int wl1271_free_hw(struct wl1271 *wl)
wake_up_interruptible_all(&wl->fwlog_waitq);
mutex_unlock(&wl->mutex);
- device_remove_bin_file(&wl->plat_dev->dev, &fwlog_attr);
+ device_remove_bin_file(wl->dev, &fwlog_attr);
- device_remove_file(&wl->plat_dev->dev, &dev_attr_hw_pg_ver);
+ device_remove_file(wl->dev, &dev_attr_hw_pg_ver);
- device_remove_file(&wl->plat_dev->dev, &dev_attr_bt_coex_state);
- platform_device_unregister(wl->plat_dev);
+ device_remove_file(wl->dev, &dev_attr_bt_coex_state);
free_page((unsigned long)wl->fwlog);
dev_kfree_skb(wl->dummy_packet);
free_pages((unsigned long)wl->aggr_buf,
get_order(WL1271_AGGR_BUFFER_SIZE));
- kfree(wl->plat_dev);
wl1271_debugfs_exit(wl);
@@ -5122,8 +5051,35 @@ static int __devinit wl12xx_probe(struct platform_device *pdev)
if (ret)
goto out_irq;
+ /* Create sysfs file to control bt coex state */
+ ret = device_create_file(wl->dev, &dev_attr_bt_coex_state);
+ if (ret < 0) {
+ wl1271_error("failed to create sysfs file bt_coex_state");
+ goto out_irq;
+ }
+
+ /* Create sysfs file to get HW PG version */
+ ret = device_create_file(wl->dev, &dev_attr_hw_pg_ver);
+ if (ret < 0) {
+ wl1271_error("failed to create sysfs file hw_pg_ver");
+ goto out_bt_coex_state;
+ }
+
+ /* Create sysfs file for the FW log */
+ ret = device_create_bin_file(wl->dev, &fwlog_attr);
+ if (ret < 0) {
+ wl1271_error("failed to create sysfs file fwlog");
+ goto out_hw_pg_ver;
+ }
+
return 0;
+out_hw_pg_ver:
+ device_remove_file(wl->dev, &dev_attr_hw_pg_ver);
+
+out_bt_coex_state:
+ device_remove_file(wl->dev, &dev_attr_bt_coex_state);
+
out_irq:
free_irq(wl->irq, wl);
diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h
index 091fdd2..bd58f50 100644
--- a/drivers/net/wireless/wl12xx/wl12xx.h
+++ b/drivers/net/wireless/wl12xx/wl12xx.h
@@ -350,7 +350,6 @@ struct wl1271_link {
};
struct wl1271 {
- struct platform_device *plat_dev;
struct ieee80211_hw *hw;
bool mac80211_registered;
--
1.7.1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 0/8] wl12xx: forward ported Balbi's bus driver refactor
2011-10-06 19:10 [PATCH 0/8] wl12xx: forward ported Balbi's bus driver refactor Luciano Coelho
` (7 preceding siblings ...)
2011-10-06 19:10 ` [PATCH 8/8] wl12xx: drop unneeded plat_dev Luciano Coelho
@ 2011-10-11 13:05 ` Luciano Coelho
8 siblings, 0 replies; 10+ messages in thread
From: Luciano Coelho @ 2011-10-11 13:05 UTC (permalink / raw)
To: linux-wireless
On Thu, 2011-10-06 at 22:10 +0300, Luciano Coelho wrote:
> Hi,
>
> Felipe sent this series of patches a long time ago with very good
> suggestion on how to avoid the duplicate code we have in the sdio and
> spi drivers.
>
> With this, we create a platform device that is handled by a platform
> driver. The bus-specific module, creates a platform device and the
> core module implements the driver that supports both platform devices
> (namely "wl12xx-sdio" and "wl12xx-spi").
>
> I didn't apply this earlier because I had concerns about the change in
> the platform data, but now I'm convinced it's not a real problem. It
> may affect compat-wireless, but it's easy to solve.
>
> I have now forward-ported the patches, fixed some bugs, removed some
> style changes and moved some other things around. For the changes I
> made, see the commit message of each patch. Some changes are not in
> the commit message, but are explained in the patch emails, after the
> Signed-off-by area.
>
> I'm keeping Felipe as the author, since most of the work is his. I
> have just tested and fixed it up.
>
> Cheers,
> Luca.
>
> Felipe Balbi (8):
> wl12xx: add an sdio glue struct to keep wl and device side-by-side
> wl12xx: add an spi glue struct to keep wl and device side-by-side
> wl12xx: add a platform device to the sdio module
> wl12xx: add a platform device to the spi module
> wl12xx: add platform driver to the core module
> wl12xx: move common init code from bus modules to main
> wl12xx: mark some symbols static
> wl12xx: drop unneeded plat_dev
Applied the whole series.
--
Cheers,
Luca.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-10-11 13:05 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 4/8] wl12xx: add a platform device to the spi module Luciano Coelho
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox