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

staging/wilc1000: pass struct wilc to most linux_wlan.c functions

We want to get rid of all global variables in this driver, and
instead pass device structures from one function to another.
This changes the linux_wlan.c and wilc_wlan.c to do this
for the most part. There are a few exceptions where these
functions are themselves called from another part of the driver
that does not have an instance pointer at hand. Changing those
would be a follow-up step.

There are a few other globals that will have to get moved
into struct wilc at a later point.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c94f05ee
...@@ -2905,7 +2905,7 @@ static int hostIFthread(void *pvArg) ...@@ -2905,7 +2905,7 @@ static int hostIFthread(void *pvArg)
del_timer(&hif_drv->scan_timer); del_timer(&hif_drv->scan_timer);
PRINT_D(HOSTINF_DBG, "scan completed successfully\n"); PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
if (!wilc_wlan_get_num_conn_ifcs()) if (!wilc_wlan_get_num_conn_ifcs(wilc_dev))
wilc_chip_sleep_manually(); wilc_chip_sleep_manually();
Handle_ScanDone(msg.drv, SCAN_EVENT_DONE); Handle_ScanDone(msg.drv, SCAN_EVENT_DONE);
......
...@@ -245,13 +245,14 @@ static void deinit_irq(struct net_device *dev) ...@@ -245,13 +245,14 @@ static void deinit_irq(struct net_device *dev)
} }
} }
void linux_wlan_dbg(u8 *buff) void wilc_dbg(struct wilc *wilc, u8 *buff)
{ {
PRINT_D(INIT_DBG, "%d\n", *buff); PRINT_D(INIT_DBG, "%d\n", *buff);
} }
int linux_wlan_lock_timeout(void *vp, u32 timeout) int wilc_lock_timeout(struct wilc *nic, void *vp, u32 timeout)
{ {
/* FIXME: replace with mutex_lock or wait_for_completion */
int error = -1; int error = -1;
PRINT_D(LOCK_DBG, "Locking %p\n", vp); PRINT_D(LOCK_DBG, "Locking %p\n", vp);
...@@ -263,7 +264,7 @@ int linux_wlan_lock_timeout(void *vp, u32 timeout) ...@@ -263,7 +264,7 @@ int linux_wlan_lock_timeout(void *vp, u32 timeout)
return error; return error;
} }
void linux_wlan_mac_indicate(struct wilc *wilc, int flag) void wilc_mac_indicate(struct wilc *wilc, int flag)
{ {
int status; int status;
...@@ -328,14 +329,14 @@ int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid) ...@@ -328,14 +329,14 @@ int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid)
return ret; return ret;
} }
int wilc_wlan_get_num_conn_ifcs(void) int wilc_wlan_get_num_conn_ifcs(struct wilc *wilc)
{ {
u8 i = 0; u8 i = 0;
u8 null_bssid[6] = {0}; u8 null_bssid[6] = {0};
u8 ret_val = 0; u8 ret_val = 0;
for (i = 0; i < wilc_dev->vif_num; i++) for (i = 0; i < wilc->vif_num; i++)
if (memcmp(wilc_dev->vif[i].bssid, null_bssid, 6)) if (memcmp(wilc->vif[i].bssid, null_bssid, 6))
ret_val++; ret_val++;
return ret_val; return ret_val;
...@@ -411,7 +412,7 @@ static int linux_wlan_txq_task(void *vp) ...@@ -411,7 +412,7 @@ static int linux_wlan_txq_task(void *vp)
return 0; return 0;
} }
void linux_wlan_rx_complete(void) void wilc_rx_complete(struct wilc *nic)
{ {
PRINT_D(RX_DBG, "RX completed\n"); PRINT_D(RX_DBG, "RX completed\n");
} }
...@@ -468,14 +469,14 @@ static int linux_wlan_start_firmware(struct net_device *dev) ...@@ -468,14 +469,14 @@ static int linux_wlan_start_firmware(struct net_device *dev)
wilc = nic->wilc; wilc = nic->wilc;
PRINT_D(INIT_DBG, "Starting Firmware ...\n"); PRINT_D(INIT_DBG, "Starting Firmware ...\n");
ret = wilc_wlan_start(); ret = wilc_wlan_start(wilc);
if (ret < 0) { if (ret < 0) {
PRINT_ER("Failed to start Firmware\n"); PRINT_ER("Failed to start Firmware\n");
return ret; return ret;
} }
PRINT_D(INIT_DBG, "Waiting for Firmware to get ready ...\n"); PRINT_D(INIT_DBG, "Waiting for Firmware to get ready ...\n");
ret = linux_wlan_lock_timeout(&wilc->sync_event, 5000); ret = wilc_lock_timeout(wilc, &wilc->sync_event, 5000);
if (ret) { if (ret) {
PRINT_D(INIT_DBG, "Firmware start timed out"); PRINT_D(INIT_DBG, "Firmware start timed out");
return ret; return ret;
...@@ -485,7 +486,7 @@ static int linux_wlan_start_firmware(struct net_device *dev) ...@@ -485,7 +486,7 @@ static int linux_wlan_start_firmware(struct net_device *dev)
return 0; return 0;
} }
static int linux_wlan_firmware_download(struct net_device *dev) static int wilc1000_firmware_download(struct net_device *dev)
{ {
perInterface_wlan_t *nic; perInterface_wlan_t *nic;
struct wilc *wilc; struct wilc *wilc;
...@@ -499,7 +500,7 @@ static int linux_wlan_firmware_download(struct net_device *dev) ...@@ -499,7 +500,7 @@ static int linux_wlan_firmware_download(struct net_device *dev)
return -ENOBUFS; return -ENOBUFS;
} }
PRINT_D(INIT_DBG, "Downloading Firmware ...\n"); PRINT_D(INIT_DBG, "Downloading Firmware ...\n");
ret = wilc_wlan_firmware_download(wilc->firmware->data, ret = wilc_wlan_firmware_download(wilc, wilc->firmware->data,
wilc->firmware->size); wilc->firmware->size);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -754,7 +755,7 @@ void wilc1000_wlan_deinit(struct net_device *dev) ...@@ -754,7 +755,7 @@ void wilc1000_wlan_deinit(struct net_device *dev)
PRINT_D(INIT_DBG, "Deinitializing IRQ\n"); PRINT_D(INIT_DBG, "Deinitializing IRQ\n");
deinit_irq(dev); deinit_irq(dev);
wilc_wlan_stop(); wilc_wlan_stop(wl);
PRINT_D(INIT_DBG, "Deinitializing WILC Wlan\n"); PRINT_D(INIT_DBG, "Deinitializing WILC Wlan\n");
wilc_wlan_cleanup(dev); wilc_wlan_cleanup(dev);
...@@ -914,7 +915,7 @@ int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic) ...@@ -914,7 +915,7 @@ int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic)
goto _fail_irq_enable_; goto _fail_irq_enable_;
} }
ret = linux_wlan_firmware_download(dev); ret = wilc1000_firmware_download(dev);
if (ret < 0) { if (ret < 0) {
PRINT_ER("Failed to download firmware\n"); PRINT_ER("Failed to download firmware\n");
ret = -EIO; ret = -EIO;
...@@ -952,7 +953,7 @@ int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic) ...@@ -952,7 +953,7 @@ int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic)
return 0; return 0;
_fail_fw_start_: _fail_fw_start_:
wilc_wlan_stop(); wilc_wlan_stop(wl);
_fail_irq_enable_: _fail_irq_enable_:
if (!wl->dev_irq_num && if (!wl->dev_irq_num &&
...@@ -985,6 +986,7 @@ static int mac_init_fn(struct net_device *ndev) ...@@ -985,6 +986,7 @@ static int mac_init_fn(struct net_device *ndev)
int wilc_mac_open(struct net_device *ndev) int wilc_mac_open(struct net_device *ndev)
{ {
perInterface_wlan_t *nic; perInterface_wlan_t *nic;
struct wilc *wilc;
unsigned char mac_add[ETH_ALEN] = {0}; unsigned char mac_add[ETH_ALEN] = {0};
int ret = 0; int ret = 0;
...@@ -1001,6 +1003,7 @@ int wilc_mac_open(struct net_device *ndev) ...@@ -1001,6 +1003,7 @@ int wilc_mac_open(struct net_device *ndev)
} }
nic = netdev_priv(ndev); nic = netdev_priv(ndev);
wilc = nic->wilc;
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);
...@@ -1314,7 +1317,7 @@ static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) ...@@ -1314,7 +1317,7 @@ static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
return ret; return ret;
} }
void frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset) void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset)
{ {
unsigned int frame_len = 0; unsigned int frame_len = 0;
int stats; int stats;
...@@ -1393,7 +1396,7 @@ void wilc_netdev_cleanup(struct wilc *wilc) ...@@ -1393,7 +1396,7 @@ void wilc_netdev_cleanup(struct wilc *wilc)
release_firmware(wilc->firmware); release_firmware(wilc->firmware);
if (wilc && (wilc->vif[0].ndev || wilc->vif[1].ndev)) { if (wilc && (wilc->vif[0].ndev || wilc->vif[1].ndev)) {
linux_wlan_lock_timeout(&close_exit_sync, 12 * 1000); wilc_lock_timeout(wilc, &close_exit_sync, 12 * 1000);
for (i = 0; i < NUM_CONCURRENT_IFC; i++) for (i = 0; i < NUM_CONCURRENT_IFC; i++)
if (wilc->vif[i].ndev) if (wilc->vif[i].ndev)
...@@ -1417,17 +1420,18 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, ...@@ -1417,17 +1420,18 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
int i; int i;
perInterface_wlan_t *nic; perInterface_wlan_t *nic;
struct net_device *ndev; struct net_device *ndev;
struct wilc *wl;
sema_init(&close_exit_sync, 0); sema_init(&close_exit_sync, 0);
wilc_dev = kzalloc(sizeof(*wilc_dev), GFP_KERNEL); wl = kzalloc(sizeof(*wilc_dev), GFP_KERNEL);
if (!wilc_dev) if (!wl)
return -ENOMEM; return -ENOMEM;
*wilc = wilc_dev; *wilc = wl;
wilc_dev->io_type = io_type; wl->io_type = io_type;
wilc_dev->gpio = gpio; wl->gpio = gpio;
wilc_dev->ops = ops; wl->ops = ops;
register_inetaddr_notifier(&g_dev_notifier); register_inetaddr_notifier(&g_dev_notifier);
...@@ -1446,11 +1450,11 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, ...@@ -1446,11 +1450,11 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
else else
strcpy(ndev->name, "p2p%d"); strcpy(ndev->name, "p2p%d");
nic->u8IfIdx = wilc_dev->vif_num; nic->u8IfIdx = wl->vif_num;
nic->wilc_netdev = ndev; nic->wilc_netdev = ndev;
nic->wilc = *wilc; nic->wilc = *wilc;
wilc_dev->vif[wilc_dev->vif_num].ndev = ndev; wl->vif[wl->vif_num].ndev = ndev;
wilc_dev->vif_num++; wl->vif_num++;
ndev->netdev_ops = &wilc_netdev_ops; ndev->netdev_ops = &wilc_netdev_ops;
{ {
...@@ -1483,6 +1487,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, ...@@ -1483,6 +1487,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
nic->iftype = STATION_MODE; nic->iftype = STATION_MODE;
nic->mac_opened = 0; nic->mac_opened = 0;
} }
wilc_dev = *wilc = wl;
return 0; return 0;
} }
......
...@@ -207,11 +207,12 @@ int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic); ...@@ -207,11 +207,12 @@ int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
extern struct wilc *wilc_dev; extern struct wilc *wilc_dev;
extern struct net_device *WILC_WFI_devs[]; extern struct net_device *WILC_WFI_devs[];
void frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset); void wilc_frmw_to_linux(struct wilc *wilc, u8 *buff, u32 size, u32 pkt_offset);
void linux_wlan_mac_indicate(struct wilc *wilc, int flag); void wilc_mac_indicate(struct wilc *wilc, int flag);
void linux_wlan_rx_complete(void); void wilc_rx_complete(struct wilc *wilc);
void linux_wlan_dbg(u8 *buff); void wilc_dbg(struct wilc *, u8 *buff);
int linux_wlan_lock_timeout(void *vp, u32 timeout);
int wilc_lock_timeout(struct wilc *wilc, void *, u32 timeout);
void wilc_netdev_cleanup(struct wilc *wilc); void wilc_netdev_cleanup(struct wilc *wilc);
int wilc_netdev_init(struct wilc **wilc, struct device *, int io_type, int gpio, int wilc_netdev_init(struct wilc **wilc, struct device *, int io_type, int gpio,
const struct wilc_hif_func *ops); const struct wilc_hif_func *ops);
...@@ -220,4 +221,5 @@ void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size); ...@@ -220,4 +221,5 @@ void WILC_WFI_mgmt_rx(struct wilc *wilc, u8 *buff, u32 size);
u16 wilc_set_machw_change_vir_if(struct net_device *dev, bool value); u16 wilc_set_machw_change_vir_if(struct net_device *dev, bool value);
int wilc_wlan_get_firmware(struct net_device *dev); int wilc_wlan_get_firmware(struct net_device *dev);
int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid); int wilc_wlan_set_bssid(struct net_device *wilc_netdev, u8 *bssid);
#endif #endif
This diff is collapsed.
...@@ -283,13 +283,13 @@ struct wilc_cfg_rsp { ...@@ -283,13 +283,13 @@ struct wilc_cfg_rsp {
struct wilc; struct wilc;
int wilc_wlan_firmware_download(const u8 *buffer, u32 buffer_size); int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, u32 buffer_size);
int wilc_wlan_start(void); int wilc_wlan_start(struct wilc *);
int wilc_wlan_stop(void); int wilc_wlan_stop(struct wilc *);
int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer, int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer,
u32 buffer_size, wilc_tx_complete_func_t func); u32 buffer_size, wilc_tx_complete_func_t func);
int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count); int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count);
void wilc_handle_isr(void *wilc); void wilc_handle_isr(struct wilc *wilc);
void wilc_wlan_cleanup(struct net_device *dev); void wilc_wlan_cleanup(struct net_device *dev);
int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size, int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size,
int commit, u32 drv_handler); int commit, u32 drv_handler);
...@@ -300,7 +300,7 @@ int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, ...@@ -300,7 +300,7 @@ int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer,
void wilc_chip_sleep_manually(void); void wilc_chip_sleep_manually(void);
void wilc_enable_tcp_ack_filter(bool value); void wilc_enable_tcp_ack_filter(bool value);
int wilc_wlan_get_num_conn_ifcs(void); int wilc_wlan_get_num_conn_ifcs(struct wilc *);
int wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev); int wilc_mac_xmit(struct sk_buff *skb, struct net_device *dev);
int wilc_mac_open(struct net_device *ndev); int wilc_mac_open(struct net_device *ndev);
......
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