staging: wilc1000: remove pointless kfree wrapper
[cascardo/linux.git] / drivers / staging / wilc1000 / linux_wlan.c
index b3cc9f5..c1289e0 100644 (file)
@@ -152,7 +152,6 @@ void linux_wlan_unlock(void *vp);
 extern void WILC_WFI_monitor_rx(uint8_t *buff, uint32_t size);
 extern void WILC_WFI_p2p_rx(struct net_device *dev, uint8_t *buff, uint32_t size);
 
-static void *internal_alloc(uint32_t size, uint32_t flag);
 static void linux_wlan_tx_complete(void *priv, int status);
 void frmw_to_linux(uint8_t *buff, uint32_t size, uint32_t pkt_offset);
 static int  mac_init_fn(struct net_device *ndev);
@@ -194,6 +193,7 @@ static char *ps8current = DebugBuffer;
 void printk_later(const char *format, ...)
 {
        va_list args;
+
        va_start(args, format);
        ps8current += vsprintf(ps8current, format, args);
        va_end(args);
@@ -402,11 +402,13 @@ static irqreturn_t isr_uh_routine(int irq, void *user_data)
 irqreturn_t isr_bh_routine(int irq, void *userdata)
 {
        linux_wlan_t *nic;
+
        nic = (linux_wlan_t *)userdata;
 #else
 static void isr_bh_routine(struct work_struct *work)
 {
        perInterface_wlan_t *nic;
+
        nic = (perInterface_wlan_t *)container_of(work, linux_wlan_t, rx_work_queue);
 #endif
 
@@ -531,6 +533,7 @@ static void linux_wlan_msleep(uint32_t msc)
 {
        if (msc <= 4000000) {
                u32 u32Temp = msc * 1000;
+
                usleep_range(u32Temp, u32Temp);
        } else {
                msleep(msc);
@@ -546,38 +549,6 @@ static void linux_wlan_dbg(uint8_t *buff)
        PRINT_D(INIT_DBG, "%d\n", *buff);
 }
 
-static void *linux_wlan_malloc_atomic(uint32_t sz)
-{
-       char *pntr = NULL;
-       pntr = kmalloc(sz, GFP_ATOMIC);
-       PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", sz, pntr);
-       return (void *)pntr;
-
-}
-static void *linux_wlan_malloc(uint32_t sz)
-{
-       char *pntr = NULL;
-       pntr = kmalloc(sz, GFP_KERNEL);
-       PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", sz, pntr);
-       return (void *)pntr;
-}
-
-void linux_wlan_free(void *vp)
-{
-       if (vp != NULL) {
-               PRINT_D(MEM_DBG, "Freeing %p\n", vp);
-               kfree(vp);
-       }
-}
-
-static void *internal_alloc(uint32_t size, uint32_t flag)
-{
-       char *pntr = NULL;
-       pntr = kmalloc(size, flag);
-       PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", size, pntr);
-       return (void *)pntr;
-}
-
 static void linux_wlan_init_lock(char *lockName, void *plock, int count)
 {
        sema_init((struct semaphore *)plock, count);
@@ -604,6 +575,7 @@ static void linux_wlan_lock(void *vp)
 static int linux_wlan_lock_timeout(void *vp, u32 timeout)
 {
        int error = -1;
+
        PRINT_D(LOCK_DBG, "Locking %p\n", vp);
        if (vp != NULL)
                error = down_timeout((struct semaphore *)vp, msecs_to_jiffies(timeout));
@@ -681,6 +653,7 @@ static void linux_wlan_deinit_spin_lock(void *plock)
 static void linux_wlan_spin_lock(void *vp, unsigned long *flags)
 {
        unsigned long lflags;
+
        PRINT_D(SPIN_DEBUG, "Lock spin %p\n", vp);
        if (vp != NULL) {
                spin_lock_irqsave((spinlock_t *)vp, lflags);
@@ -692,6 +665,7 @@ static void linux_wlan_spin_lock(void *vp, unsigned long *flags)
 static void linux_wlan_spin_unlock(void *vp, unsigned long *flags)
 {
        unsigned long lflags = *flags;
+
        PRINT_D(SPIN_DEBUG, "Unlock spin %p\n", vp);
        if (vp != NULL) {
                spin_unlock_irqrestore((spinlock_t *)vp, lflags);
@@ -1052,7 +1026,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n
                goto _fail_;
        }
 
-       *(int *)c_val = (u32)pstrWFIDrv;
+       *(int *)c_val = 1;
 
        if (!g_linux_wlan->oup.wlan_cfg_set(1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0))
                goto _fail_;
@@ -1291,7 +1265,7 @@ static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_n
                goto _fail_;
 
        c_val[0] = 1; /* Enable N with immediate block ack. */
-       if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1, 1, (u32)pstrWFIDrv))
+       if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1, 1, 1))
                goto _fail_;
 
        return 0;
@@ -1488,9 +1462,6 @@ void linux_to_wlan(wilc_wlan_inp_t *nwi, linux_wlan_t *nic)
        nwi->os_func.os_sleep = linux_wlan_msleep;
        nwi->os_func.os_atomic_sleep = linux_wlan_atomic_msleep;
        nwi->os_func.os_debug = linux_wlan_dbg;
-       nwi->os_func.os_malloc = linux_wlan_malloc;
-       nwi->os_func.os_malloc_atomic = linux_wlan_malloc_atomic;
-       nwi->os_func.os_free = linux_wlan_free;
        nwi->os_func.os_lock = linux_wlan_lock;
        nwi->os_func.os_unlock = linux_wlan_unlock;
        nwi->os_func.os_wait = linux_wlan_lock_timeout;
@@ -1535,6 +1506,7 @@ int wlan_initialize_threads(perInterface_wlan_t *nic)
 {
 
        int ret = 0;
+
        PRINT_D(INIT_DBG, "Initializing Threads ...\n");
 
 #if (RX_BH_TYPE == RX_BH_WORK_QUEUE)
@@ -1709,6 +1681,7 @@ extern void wilc_wlan_global_reset(void);
 uint8_t wilc1000_prepare_11b_core(wilc_wlan_inp_t *nwi,        wilc_wlan_oup_t *nwo, linux_wlan_t *nic)
 {
        uint8_t trials = 0;
+
        while ((core_11b_ready() && (READY_CHECK_THRESHOLD > (trials++)))) {
                PRINT_D(INIT_DBG, "11b core not ready yet: %u\n", trials);
                wilc_wlan_deinit(nic);
@@ -1743,6 +1716,7 @@ int repeat_power_cycle(perInterface_wlan_t *nic)
        int ret = 0;
        wilc_wlan_inp_t nwi;
        wilc_wlan_oup_t nwo;
+
        sdio_unregister_driver(&wilc_bus);
 
        linux_wlan_device_detection(0);
@@ -1880,6 +1854,7 @@ int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic)
                if (g_linux_wlan->oup.wlan_cfg_get(1, WID_FIRMWARE_VERSION, 1, 0)) {
                        int size;
                        char Firmware_ver[20];
+
                        size = g_linux_wlan->oup.wlan_cfg_get_value(
                                        WID_FIRMWARE_VERSION,
                                        Firmware_ver, sizeof(Firmware_ver));
@@ -1999,8 +1974,7 @@ int mac_open(struct net_device *ndev)
        Set_machw_change_vir_if(false);
 
        host_int_get_MacAddress(priv->hWILCWFIDrv, mac_add);
-       PRINT_D(INIT_DBG, "Mac address: %x:%x:%x:%x:%x:%x\n", mac_add[0], mac_add[1], mac_add[2],
-               mac_add[3], mac_add[4], mac_add[5]);
+       PRINT_D(INIT_DBG, "Mac address: %pM\n", mac_add);
 
        /* loop through the NUM of supported devices and set the MAC address */
        for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) {
@@ -2039,6 +2013,7 @@ int mac_open(struct net_device *ndev)
 {
 
        linux_wlan_t *nic;
+
        nic = netdev_priv(ndev);
 
        /*initialize platform*/
@@ -2069,6 +2044,7 @@ static void wilc_set_multicast_list(struct net_device *dev)
        struct WILC_WFI_priv *priv;
        tstrWILC_WFIDrv *pstrWFIDrv;
        int i = 0;
+
        priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
        pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
 
@@ -2120,13 +2096,14 @@ static void linux_wlan_tx_complete(void *priv, int status)
 {
 
        struct tx_complete_data *pv_data = (struct tx_complete_data *)priv;
+
        if (status == 1)
                PRINT_D(TX_DBG, "Packet sent successfully - Size = %d - Address = %p - SKB = %p\n", pv_data->size, pv_data->buff, pv_data->skb);
        else
                PRINT_D(TX_DBG, "Couldn't send packet - Size = %d - Address = %p - SKB = %p\n", pv_data->size, pv_data->buff, pv_data->skb);
        /* Free the SK Buffer, its work is done */
        dev_kfree_skb(pv_data->skb);
-       linux_wlan_free(pv_data);
+       kfree(pv_data);
 }
 
 int mac_xmit(struct sk_buff *skb, struct net_device *ndev)
@@ -2137,6 +2114,7 @@ int mac_xmit(struct sk_buff *skb, struct net_device *ndev)
        char *pu8UdpBuffer;
        struct iphdr *ih;
        struct ethhdr *eth_h;
+
        nic = netdev_priv(ndev);
 
        PRINT_D(INT_DBG, "\n========\n IntUH: %d - IntBH: %d - IntCld: %d\n========\n", int_rcvdU, int_rcvdB, int_clrd);
@@ -2148,7 +2126,7 @@ int mac_xmit(struct sk_buff *skb, struct net_device *ndev)
                return 0;
        }
 
-       tx_data = (struct tx_complete_data *)internal_alloc(sizeof(struct tx_complete_data), GFP_ATOMIC);
+       tx_data = kmalloc(sizeof(struct tx_complete_data), GFP_ATOMIC);
        if (tx_data == NULL) {
                PRINT_ER("Failed to allocate memory for tx_data structure\n");
                dev_kfree_skb(skb);