Commit b03314e2 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Greg Kroah-Hartman

staging/wilc1000: unify device pointer

struct wilc has two pointers to store the device, one for sdio_func
and one for spi_device. By changing the pointer to a 'struct device',
we can simplify the logic and avoid a few #ifdefs.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 857c7b00
...@@ -453,19 +453,11 @@ int wilc_wlan_get_firmware(struct net_device *dev) ...@@ -453,19 +453,11 @@ int wilc_wlan_get_firmware(struct net_device *dev)
goto _fail_; goto _fail_;
} }
#ifdef WILC_SDIO if (request_firmware(&wilc_firmware, firmware, wilc->dev) != 0) {
if (request_firmware(&wilc_firmware, firmware, &wilc->wilc_sdio_func->dev) != 0) {
PRINT_ER("%s - firmare not available\n", firmware); PRINT_ER("%s - firmare not available\n", firmware);
ret = -1; ret = -1;
goto _fail_; goto _fail_;
} }
#else
if (request_firmware(&wilc_firmware, firmware, &wilc->wilc_spidev->dev) != 0) {
PRINT_ER("%s - firmare not available\n", firmware);
ret = -1;
goto _fail_;
}
#endif
wilc->firmware = wilc_firmware; wilc->firmware = wilc_firmware;
_fail_: _fail_:
...@@ -1015,12 +1007,11 @@ int wilc_mac_open(struct net_device *ndev) ...@@ -1015,12 +1007,11 @@ int wilc_mac_open(struct net_device *ndev)
nic = netdev_priv(ndev); nic = netdev_priv(ndev);
wl = nic->wilc; wl = nic->wilc;
#ifdef WILC_SPI if (!wl|| !wl->dev) {
if (!wl || !wl->wilc_spidev) {
netdev_err(ndev, "wilc1000: SPI device not ready\n"); netdev_err(ndev, "wilc1000: SPI device not ready\n");
return -ENODEV; return -ENODEV;
} }
#endif
nic = netdev_priv(ndev); nic = netdev_priv(ndev);
priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy); priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy);
PRINT_D(INIT_DBG, "MAC OPEN[%p]\n", ndev); PRINT_D(INIT_DBG, "MAC OPEN[%p]\n", ndev);
...@@ -1505,15 +1496,5 @@ int wilc_netdev_init(struct wilc **wilc) ...@@ -1505,15 +1496,5 @@ int wilc_netdev_init(struct wilc **wilc)
nic->mac_opened = 0; nic->mac_opened = 0;
} }
#ifndef WILC_SDIO
if (!wilc_spi_init()) {
PRINT_ER("Can't initialize SPI\n");
return -1;
}
wilc_dev->wilc_spidev = wilc_spi_dev;
#else
wilc_dev->wilc_sdio_func = wilc_sdio_func;
#endif
return 0; return 0;
} }
...@@ -21,13 +21,7 @@ ...@@ -21,13 +21,7 @@
#define MAX_SPEED (6 * 1000000) /* Max 50M */ #define MAX_SPEED (6 * 1000000) /* Max 50M */
#endif #endif
struct wilc_sdio {
struct sdio_func *func;
struct wilc *wilc;
};
struct sdio_func *wilc_sdio_func; struct sdio_func *wilc_sdio_func;
static unsigned int sdio_default_speed; static unsigned int sdio_default_speed;
#define SDIO_VENDOR_ID_WILC 0x0296 #define SDIO_VENDOR_ID_WILC 0x0296
...@@ -42,12 +36,8 @@ static const struct sdio_device_id wilc_sdio_ids[] = { ...@@ -42,12 +36,8 @@ static const struct sdio_device_id wilc_sdio_ids[] = {
#ifndef WILC_SDIO_IRQ_GPIO #ifndef WILC_SDIO_IRQ_GPIO
static void wilc_sdio_interrupt(struct sdio_func *func) static void wilc_sdio_interrupt(struct sdio_func *func)
{ {
struct wilc_sdio *wl_sdio;
wl_sdio = sdio_get_drvdata(func);
sdio_release_host(func); sdio_release_host(func);
wilc_handle_isr(wl_sdio->wilc); wilc_handle_isr(sdio_get_drvdata(func));
sdio_claim_host(func); sdio_claim_host(func);
} }
#endif #endif
...@@ -55,7 +45,7 @@ static void wilc_sdio_interrupt(struct sdio_func *func) ...@@ -55,7 +45,7 @@ static void wilc_sdio_interrupt(struct sdio_func *func)
int wilc_sdio_cmd52(sdio_cmd52_t *cmd) int wilc_sdio_cmd52(sdio_cmd52_t *cmd)
{ {
struct sdio_func *func = wilc_dev->wilc_sdio_func; struct sdio_func *func = container_of(wilc_dev->dev, struct sdio_func, dev);
int ret; int ret;
u8 data; u8 data;
...@@ -87,7 +77,7 @@ int wilc_sdio_cmd52(sdio_cmd52_t *cmd) ...@@ -87,7 +77,7 @@ int wilc_sdio_cmd52(sdio_cmd52_t *cmd)
int wilc_sdio_cmd53(sdio_cmd53_t *cmd) int wilc_sdio_cmd53(sdio_cmd53_t *cmd)
{ {
struct sdio_func *func = wilc_dev->wilc_sdio_func; struct sdio_func *func = container_of(wilc_dev->dev, struct sdio_func, dev);
int size, ret; int size, ret;
sdio_claim_host(func); sdio_claim_host(func);
...@@ -118,24 +108,17 @@ int wilc_sdio_cmd53(sdio_cmd53_t *cmd) ...@@ -118,24 +108,17 @@ int wilc_sdio_cmd53(sdio_cmd53_t *cmd)
static int linux_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id) static int linux_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id)
{ {
struct wilc_sdio *wl_sdio;
struct wilc *wilc; struct wilc *wilc;
PRINT_D(INIT_DBG, "probe function\n");
wl_sdio = kzalloc(sizeof(struct wilc_sdio), GFP_KERNEL);
if (!wl_sdio)
return -ENOMEM;
PRINT_D(INIT_DBG, "Initializing netdev\n"); PRINT_D(INIT_DBG, "Initializing netdev\n");
wilc_sdio_func = func; wilc_sdio_func = func;
if (wilc_netdev_init(&wilc)) { if (wilc_netdev_init(&wilc)) {
PRINT_ER("Couldn't initialize netdev\n"); PRINT_ER("Couldn't initialize netdev\n");
kfree(wl_sdio);
return -1; return -1;
} }
wl_sdio->func = func; sdio_set_drvdata(func, wilc);
wl_sdio->wilc = wilc; wilc->dev = &func->dev;
sdio_set_drvdata(func, wl_sdio);
printk("Driver Initializing success\n"); printk("Driver Initializing success\n");
return 0; return 0;
...@@ -143,11 +126,7 @@ static int linux_sdio_probe(struct sdio_func *func, const struct sdio_device_id ...@@ -143,11 +126,7 @@ static int linux_sdio_probe(struct sdio_func *func, const struct sdio_device_id
static void linux_sdio_remove(struct sdio_func *func) static void linux_sdio_remove(struct sdio_func *func)
{ {
struct wilc_sdio *wl_sdio; wilc_netdev_cleanup(sdio_get_drvdata(func));
wl_sdio = sdio_get_drvdata(func);
wilc_netdev_cleanup(wl_sdio->wilc);
kfree(wl_sdio);
} }
static struct sdio_driver wilc_bus = { static struct sdio_driver wilc_bus = {
......
...@@ -9,9 +9,10 @@ ...@@ -9,9 +9,10 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include "wilc_wfi_netdevice.h"
#include "linux_wlan_common.h" #include "linux_wlan_common.h"
#include "linux_wlan_spi.h" #include "linux_wlan_spi.h"
#include "wilc_wfi_netdevice.h" #include "wilc_wlan_if.h"
#define USE_SPI_DMA 0 /* johnny add */ #define USE_SPI_DMA 0 /* johnny add */
...@@ -399,8 +400,25 @@ static struct wilc *wilc; ...@@ -399,8 +400,25 @@ static struct wilc *wilc;
static int __init init_wilc_spi_driver(void) static int __init init_wilc_spi_driver(void)
{ {
int ret;
wilc_debugfs_init(); wilc_debugfs_init();
return wilc_netdev_init(&wilc);
ret = wilc_netdev_init(&wilc);
if (ret) {
wilc_debugfs_remove();
return ret;
}
if (!wilc_spi_init() || !wilc_spi_dev) {
PRINT_ER("Can't initialize SPI\n");
wilc_netdev_cleanup(wilc);
wilc_debugfs_remove();
return -ENXIO;
}
wilc_dev->dev = &wilc_spi_dev->dev;
return ret;
} }
late_initcall(init_wilc_spi_driver); late_initcall(init_wilc_spi_driver);
......
...@@ -185,11 +185,7 @@ struct wilc { ...@@ -185,11 +185,7 @@ struct wilc {
const struct firmware *firmware; const struct firmware *firmware;
#ifdef WILC_SDIO struct device *dev;
struct sdio_func *wilc_sdio_func;
#else
struct spi_device *wilc_spidev;
#endif
}; };
typedef struct { typedef struct {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment