Commit 6bcba96e authored by Ajay Singh's avatar Ajay Singh Committed by Greg Kroah-Hartman

staging: wilc1000: move variable assignment along with its declaration

Cleanup patch to club the variable assignment along with the variable
declaration especially for private data.
Signed-off-by: default avatarAjay Singh <ajay.kathat@microchip.com>
Reviewed-by: default avatarClaudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent cd46d1b1
...@@ -3429,13 +3429,10 @@ static void get_periodic_rssi(struct timer_list *unused) ...@@ -3429,13 +3429,10 @@ static void get_periodic_rssi(struct timer_list *unused)
int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler) int wilc_init(struct net_device *dev, struct host_if_drv **hif_drv_handler)
{ {
struct host_if_drv *hif_drv; struct host_if_drv *hif_drv;
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc; struct wilc *wilc = vif->wilc;
int i; int i;
vif = netdev_priv(dev);
wilc = vif->wilc;
hif_drv = kzalloc(sizeof(*hif_drv), GFP_KERNEL); hif_drv = kzalloc(sizeof(*hif_drv), GFP_KERNEL);
if (!hif_drv) if (!hif_drv)
return -ENOMEM; return -ENOMEM;
......
...@@ -94,12 +94,9 @@ static int dev_state_ev_handler(struct notifier_block *this, ...@@ -94,12 +94,9 @@ static int dev_state_ev_handler(struct notifier_block *this,
static irqreturn_t isr_uh_routine(int irq, void *user_data) static irqreturn_t isr_uh_routine(int irq, void *user_data)
{ {
struct wilc_vif *vif;
struct wilc *wilc;
struct net_device *dev = user_data; struct net_device *dev = user_data;
struct wilc_vif *vif = netdev_priv(dev);
vif = netdev_priv(dev); struct wilc *wilc = vif->wilc;
wilc = vif->wilc;
if (wilc->close) { if (wilc->close) {
netdev_err(dev, "Can't handle UH interrupt\n"); netdev_err(dev, "Can't handle UH interrupt\n");
...@@ -110,12 +107,9 @@ static irqreturn_t isr_uh_routine(int irq, void *user_data) ...@@ -110,12 +107,9 @@ static irqreturn_t isr_uh_routine(int irq, void *user_data)
static irqreturn_t isr_bh_routine(int irq, void *userdata) static irqreturn_t isr_bh_routine(int irq, void *userdata)
{ {
struct wilc_vif *vif;
struct wilc *wilc;
struct net_device *dev = userdata; struct net_device *dev = userdata;
struct wilc_vif *vif = netdev_priv(userdata);
vif = netdev_priv(userdata); struct wilc *wilc = vif->wilc;
wilc = vif->wilc;
if (wilc->close) { if (wilc->close) {
netdev_err(dev, "Can't handle BH interrupt\n"); netdev_err(dev, "Can't handle BH interrupt\n");
...@@ -130,11 +124,8 @@ static irqreturn_t isr_bh_routine(int irq, void *userdata) ...@@ -130,11 +124,8 @@ static irqreturn_t isr_bh_routine(int irq, void *userdata)
static int init_irq(struct net_device *dev) static int init_irq(struct net_device *dev)
{ {
int ret = 0; int ret = 0;
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wl; struct wilc *wl = vif->wilc;
vif = netdev_priv(dev);
wl = vif->wilc;
if ((gpio_request(wl->gpio, "WILC_INTR") == 0) && if ((gpio_request(wl->gpio, "WILC_INTR") == 0) &&
(gpio_direction_input(wl->gpio) == 0)) { (gpio_direction_input(wl->gpio) == 0)) {
...@@ -163,11 +154,8 @@ static int init_irq(struct net_device *dev) ...@@ -163,11 +154,8 @@ static int init_irq(struct net_device *dev)
static void deinit_irq(struct net_device *dev) static void deinit_irq(struct net_device *dev)
{ {
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc; struct wilc *wilc = vif->wilc;
vif = netdev_priv(dev);
wilc = vif->wilc;
/* Deinitialize IRQ */ /* Deinitialize IRQ */
if (wilc->dev_irq_num) { if (wilc->dev_irq_num) {
...@@ -238,12 +226,9 @@ static int linux_wlan_txq_task(void *vp) ...@@ -238,12 +226,9 @@ static int linux_wlan_txq_task(void *vp)
{ {
int ret; int ret;
u32 txq_count; u32 txq_count;
struct wilc_vif *vif;
struct wilc *wl;
struct net_device *dev = vp; struct net_device *dev = vp;
struct wilc_vif *vif = netdev_priv(dev);
vif = netdev_priv(dev); struct wilc *wl = vif->wilc;
wl = vif->wilc;
complete(&wl->txq_thread_started); complete(&wl->txq_thread_started);
while (1) { while (1) {
...@@ -271,15 +256,12 @@ static int linux_wlan_txq_task(void *vp) ...@@ -271,15 +256,12 @@ static int linux_wlan_txq_task(void *vp)
static int wilc_wlan_get_firmware(struct net_device *dev) static int wilc_wlan_get_firmware(struct net_device *dev)
{ {
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc; struct wilc *wilc = vif->wilc;
int chip_id, ret = 0; int chip_id, ret = 0;
const struct firmware *wilc_firmware; const struct firmware *wilc_firmware;
char *firmware; char *firmware;
vif = netdev_priv(dev);
wilc = vif->wilc;
chip_id = wilc_get_chipid(wilc, false); chip_id = wilc_get_chipid(wilc, false);
if (chip_id < 0x1003a0) if (chip_id < 0x1003a0)
...@@ -306,13 +288,10 @@ static int wilc_wlan_get_firmware(struct net_device *dev) ...@@ -306,13 +288,10 @@ static int wilc_wlan_get_firmware(struct net_device *dev)
static int linux_wlan_start_firmware(struct net_device *dev) static int linux_wlan_start_firmware(struct net_device *dev)
{ {
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc; struct wilc *wilc = vif->wilc;
int ret = 0; int ret = 0;
vif = netdev_priv(dev);
wilc = vif->wilc;
ret = wilc_wlan_start(wilc); ret = wilc_wlan_start(wilc);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -326,13 +305,10 @@ static int linux_wlan_start_firmware(struct net_device *dev) ...@@ -326,13 +305,10 @@ static int linux_wlan_start_firmware(struct net_device *dev)
static int wilc1000_firmware_download(struct net_device *dev) static int wilc1000_firmware_download(struct net_device *dev)
{ {
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc; struct wilc *wilc = vif->wilc;
int ret = 0; int ret = 0;
vif = netdev_priv(dev);
wilc = vif->wilc;
if (!wilc->firmware) { if (!wilc->firmware) {
netdev_err(dev, "Firmware buffer is NULL\n"); netdev_err(dev, "Firmware buffer is NULL\n");
return -ENOBUFS; return -ENOBUFS;
...@@ -560,11 +536,8 @@ static int linux_wlan_init_test_config(struct net_device *dev, ...@@ -560,11 +536,8 @@ static int linux_wlan_init_test_config(struct net_device *dev,
static int wlan_deinit_locks(struct net_device *dev) static int wlan_deinit_locks(struct net_device *dev)
{ {
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc; struct wilc *wilc = vif->wilc;
vif = netdev_priv(dev);
wilc = vif->wilc;
mutex_destroy(&wilc->hif_cs); mutex_destroy(&wilc->hif_cs);
mutex_destroy(&wilc->rxq_cs); mutex_destroy(&wilc->rxq_cs);
...@@ -575,11 +548,8 @@ static int wlan_deinit_locks(struct net_device *dev) ...@@ -575,11 +548,8 @@ static int wlan_deinit_locks(struct net_device *dev)
static void wlan_deinitialize_threads(struct net_device *dev) static void wlan_deinitialize_threads(struct net_device *dev)
{ {
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wl; struct wilc *wl = vif->wilc;
vif = netdev_priv(dev);
wl = vif->wilc;
wl->close = 1; wl->close = 1;
...@@ -593,11 +563,8 @@ static void wlan_deinitialize_threads(struct net_device *dev) ...@@ -593,11 +563,8 @@ static void wlan_deinitialize_threads(struct net_device *dev)
static void wilc_wlan_deinitialize(struct net_device *dev) static void wilc_wlan_deinitialize(struct net_device *dev)
{ {
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wl; struct wilc *wl = vif->wilc;
vif = netdev_priv(dev);
wl = vif->wilc;
if (!wl) { if (!wl) {
netdev_err(dev, "wl is NULL\n"); netdev_err(dev, "wl is NULL\n");
...@@ -632,11 +599,8 @@ static void wilc_wlan_deinitialize(struct net_device *dev) ...@@ -632,11 +599,8 @@ static void wilc_wlan_deinitialize(struct net_device *dev)
static int wlan_init_locks(struct net_device *dev) static int wlan_init_locks(struct net_device *dev)
{ {
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wl; struct wilc *wl = vif->wilc;
vif = netdev_priv(dev);
wl = vif->wilc;
mutex_init(&wl->hif_cs); mutex_init(&wl->hif_cs);
mutex_init(&wl->rxq_cs); mutex_init(&wl->rxq_cs);
...@@ -655,11 +619,8 @@ static int wlan_init_locks(struct net_device *dev) ...@@ -655,11 +619,8 @@ static int wlan_init_locks(struct net_device *dev)
static int wlan_initialize_threads(struct net_device *dev) static int wlan_initialize_threads(struct net_device *dev)
{ {
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc; struct wilc *wilc = vif->wilc;
vif = netdev_priv(dev);
wilc = vif->wilc;
wilc->txq_thread = kthread_run(linux_wlan_txq_task, (void *)dev, wilc->txq_thread = kthread_run(linux_wlan_txq_task, (void *)dev,
"K_TXQ_TASK"); "K_TXQ_TASK");
...@@ -779,14 +740,11 @@ static int mac_init_fn(struct net_device *ndev) ...@@ -779,14 +740,11 @@ static int mac_init_fn(struct net_device *ndev)
static int wilc_mac_open(struct net_device *ndev) static int wilc_mac_open(struct net_device *ndev)
{ {
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(ndev);
struct wilc *wl = vif->wilc;
unsigned char mac_add[ETH_ALEN] = {0}; unsigned char mac_add[ETH_ALEN] = {0};
int ret = 0; int ret = 0;
int i = 0; int i = 0;
struct wilc *wl;
vif = netdev_priv(ndev);
wl = vif->wilc;
if (!wl || !wl->dev) { if (!wl || !wl->dev) {
netdev_err(ndev, "device not ready\n"); netdev_err(ndev, "device not ready\n");
...@@ -850,11 +808,9 @@ static struct net_device_stats *mac_stats(struct net_device *dev) ...@@ -850,11 +808,9 @@ static struct net_device_stats *mac_stats(struct net_device *dev)
static void wilc_set_multicast_list(struct net_device *dev) static void wilc_set_multicast_list(struct net_device *dev)
{ {
struct netdev_hw_addr *ha; struct netdev_hw_addr *ha;
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
int i = 0; int i = 0;
vif = netdev_priv(dev);
if (dev->flags & IFF_PROMISC) if (dev->flags & IFF_PROMISC)
return; return;
...@@ -894,16 +850,13 @@ static void linux_wlan_tx_complete(void *priv, int status) ...@@ -894,16 +850,13 @@ static void linux_wlan_tx_complete(void *priv, int status)
netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev)
{ {
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(ndev);
struct wilc *wilc = vif->wilc;
struct tx_complete_data *tx_data = NULL; struct tx_complete_data *tx_data = NULL;
int queue_count; int queue_count;
char *udp_buf; char *udp_buf;
struct iphdr *ih; struct iphdr *ih;
struct ethhdr *eth_h; struct ethhdr *eth_h;
struct wilc *wilc;
vif = netdev_priv(ndev);
wilc = vif->wilc;
if (skb->dev != ndev) { if (skb->dev != ndev) {
netdev_err(ndev, "Packet not destined to this device\n"); netdev_err(ndev, "Packet not destined to this device\n");
...@@ -951,12 +904,10 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev) ...@@ -951,12 +904,10 @@ netdev_tx_t wilc_mac_xmit(struct sk_buff *skb, struct net_device *ndev)
static int wilc_mac_close(struct net_device *ndev) static int wilc_mac_close(struct net_device *ndev)
{ {
struct wilc_priv *priv; struct wilc_priv *priv;
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(ndev);
struct host_if_drv *hif_drv; struct host_if_drv *hif_drv;
struct wilc *wl; struct wilc *wl;
vif = netdev_priv(ndev);
if (!vif || !vif->ndev || !vif->ndev->ieee80211_ptr || if (!vif || !vif->ndev || !vif->ndev->ieee80211_ptr ||
!vif->ndev->ieee80211_ptr->wiphy) !vif->ndev->ieee80211_ptr->wiphy)
return 0; return 0;
......
...@@ -31,11 +31,8 @@ wilc_wlan_txq_remove_from_head(struct net_device *dev) ...@@ -31,11 +31,8 @@ wilc_wlan_txq_remove_from_head(struct net_device *dev)
{ {
struct txq_entry_t *tqe = NULL; struct txq_entry_t *tqe = NULL;
unsigned long flags; unsigned long flags;
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc; struct wilc *wilc = vif->wilc;
vif = netdev_priv(dev);
wilc = vif->wilc;
spin_lock_irqsave(&wilc->txq_spinlock, flags); spin_lock_irqsave(&wilc->txq_spinlock, flags);
...@@ -53,11 +50,8 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev, ...@@ -53,11 +50,8 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev,
struct txq_entry_t *tqe) struct txq_entry_t *tqe)
{ {
unsigned long flags; unsigned long flags;
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc; struct wilc *wilc = vif->wilc;
vif = netdev_priv(dev);
wilc = vif->wilc;
spin_lock_irqsave(&wilc->txq_spinlock, flags); spin_lock_irqsave(&wilc->txq_spinlock, flags);
...@@ -156,11 +150,8 @@ static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) ...@@ -156,11 +150,8 @@ static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe)
const struct ethhdr *eth_hdr_ptr = buffer; const struct ethhdr *eth_hdr_ptr = buffer;
int i; int i;
unsigned long flags; unsigned long flags;
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc; struct wilc *wilc = vif->wilc;
vif = netdev_priv(dev);
wilc = vif->wilc;
spin_lock_irqsave(&wilc->txq_spinlock, flags); spin_lock_irqsave(&wilc->txq_spinlock, flags);
...@@ -202,15 +193,12 @@ static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe) ...@@ -202,15 +193,12 @@ static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe)
static int wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev) static int wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev)
{ {
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc; struct wilc *wilc = vif->wilc;
u32 i = 0; u32 i = 0;
u32 dropped = 0; u32 dropped = 0;
unsigned long flags; unsigned long flags;
vif = netdev_priv(dev);
wilc = vif->wilc;
spin_lock_irqsave(&wilc->txq_spinlock, flags); spin_lock_irqsave(&wilc->txq_spinlock, flags);
for (i = pending_base; i < (pending_base + pending_acks); i++) { for (i = pending_base; i < (pending_base + pending_acks); i++) {
u32 session_index; u32 session_index;
...@@ -511,7 +499,6 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) ...@@ -511,7 +499,6 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
int i, entries = 0; int i, entries = 0;
u32 sum; u32 sum;
u32 reg; u32 reg;
u8 *txb;
u32 offset = 0; u32 offset = 0;
int vmm_sz = 0; int vmm_sz = 0;
struct txq_entry_t *tqe; struct txq_entry_t *tqe;
...@@ -519,14 +506,10 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count) ...@@ -519,14 +506,10 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
int counter; int counter;
int timeout; int timeout;
u32 vmm_table[WILC_VMM_TBL_SIZE]; u32 vmm_table[WILC_VMM_TBL_SIZE];
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc; struct wilc *wilc = vif->wilc;
const struct wilc_hif_func *func; const struct wilc_hif_func *func;
u8 *txb = wilc->tx_buffer;
vif = netdev_priv(dev);
wilc = vif->wilc;
txb = wilc->tx_buffer;
if (wilc->quit) if (wilc->quit)
goto out; goto out;
...@@ -1081,11 +1064,8 @@ void wilc_wlan_cleanup(struct net_device *dev) ...@@ -1081,11 +1064,8 @@ void wilc_wlan_cleanup(struct net_device *dev)
struct rxq_entry_t *rqe; struct rxq_entry_t *rqe;
u32 reg = 0; u32 reg = 0;
int ret; int ret;
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc; struct wilc *wilc = vif->wilc;
vif = netdev_priv(dev);
wilc = vif->wilc;
wilc->quit = 1; wilc->quit = 1;
do { do {
...@@ -1281,11 +1261,8 @@ static u32 init_chip(struct net_device *dev) ...@@ -1281,11 +1261,8 @@ static u32 init_chip(struct net_device *dev)
{ {
u32 chipid; u32 chipid;
u32 reg, ret = 0; u32 reg, ret = 0;
struct wilc_vif *vif; struct wilc_vif *vif = netdev_priv(dev);
struct wilc *wilc; struct wilc *wilc = vif->wilc;
vif = netdev_priv(dev);
wilc = vif->wilc;
acquire_bus(wilc, ACQUIRE_ONLY); acquire_bus(wilc, ACQUIRE_ONLY);
......
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