Merge branch 'staging-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh...
[deliverable/linux.git] / drivers / staging / brcm80211 / brcmfmac / dhd_linux.c
index 86a6adbc16d2973b9d6e5be18592f7cc781fb7c9..05dada98eb6bfb6bbacc0a6d8c5cf41834d39ffd 100644 (file)
 #include <linux/fcntl.h>
 #include <linux/fs.h>
 #include <linux/uaccess.h>
+#include <linux/interrupt.h>
+#include <linux/hardirq.h>
 #include <net/cfg80211.h>
-#if defined(CONFIG_HAS_EARLYSUSPEND)
-#include <linux/earlysuspend.h>
-#endif
 #include <defs.h>
 #include <brcmu_utils.h>
 #include <brcmu_wifi.h>
 
-#include "dngl_stats.h"
 #include "dhd.h"
 #include "dhd_bus.h"
 #include "dhd_proto.h"
 #include "wl_cfg80211.h"
 #include "bcmchip.h"
 
-/* Global ASSERT type flag */
-u32 g_assert_type;
-
 #if defined(CONFIG_PM_SLEEP)
 #include <linux/suspend.h>
 atomic_t brcmf_mmc_suspend;
-DECLARE_WAIT_QUEUE_HEAD(dhd_dpc_wait);
 #endif /*  defined(CONFIG_PM_SLEEP) */
 
 MODULE_AUTHOR("Broadcom Corporation");
@@ -76,7 +70,7 @@ struct brcmf_if {
 
 /* Local private structure (extension of pub) */
 struct brcmf_info {
-       dhd_pub_t pub;
+       struct brcmf_pub pub;
 
        /* OS/stack specifics */
        struct brcmf_if *iflist[BRCMF_MAX_IFS];
@@ -91,10 +85,6 @@ struct brcmf_info {
        bool set_macaddress;
        u8 macvalue[ETH_ALEN];
        atomic_t pend_8021x_cnt;
-
-#ifdef CONFIG_HAS_EARLYSUSPEND
-       struct early_suspend early_suspend;
-#endif                         /* CONFIG_HAS_EARLYSUSPEND */
 };
 
 /* Error bits */
@@ -123,9 +113,8 @@ module_param(brcmf_pkt_filter_init, uint, 0);
 
 /* Pkt filter mode control */
 uint brcmf_master_mode = true;
-module_param(brcmf_master_mode, uint, 1);
+module_param(brcmf_master_mode, uint, 0);
 
-extern int brcmf_dongle_memsize;
 module_param(brcmf_dongle_memsize, int, 0);
 
 /* Contorl fw roaming */
@@ -160,8 +149,6 @@ uint brcmf_sdiod_drive_strength = 6;
 module_param(brcmf_sdiod_drive_strength, uint, 0);
 
 /* Tx/Rx bounds */
-extern uint brcmf_txbound;
-extern uint brcmf_rxbound;
 module_param(brcmf_txbound, uint, 0);
 module_param(brcmf_rxbound, uint, 0);
 
@@ -175,137 +162,11 @@ uint brcmf_pktgen_len;
 module_param(brcmf_pktgen_len, uint, 0);
 #endif
 
-/* Version string to report */
-#ifdef BCMDBG
-#define DHD_COMPILED "\nCompiled in " SRCBASE
-#else
-#define DHD_COMPILED
-#endif
-
 static int brcmf_toe_get(struct brcmf_info *drvr_priv, int idx, u32 *toe_ol);
 static int brcmf_toe_set(struct brcmf_info *drvr_priv, int idx, u32 toe_ol);
 static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata,
-                            brcmf_event_msg_t *event_ptr, void **data_ptr);
-
-static void brcmf_set_packet_filter(int value, dhd_pub_t *drvr)
-{
-       DHD_TRACE(("%s: %d\n", __func__, value));
-       /* 1 - Enable packet filter, only allow unicast packet to send up */
-       /* 0 - Disable packet filter */
-       if (brcmf_pkt_filter_enable) {
-               int i;
-
-               for (i = 0; i < drvr->pktfilter_count; i++) {
-                       brcmf_c_pktfilter_offload_set(drvr, drvr->pktfilter[i]);
-                       brcmf_c_pktfilter_offload_enable(drvr,
-                                                        drvr->pktfilter[i],
-                                                        value,
-                                                        brcmf_master_mode);
-               }
-       }
-}
-
-#if defined(CONFIG_HAS_EARLYSUSPEND)
-static int brcmf_set_suspend(int value, dhd_pub_t *drvr)
-{
-       int power_mode = PM_MAX;
-       /* struct wl_pkt_filter_enable       enable_parm; */
-       char iovbuf[32];
-       int bcn_li_dtim = 3;
-
-       DHD_TRACE(("%s: enter, value = %d in_suspend=%d\n",
-                  __func__, value, drvr->in_suspend));
-
-       if (drvr && drvr->up) {
-               if (value && drvr->in_suspend) {
-
-                       /* Kernel suspended */
-                       DHD_TRACE(("%s: force extra Suspend setting\n",
-                                  __func__));
-
-                       brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_PM,
-                                        (char *)&power_mode,
-                                        sizeof(power_mode));
-
-                       /* Enable packet filter, only allow unicast
-                                packet to send up */
-                       brcmf_set_packet_filter(1, drvr);
-
-                       /* if dtim skip setup as default force it
-                        * to wake each third dtim
-                        * for better power saving.
-                        * Note that side effect is chance to miss BC/MC
-                        * packet
-                        */
-                       if ((drvr->dtim_skip == 0) || (drvr->dtim_skip == 1))
-                               bcn_li_dtim = 3;
-                       else
-                               bcn_li_dtim = drvr->dtim_skip;
-                       brcmu_mkiovar("bcn_li_dtim", (char *)&bcn_li_dtim,
-                                   4, iovbuf, sizeof(iovbuf));
-                       brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_VAR,
-                                                 iovbuf, sizeof(iovbuf));
-               } else {
-
-                       /* Kernel resumed  */
-                       DHD_TRACE(("%s: Remove extra suspend setting\n",
-                                  __func__));
-
-                       power_mode = PM_FAST;
-                       brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_PM,
-                                                 (char *)&power_mode,
-                                                 sizeof(power_mode));
-
-                       /* disable pkt filter */
-                       brcmf_set_packet_filter(0, drvr);
-
-                       /* restore pre-suspend setting for dtim_skip */
-                       brcmu_mkiovar("bcn_li_dtim", (char *)&drvr->dtim_skip,
-                                   4, iovbuf, sizeof(iovbuf));
-
-                       brcmf_proto_cdc_set_ioctl(drvr, 0, BRCMF_C_SET_VAR,
-                                                 iovbuf, sizeof(iovbuf));
-               }
-       }
-
-       return 0;
-}
-
-static void brcmf_suspend_resume_helper(struct brcmf_info *drvr_priv, int val)
-{
-       dhd_pub_t *drvr = &drvr_priv->pub;
-
-       brcmf_os_proto_block(drvr);
-       /* Set flag when early suspend was called */
-       drvr->in_suspend = val;
-       if (!drvr->suspend_disable_flag)
-               brcmf_set_suspend(val, drvr);
-       brcmf_os_proto_unblock(drvr);
-}
-
-static void brcmf_early_suspend(struct early_suspend *h)
-{
-       struct brcmf_info *drvr_priv =
-                       container_of(h, struct brcmf_info, early_suspend);
-
-       DHD_TRACE(("%s: enter\n", __func__));
-
-       if (drvr_priv)
-               dhd_suspend_resume_helper(drvr_priv, 1);
-
-}
-
-static void brcmf_late_resume(struct early_suspend *h)
-{
-       struct brcmf_info *drvr_priv =
-                       container_of(h, struct brcmf_info, early_suspend);
-
-       DHD_TRACE(("%s: enter\n", __func__));
-
-       if (drvr_priv)
-               dhd_suspend_resume_helper(drvr_priv, 0);
-}
-#endif                         /* defined(CONFIG_HAS_EARLYSUSPEND) */
+                           struct brcmf_event_msg *event_ptr,
+                           void **data_ptr);
 
 /*
  * Generalized timeout mechanism.  Uses spin sleep with exponential
@@ -369,7 +230,6 @@ static int brcmf_net2idx(struct brcmf_info *drvr_priv, struct net_device *net)
 {
        int i = 0;
 
-       ASSERT(drvr_priv);
        while (i < BRCMF_MAX_IFS) {
                if (drvr_priv->iflist[i] && (drvr_priv->iflist[i]->net == net))
                        return i;
@@ -383,8 +243,6 @@ int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name)
 {
        int i = BRCMF_MAX_IFS;
 
-       ASSERT(drvr_priv);
-
        if (name == NULL || *name == '\0')
                return 0;
 
@@ -393,24 +251,22 @@ int brcmf_ifname2idx(struct brcmf_info *drvr_priv, char *name)
                    && !strncmp(drvr_priv->iflist[i]->name, name, IFNAMSIZ))
                        break;
 
-       DHD_TRACE(("%s: return idx %d for \"%s\"\n", __func__, i, name));
+       BRCMF_TRACE(("%s: return idx %d for \"%s\"\n", __func__, i, name));
 
        return i;               /* default - the primary interface */
 }
 
-char *brcmf_ifname(dhd_pub_t *drvr, int ifidx)
+char *brcmf_ifname(struct brcmf_pub *drvr, int ifidx)
 {
        struct brcmf_info *drvr_priv = drvr->info;
 
-       ASSERT(drvr_priv);
-
        if (ifidx < 0 || ifidx >= BRCMF_MAX_IFS) {
-               DHD_ERROR(("%s: ifidx %d out of range\n", __func__, ifidx));
+               BRCMF_ERROR(("%s: ifidx %d out of range\n", __func__, ifidx));
                return "<if_bad>";
        }
 
        if (drvr_priv->iflist[ifidx] == NULL) {
-               DHD_ERROR(("%s: null i/f %d\n", __func__, ifidx));
+               BRCMF_ERROR(("%s: null i/f %d\n", __func__, ifidx));
                return "<if_null>";
        }
 
@@ -431,7 +287,6 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx)
        uint buflen;
        int ret;
 
-       ASSERT(drvr_priv && drvr_priv->iflist[ifidx]);
        dev = drvr_priv->iflist[ifidx]->net;
        cnt = netdev_mc_count(dev);
 
@@ -443,8 +298,8 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx)
        buflen = sizeof("mcast_list") + sizeof(cnt) + (cnt * ETH_ALEN);
        bufp = buf = kmalloc(buflen, GFP_ATOMIC);
        if (!bufp) {
-               DHD_ERROR(("%s: out of memory for mcast_list, cnt %d\n",
-                          brcmf_ifname(&drvr_priv->pub, ifidx), cnt));
+               BRCMF_ERROR(("%s: out of memory for mcast_list, cnt %d\n",
+                            brcmf_ifname(&drvr_priv->pub, ifidx), cnt));
                return;
        }
 
@@ -471,8 +326,8 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx)
 
        ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len);
        if (ret < 0) {
-               DHD_ERROR(("%s: set mcast_list failed, cnt %d\n",
-                          brcmf_ifname(&drvr_priv->pub, ifidx), cnt));
+               BRCMF_ERROR(("%s: set mcast_list failed, cnt %d\n",
+                            brcmf_ifname(&drvr_priv->pub, ifidx), cnt));
                allmulti = cnt ? true : allmulti;
        }
 
@@ -486,17 +341,18 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx)
        buflen = sizeof("allmulti") + sizeof(allmulti);
        buf = kmalloc(buflen, GFP_ATOMIC);
        if (!buf) {
-               DHD_ERROR(("%s: out of memory for allmulti\n",
-                          brcmf_ifname(&drvr_priv->pub, ifidx)));
+               BRCMF_ERROR(("%s: out of memory for allmulti\n",
+                            brcmf_ifname(&drvr_priv->pub, ifidx)));
                return;
        }
        allmulti = cpu_to_le32(allmulti);
 
        if (!brcmu_mkiovar
            ("allmulti", (void *)&allmulti, sizeof(allmulti), buf, buflen)) {
-               DHD_ERROR(("%s: mkiovar failed for allmulti, datalen %d "
-                       "buflen %u\n", brcmf_ifname(&drvr_priv->pub, ifidx),
-                       (int)sizeof(allmulti), buflen));
+               BRCMF_ERROR(("%s: mkiovar failed for allmulti, datalen %d "
+                            "buflen %u\n",
+                            brcmf_ifname(&drvr_priv->pub, ifidx),
+                            (int)sizeof(allmulti), buflen));
                kfree(buf);
                return;
        }
@@ -509,9 +365,9 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx)
 
        ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len);
        if (ret < 0) {
-               DHD_ERROR(("%s: set allmulti %d failed\n",
-                          brcmf_ifname(&drvr_priv->pub, ifidx),
-                          le32_to_cpu(allmulti)));
+               BRCMF_ERROR(("%s: set allmulti %d failed\n",
+                            brcmf_ifname(&drvr_priv->pub, ifidx),
+                            le32_to_cpu(allmulti)));
        }
 
        kfree(buf);
@@ -530,9 +386,9 @@ static void _brcmf_set_multicast_list(struct brcmf_info *drvr_priv, int ifidx)
 
        ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len);
        if (ret < 0) {
-               DHD_ERROR(("%s: set promisc %d failed\n",
-                          brcmf_ifname(&drvr_priv->pub, ifidx),
-                          le32_to_cpu(allmulti)));
+               BRCMF_ERROR(("%s: set promisc %d failed\n",
+                            brcmf_ifname(&drvr_priv->pub, ifidx),
+                            le32_to_cpu(allmulti)));
        }
 }
 
@@ -542,11 +398,11 @@ static int _brcmf_set_mac_address(struct brcmf_info *drvr_priv, int ifidx, u8 *a
        struct brcmf_ioctl ioc;
        int ret;
 
-       DHD_TRACE(("%s enter\n", __func__));
+       BRCMF_TRACE(("%s enter\n", __func__));
        if (!brcmu_mkiovar
            ("cur_etheraddr", (char *)addr, ETH_ALEN, buf, 32)) {
-               DHD_ERROR(("%s: mkiovar failed for cur_etheraddr\n",
-                          brcmf_ifname(&drvr_priv->pub, ifidx)));
+               BRCMF_ERROR(("%s: mkiovar failed for cur_etheraddr\n",
+                            brcmf_ifname(&drvr_priv->pub, ifidx)));
                return -1;
        }
        memset(&ioc, 0, sizeof(ioc));
@@ -557,8 +413,8 @@ static int _brcmf_set_mac_address(struct brcmf_info *drvr_priv, int ifidx, u8 *a
 
        ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len);
        if (ret < 0) {
-               DHD_ERROR(("%s: set cur_etheraddr failed\n",
-                          brcmf_ifname(&drvr_priv->pub, ifidx)));
+               BRCMF_ERROR(("%s: set cur_etheraddr failed\n",
+                            brcmf_ifname(&drvr_priv->pub, ifidx)));
        } else {
                memcpy(drvr_priv->iflist[ifidx]->net->dev_addr, addr, ETH_ALEN);
        }
@@ -570,16 +426,15 @@ static int _brcmf_set_mac_address(struct brcmf_info *drvr_priv, int ifidx, u8 *a
 extern struct net_device *ap_net_dev;
 #endif
 
+/* Virtual interfaces only ((ifp && ifp->info && ifp->idx == true) */
 static void brcmf_op_if(struct brcmf_if *ifp)
 {
        struct brcmf_info *drvr_priv;
        int ret = 0, err = 0;
 
-       ASSERT(ifp && ifp->info && ifp->idx);   /* Virtual interfaces only */
-
        drvr_priv = ifp->info;
 
-       DHD_TRACE(("%s: idx %d, state %d\n", __func__, ifp->idx, ifp->state));
+       BRCMF_TRACE(("%s: idx %d, state %d\n", __func__, ifp->idx, ifp->state));
 
        switch (ifp->state) {
        case BRCMF_E_IF_ADD:
@@ -588,9 +443,9 @@ static void brcmf_op_if(struct brcmf_if *ifp)
                 * in case we missed the BRCMF_E_IF_DEL event.
                 */
                if (ifp->net != NULL) {
-                       DHD_ERROR(("%s: ERROR: netdev:%s already exists, "
-                       "try free & unregister\n",
-                       __func__, ifp->net->name));
+                       BRCMF_ERROR(("%s: ERROR: netdev:%s already exists, "
+                                    "try free & unregister\n",
+                                    __func__, ifp->net->name));
                        netif_stop_queue(ifp->net);
                        unregister_netdev(ifp->net);
                        free_netdev(ifp->net);
@@ -598,7 +453,7 @@ static void brcmf_op_if(struct brcmf_if *ifp)
                /* Allocate etherdev, including space for private structure */
                ifp->net = alloc_etherdev(sizeof(drvr_priv));
                if (!ifp->net) {
-                       DHD_ERROR(("%s: OOM - alloc_etherdev\n", __func__));
+                       BRCMF_ERROR(("%s: OOM - alloc_etherdev\n", __func__));
                        ret = -ENOMEM;
                }
                if (ret == 0) {
@@ -606,9 +461,9 @@ static void brcmf_op_if(struct brcmf_if *ifp)
                        memcpy(netdev_priv(ifp->net), &drvr_priv, sizeof(drvr_priv));
                        err = brcmf_net_attach(&drvr_priv->pub, ifp->idx);
                        if (err != 0) {
-                               DHD_ERROR(("%s: dhd_net_attach failed, "
-                                       "err %d\n",
-                                       __func__, err));
+                               BRCMF_ERROR(("%s: brcmf_net_attach failed, "
+                                            "err %d\n",
+                                            __func__, err));
                                ret = -EOPNOTSUPP;
                        } else {
 #ifdef SOFTAP
@@ -623,17 +478,17 @@ static void brcmf_op_if(struct brcmf_if *ifp)
                                         wl0.1 is ready */
                                up(&ap_eth_sema);
 #endif
-                               DHD_TRACE(("\n ==== pid:%x, net_device for "
-                                       "if:%s created ===\n\n",
-                                       current->pid, ifp->net->name));
+                               BRCMF_TRACE(("\n ==== pid:%x, net_device for "
+                                            "if:%s created ===\n\n",
+                                            current->pid, ifp->net->name));
                                ifp->state = 0;
                        }
                }
                break;
        case BRCMF_E_IF_DEL:
                if (ifp->net != NULL) {
-                       DHD_TRACE(("\n%s: got 'WLC_E_IF_DEL' state\n",
-                                  __func__));
+                       BRCMF_TRACE(("\n%s: got 'WLC_E_IF_DEL' state\n",
+                                    __func__));
                        netif_stop_queue(ifp->net);
                        unregister_netdev(ifp->net);
                        ret = BRCMF_DEL_IF;     /* Make sure the free_netdev()
@@ -641,8 +496,7 @@ static void brcmf_op_if(struct brcmf_if *ifp)
                }
                break;
        default:
-               DHD_ERROR(("%s: bad op %d\n", __func__, ifp->state));
-               ASSERT(!ifp->state);
+               BRCMF_ERROR(("%s: bad op %d\n", __func__, ifp->state));
                break;
        }
 
@@ -674,32 +528,35 @@ static int _brcmf_sysioc_thread(void *data)
                if (kthread_should_stop())
                        break;
                for (i = 0; i < BRCMF_MAX_IFS; i++) {
-                       if (drvr_priv->iflist[i]) {
+                       struct brcmf_if *ifentry = drvr_priv->iflist[i];
+                       if (ifentry) {
 #ifdef SOFTAP
                                in_ap = (ap_net_dev != NULL);
 #endif                         /* SOFTAP */
-                               if (drvr_priv->iflist[i]->state)
-                                       brcmf_op_if(drvr_priv->iflist[i]);
+                               if (ifentry->state)
+                                       brcmf_op_if(ifentry);
 #ifdef SOFTAP
                                if (drvr_priv->iflist[i] == NULL) {
-                                       DHD_TRACE(("\n\n %s: interface %d "
-                                               "removed!\n", __func__, i));
+                                       BRCMF_TRACE(("\n\n %s: interface %d "
+                                                    "removed!\n", __func__,
+                                                    i));
                                        continue;
                                }
 
                                if (in_ap && drvr_priv->set_macaddress) {
-                                       DHD_TRACE(("attempt to set MAC for %s "
-                                               "in AP Mode," "blocked.\n",
-                                               drvr_priv->iflist[i]->net->name));
+                                       BRCMF_TRACE(("attempt to set MAC for"
+                                                    " %s in AP Mode,"
+                                                    " blocked.\n",
+                                                    ifentry->net->name));
                                        drvr_priv->set_macaddress = false;
                                        continue;
                                }
 
                                if (in_ap && drvr_priv->set_multicast) {
-                                       DHD_TRACE(("attempt to set MULTICAST "
-                                                  "list for %s in AP Mode, "
-                                                  "blocked.\n",
-                                                  drvr_priv->iflist[i]->net->name));
+                                       BRCMF_TRACE(("attempt to set MULTICAST "
+                                                    "list for %s in AP Mode, "
+                                                    "blocked.\n",
+                                                    ifentry->net->name));
                                        drvr_priv->set_multicast = false;
                                        continue;
                                }
@@ -711,7 +568,7 @@ static int _brcmf_sysioc_thread(void *data)
                                if (drvr_priv->set_macaddress) {
                                        drvr_priv->set_macaddress = false;
                                        _brcmf_set_mac_address(drvr_priv, i,
-                                                            drvr_priv->macvalue);
+                                               drvr_priv->macvalue);
                                }
                        }
                }
@@ -731,7 +588,6 @@ static int brcmf_netdev_set_mac_address(struct net_device *dev, void *addr)
        if (ifidx == BRCMF_BAD_IF)
                return -1;
 
-       ASSERT(drvr_priv->sysioc_tsk);
        memcpy(&drvr_priv->macvalue, sa->sa_data, ETH_ALEN);
        drvr_priv->set_macaddress = true;
        up(&drvr_priv->sysioc_sem);
@@ -748,17 +604,16 @@ static void brcmf_netdev_set_multicast_list(struct net_device *dev)
        if (ifidx == BRCMF_BAD_IF)
                return;
 
-       ASSERT(drvr_priv->sysioc_tsk);
        drvr_priv->set_multicast = true;
        up(&drvr_priv->sysioc_sem);
 }
 
-int brcmf_sendpkt(dhd_pub_t *drvr, int ifidx, struct sk_buff *pktbuf)
+int brcmf_sendpkt(struct brcmf_pub *drvr, int ifidx, struct sk_buff *pktbuf)
 {
        struct brcmf_info *drvr_priv = drvr->info;
 
        /* Reject if down */
-       if (!drvr->up || (drvr->busstate == DHD_BUS_DOWN))
+       if (!drvr->up || (drvr->busstate == BRCMF_BUS_DOWN))
                return -ENODEV;
 
        /* Update multicast statistic */
@@ -785,19 +640,20 @@ static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *net)
        struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(net);
        int ifidx;
 
-       DHD_TRACE(("%s: Enter\n", __func__));
+       BRCMF_TRACE(("%s: Enter\n", __func__));
 
        /* Reject if down */
-       if (!drvr_priv->pub.up || (drvr_priv->pub.busstate == DHD_BUS_DOWN)) {
-               DHD_ERROR(("%s: xmit rejected pub.up=%d busstate=%d\n",
-                          __func__, drvr_priv->pub.up, drvr_priv->pub.busstate));
+       if (!drvr_priv->pub.up || (drvr_priv->pub.busstate == BRCMF_BUS_DOWN)) {
+               BRCMF_ERROR(("%s: xmit rejected pub.up=%d busstate=%d\n",
+                            __func__, drvr_priv->pub.up,
+                            drvr_priv->pub.busstate));
                netif_stop_queue(net);
                return -ENODEV;
        }
 
        ifidx = brcmf_net2idx(drvr_priv, net);
        if (ifidx == BRCMF_BAD_IF) {
-               DHD_ERROR(("%s: bad ifidx %d\n", __func__, ifidx));
+               BRCMF_ERROR(("%s: bad ifidx %d\n", __func__, ifidx));
                netif_stop_queue(net);
                return -ENODEV;
        }
@@ -806,15 +662,15 @@ static int brcmf_netdev_start_xmit(struct sk_buff *skb, struct net_device *net)
        if (skb_headroom(skb) < drvr_priv->pub.hdrlen) {
                struct sk_buff *skb2;
 
-               DHD_INFO(("%s: insufficient headroom\n",
-                         brcmf_ifname(&drvr_priv->pub, ifidx)));
+               BRCMF_INFO(("%s: insufficient headroom\n",
+                           brcmf_ifname(&drvr_priv->pub, ifidx)));
                drvr_priv->pub.tx_realloc++;
                skb2 = skb_realloc_headroom(skb, drvr_priv->pub.hdrlen);
                dev_kfree_skb(skb);
                skb = skb2;
                if (skb == NULL) {
-                       DHD_ERROR(("%s: skb_realloc_headroom failed\n",
-                                  brcmf_ifname(&drvr_priv->pub, ifidx)));
+                       BRCMF_ERROR(("%s: skb_realloc_headroom failed\n",
+                                    brcmf_ifname(&drvr_priv->pub, ifidx)));
                        ret = -ENOMEM;
                        goto done;
                }
@@ -832,15 +688,14 @@ done:
        return 0;
 }
 
-void brcmf_txflowcontrol(dhd_pub_t *drvr, int ifidx, bool state)
+void brcmf_txflowcontrol(struct brcmf_pub *drvr, int ifidx, bool state)
 {
        struct net_device *net;
        struct brcmf_info *drvr_priv = drvr->info;
 
-       DHD_TRACE(("%s: Enter\n", __func__));
+       BRCMF_TRACE(("%s: Enter\n", __func__));
 
        drvr->txoff = state;
-       ASSERT(drvr_priv && drvr_priv->iflist[ifidx]);
        net = drvr_priv->iflist[ifidx]->net;
        if (state == ON)
                netif_stop_queue(net);
@@ -848,7 +703,7 @@ void brcmf_txflowcontrol(dhd_pub_t *drvr, int ifidx, bool state)
                netif_wake_queue(net);
 }
 
-void brcmf_rx_frame(dhd_pub_t *drvr, int ifidx, struct sk_buff *skb,
+void brcmf_rx_frame(struct brcmf_pub *drvr, int ifidx, struct sk_buff *skb,
                  int numpkt)
 {
        struct brcmf_info *drvr_priv = drvr->info;
@@ -858,9 +713,9 @@ void brcmf_rx_frame(dhd_pub_t *drvr, int ifidx, struct sk_buff *skb,
        struct sk_buff *pnext, *save_pktbuf;
        int i;
        struct brcmf_if *ifp;
-       brcmf_event_msg_t event;
+       struct brcmf_event_msg event;
 
-       DHD_TRACE(("%s: Enter\n", __func__));
+       BRCMF_TRACE(("%s: Enter\n", __func__));
 
        save_pktbuf = skb;
 
@@ -888,7 +743,6 @@ void brcmf_rx_frame(dhd_pub_t *drvr, int ifidx, struct sk_buff *skb,
                if (ifp == NULL)
                        ifp = drvr_priv->iflist[0];
 
-               ASSERT(ifp);
                skb->dev = ifp->net;
                skb->protocol = eth_type_trans(skb, skb->dev);
 
@@ -907,7 +761,6 @@ void brcmf_rx_frame(dhd_pub_t *drvr, int ifidx, struct sk_buff *skb,
                                          skb_mac_header(skb),
                                          &event, &data);
 
-               ASSERT(ifidx < BRCMF_MAX_IFS && drvr_priv->iflist[ifidx]);
                if (drvr_priv->iflist[ifidx] &&
                    !drvr_priv->iflist[ifidx]->state)
                        ifp = drvr_priv->iflist[ifidx];
@@ -932,13 +785,7 @@ void brcmf_rx_frame(dhd_pub_t *drvr, int ifidx, struct sk_buff *skb,
        }
 }
 
-void brcmf_event(struct brcmf_info *drvr_priv, char *evpkt, int evlen, int ifidx)
-{
-       /* Linux version has nothing to do */
-       return;
-}
-
-void brcmf_txcomplete(dhd_pub_t *drvr, struct sk_buff *txp, bool success)
+void brcmf_txcomplete(struct brcmf_pub *drvr, struct sk_buff *txp, bool success)
 {
        uint ifidx;
        struct brcmf_info *drvr_priv = drvr->info;
@@ -961,14 +808,13 @@ static struct net_device_stats *brcmf_netdev_get_stats(struct net_device *net)
        struct brcmf_if *ifp;
        int ifidx;
 
-       DHD_TRACE(("%s: Enter\n", __func__));
+       BRCMF_TRACE(("%s: Enter\n", __func__));
 
        ifidx = brcmf_net2idx(drvr_priv, net);
        if (ifidx == BRCMF_BAD_IF)
                return NULL;
 
        ifp = drvr_priv->iflist[ifidx];
-       ASSERT(drvr_priv && ifp);
 
        if (drvr_priv->pub.up) {
                /* Use the protocol to get dongle stats */
@@ -1009,13 +855,13 @@ static int brcmf_toe_get(struct brcmf_info *drvr_priv, int ifidx, u32 *toe_ol)
        if (ret < 0) {
                /* Check for older dongle image that doesn't support toe_ol */
                if (ret == -EIO) {
-                       DHD_ERROR(("%s: toe not supported by device\n",
-                                  brcmf_ifname(&drvr_priv->pub, ifidx)));
+                       BRCMF_ERROR(("%s: toe not supported by device\n",
+                                    brcmf_ifname(&drvr_priv->pub, ifidx)));
                        return -EOPNOTSUPP;
                }
 
-               DHD_INFO(("%s: could not get toe_ol: ret=%d\n",
-                         brcmf_ifname(&drvr_priv->pub, ifidx), ret));
+               BRCMF_INFO(("%s: could not get toe_ol: ret=%d\n",
+                           brcmf_ifname(&drvr_priv->pub, ifidx), ret));
                return ret;
        }
 
@@ -1045,8 +891,8 @@ static int brcmf_toe_set(struct brcmf_info *drvr_priv, int ifidx, u32 toe_ol)
 
        ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len);
        if (ret < 0) {
-               DHD_ERROR(("%s: could not set toe_ol: ret=%d\n",
-                          brcmf_ifname(&drvr_priv->pub, ifidx), ret));
+               BRCMF_ERROR(("%s: could not set toe_ol: ret=%d\n",
+                            brcmf_ifname(&drvr_priv->pub, ifidx), ret));
                return ret;
        }
 
@@ -1059,8 +905,8 @@ static int brcmf_toe_set(struct brcmf_info *drvr_priv, int ifidx, u32 toe_ol)
 
        ret = brcmf_proto_ioctl(&drvr_priv->pub, ifidx, &ioc, ioc.buf, ioc.len);
        if (ret < 0) {
-               DHD_ERROR(("%s: could not set toe: ret=%d\n",
-                          brcmf_ifname(&drvr_priv->pub, ifidx), ret));
+               BRCMF_ERROR(("%s: could not set toe: ret=%d\n",
+                            brcmf_ifname(&drvr_priv->pub, ifidx), ret));
                return ret;
        }
 
@@ -1075,7 +921,8 @@ static void brcmf_ethtool_get_drvinfo(struct net_device *net,
        sprintf(info->driver, KBUILD_MODNAME);
        sprintf(info->version, "%lu", drvr_priv->pub.drv_version);
        sprintf(info->fw_version, "%s", BCM4329_FW_NAME);
-       sprintf(info->bus_info, "%s", dev_name(&wl_cfg80211_get_sdio_func()->dev));
+       sprintf(info->bus_info, "%s",
+               dev_name(&brcmf_cfg80211_get_sdio_func()->dev));
 }
 
 struct ethtool_ops brcmf_ethtool_ops = {
@@ -1091,7 +938,7 @@ static int brcmf_ethtool(struct brcmf_info *drvr_priv, void *uaddr)
        u32 toe_cmpnt, csum_dir;
        int ret;
 
-       DHD_TRACE(("%s: Enter\n", __func__));
+       BRCMF_TRACE(("%s: Enter\n", __func__));
 
        /* all ethtool calls start with a cmd word */
        if (copy_from_user(&cmd, uaddr, sizeof(u32)))
@@ -1109,7 +956,7 @@ static int brcmf_ethtool(struct brcmf_info *drvr_priv, void *uaddr)
                memset(&info, 0, sizeof(info));
                info.cmd = cmd;
 
-               /* if dhd requested, identify ourselves */
+               /* if requested, identify ourselves */
                if (strcmp(drvname, "?dhd") == 0) {
                        sprintf(info.driver, "dhd");
                        strcpy(info.version, BRCMF_VERSION_STR);
@@ -1117,7 +964,7 @@ static int brcmf_ethtool(struct brcmf_info *drvr_priv, void *uaddr)
 
                /* otherwise, require dongle to be up */
                else if (!drvr_priv->pub.up) {
-                       DHD_ERROR(("%s: dongle is not up\n", __func__));
+                       BRCMF_ERROR(("%s: dongle is not up\n", __func__));
                        return -ENODEV;
                }
 
@@ -1130,8 +977,8 @@ static int brcmf_ethtool(struct brcmf_info *drvr_priv, void *uaddr)
                sprintf(info.version, "%lu", drvr_priv->pub.drv_version);
                if (copy_to_user(uaddr, &info, sizeof(info)))
                        return -EFAULT;
-               DHD_CTL(("%s: given %*s, returning %s\n", __func__,
-                        (int)sizeof(drvname), drvname, info.driver));
+               BRCMF_CTL(("%s: given %*s, returning %s\n", __func__,
+                          (int)sizeof(drvname), drvname, info.driver));
                break;
 
                /* Get toe offload components from dongle */
@@ -1206,7 +1053,7 @@ static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr,
        bool is_set_key_cmd;
 
        ifidx = brcmf_net2idx(drvr_priv, net);
-       DHD_TRACE(("%s: ifidx %d, cmd 0x%04x\n", __func__, ifidx, cmd));
+       BRCMF_TRACE(("%s: ifidx %d, cmd 0x%04x\n", __func__, ifidx, cmd));
 
        if (ifidx == BRCMF_BAD_IF)
                return -1;
@@ -1247,7 +1094,7 @@ static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr,
                }
        }
 
-       /* To differentiate between wl and dhd read 4 more byes */
+       /* To differentiate read 4 more byes */
        if ((copy_from_user(&driver, (char *)ifr->ifr_data +
                            sizeof(struct brcmf_ioctl), sizeof(uint)) != 0)) {
                bcmerror = -EINVAL;
@@ -1259,7 +1106,7 @@ static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr,
                goto done;
        }
 
-       /* check for local dhd ioctl and handle it */
+       /* check for local brcmf ioctl and handle it */
        if (driver == BRCMF_IOCTL_MAGIC) {
                bcmerror = brcmf_c_ioctl((void *)&drvr_priv->pub, &ioc, buf, buflen);
                if (bcmerror)
@@ -1268,8 +1115,8 @@ static int brcmf_netdev_ioctl_entry(struct net_device *net, struct ifreq *ifr,
        }
 
        /* send to dongle (must be up, and wl) */
-       if ((drvr_priv->pub.busstate != DHD_BUS_DATA)) {
-               DHD_ERROR(("%s DONGLE_DOWN,__func__\n", __func__));
+       if ((drvr_priv->pub.busstate != BRCMF_BUS_DATA)) {
+               BRCMF_ERROR(("%s DONGLE_DOWN,__func__\n", __func__));
                bcmerror = -EIO;
                goto done;
        }
@@ -1314,8 +1161,8 @@ static int brcmf_netdev_stop(struct net_device *net)
 #if !defined(IGNORE_ETH0_DOWN)
        struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(net);
 
-       DHD_TRACE(("%s: Enter\n", __func__));
-       wl_cfg80211_down();
+       BRCMF_TRACE(("%s: Enter\n", __func__));
+       brcmf_cfg80211_down();
        if (drvr_priv->pub.up == 0)
                return 0;
 
@@ -1323,8 +1170,8 @@ static int brcmf_netdev_stop(struct net_device *net)
        drvr_priv->pub.up = 0;
        netif_stop_queue(net);
 #else
-       DHD_ERROR(("BYPASS %s:due to BRCM compilation : under investigation\n",
-               __func__));
+       BRCMF_ERROR(("BYPASS %s:due to BRCM compilation: under investigation\n",
+                    __func__));
 #endif                         /* !defined(IGNORE_ETH0_DOWN) */
 
        return 0;
@@ -1337,14 +1184,15 @@ static int brcmf_netdev_open(struct net_device *net)
        int ifidx = brcmf_net2idx(drvr_priv, net);
        s32 ret = 0;
 
-       DHD_TRACE(("%s: ifidx %d\n", __func__, ifidx));
+       BRCMF_TRACE(("%s: ifidx %d\n", __func__, ifidx));
 
        if (ifidx == 0) {       /* do it only for primary eth0 */
 
                /* try to bring up bus */
                ret = brcmf_bus_start(&drvr_priv->pub);
                if (ret != 0) {
-                       DHD_ERROR(("%s: failed with code %d\n", __func__, ret));
+                       BRCMF_ERROR(("%s: failed with code %d\n",
+                                    __func__, ret));
                        return -1;
                }
                atomic_set(&drvr_priv->pend_8021x_cnt, 0);
@@ -1354,16 +1202,18 @@ static int brcmf_netdev_open(struct net_device *net)
                /* Get current TOE mode from dongle */
                if (brcmf_toe_get(drvr_priv, ifidx, &toe_ol) >= 0
                    && (toe_ol & TOE_TX_CSUM_OL) != 0)
-                       drvr_priv->iflist[ifidx]->net->features |= NETIF_F_IP_CSUM;
+                       drvr_priv->iflist[ifidx]->net->features |=
+                               NETIF_F_IP_CSUM;
                else
-                       drvr_priv->iflist[ifidx]->net->features &= ~NETIF_F_IP_CSUM;
+                       drvr_priv->iflist[ifidx]->net->features &=
+                               ~NETIF_F_IP_CSUM;
        }
        /* Allow transmit calls */
        netif_start_queue(net);
        drvr_priv->pub.up = 1;
-       if (unlikely(wl_cfg80211_up())) {
-               DHD_ERROR(("%s: failed to bring up cfg80211\n",
-                          __func__));
+       if (unlikely(brcmf_cfg80211_up())) {
+               BRCMF_ERROR(("%s: failed to bring up cfg80211\n",
+                            __func__));
                return -1;
        }
 
@@ -1376,15 +1226,13 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, void *handle, char *name,
 {
        struct brcmf_if *ifp;
 
-       DHD_TRACE(("%s: idx %d, handle->%p\n", __func__, ifidx, handle));
-
-       ASSERT(drvr_priv && (ifidx < BRCMF_MAX_IFS));
+       BRCMF_TRACE(("%s: idx %d, handle->%p\n", __func__, ifidx, handle));
 
        ifp = drvr_priv->iflist[ifidx];
        if (!ifp) {
                ifp = kmalloc(sizeof(struct brcmf_if), GFP_ATOMIC);
                if (!ifp) {
-                       DHD_ERROR(("%s: OOM - struct dhd_if\n", __func__));
+                       BRCMF_ERROR(("%s: OOM - struct brcmf_if\n", __func__));
                        return -ENOMEM;
                }
        }
@@ -1399,7 +1247,6 @@ brcmf_add_if(struct brcmf_info *drvr_priv, int ifidx, void *handle, char *name,
        if (handle == NULL) {
                ifp->state = BRCMF_E_IF_ADD;
                ifp->idx = ifidx;
-               ASSERT(drvr_priv->sysioc_tsk);
                up(&drvr_priv->sysioc_sem);
        } else
                ifp->net = (struct net_device *)handle;
@@ -1411,39 +1258,37 @@ void brcmf_del_if(struct brcmf_info *drvr_priv, int ifidx)
 {
        struct brcmf_if *ifp;
 
-       DHD_TRACE(("%s: idx %d\n", __func__, ifidx));
+       BRCMF_TRACE(("%s: idx %d\n", __func__, ifidx));
 
-       ASSERT(drvr_priv && ifidx && (ifidx < BRCMF_MAX_IFS));
        ifp = drvr_priv->iflist[ifidx];
        if (!ifp) {
-               DHD_ERROR(("%s: Null interface\n", __func__));
+               BRCMF_ERROR(("%s: Null interface\n", __func__));
                return;
        }
 
        ifp->state = BRCMF_E_IF_DEL;
        ifp->idx = ifidx;
-       ASSERT(drvr_priv->sysioc_tsk);
        up(&drvr_priv->sysioc_sem);
 }
 
-dhd_pub_t *brcmf_attach(struct dhd_bus *bus, uint bus_hdrlen)
+struct brcmf_pub *brcmf_attach(struct brcmf_bus *bus, uint bus_hdrlen)
 {
        struct brcmf_info *drvr_priv = NULL;
        struct net_device *net;
 
-       DHD_TRACE(("%s: Enter\n", __func__));
+       BRCMF_TRACE(("%s: Enter\n", __func__));
 
        /* Allocate etherdev, including space for private structure */
        net = alloc_etherdev(sizeof(drvr_priv));
        if (!net) {
-               DHD_ERROR(("%s: OOM - alloc_etherdev\n", __func__));
+               BRCMF_ERROR(("%s: OOM - alloc_etherdev\n", __func__));
                goto fail;
        }
 
        /* Allocate primary brcmf_info */
        drvr_priv = kzalloc(sizeof(struct brcmf_info), GFP_ATOMIC);
        if (!drvr_priv) {
-               DHD_ERROR(("%s: OOM - alloc dhd_info\n", __func__));
+               BRCMF_ERROR(("%s: OOM - alloc brcmf_info\n", __func__));
                goto fail;
        }
 
@@ -1482,23 +1327,23 @@ dhd_pub_t *brcmf_attach(struct dhd_bus *bus, uint bus_hdrlen)
 
        /* Attach and link in the protocol */
        if (brcmf_proto_attach(&drvr_priv->pub) != 0) {
-               DHD_ERROR(("dhd_prot_attach failed\n"));
+               BRCMF_ERROR(("brcmf_prot_attach failed\n"));
                goto fail;
        }
 
        /* Attach and link in the cfg80211 */
-       if (unlikely(wl_cfg80211_attach(net, &drvr_priv->pub))) {
-               DHD_ERROR(("wl_cfg80211_attach failed\n"));
+       if (unlikely(brcmf_cfg80211_attach(net, &drvr_priv->pub))) {
+               BRCMF_ERROR(("wl_cfg80211_attach failed\n"));
                goto fail;
        }
 
        if (brcmf_sysioc) {
                sema_init(&drvr_priv->sysioc_sem, 0);
                drvr_priv->sysioc_tsk = kthread_run(_brcmf_sysioc_thread, drvr_priv,
-                                               "_dhd_sysioc");
+                                               "_brcmf_sysioc");
                if (IS_ERR(drvr_priv->sysioc_tsk)) {
                        printk(KERN_WARNING
-                               "_dhd_sysioc thread failed to start\n");
+                               "_brcmf_sysioc thread failed to start\n");
                        drvr_priv->sysioc_tsk = NULL;
                }
        } else
@@ -1509,21 +1354,9 @@ dhd_pub_t *brcmf_attach(struct dhd_bus *bus, uint bus_hdrlen)
         */
        memcpy(netdev_priv(net), &drvr_priv, sizeof(drvr_priv));
 
-#if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
-       g_bus = bus;
-#endif
 #if defined(CONFIG_PM_SLEEP)
        atomic_set(&brcmf_mmc_suspend, false);
 #endif /* defined(CONFIG_PM_SLEEP) */
-       /* && defined(DHD_GPL) */
-       /* Init lock suspend to prevent kernel going to suspend */
-#ifdef CONFIG_HAS_EARLYSUSPEND
-       drvr_priv->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 20;
-       drvr_priv->early_suspend.suspend = brcmf_early_suspend;
-       drvr_priv->early_suspend.resume = brcmf_late_resume;
-       register_early_suspend(&drvr_priv->early_suspend);
-#endif
-
        return &drvr_priv->pub;
 
 fail:
@@ -1535,28 +1368,26 @@ fail:
        return NULL;
 }
 
-int brcmf_bus_start(dhd_pub_t *drvr)
+int brcmf_bus_start(struct brcmf_pub *drvr)
 {
        int ret = -1;
        struct brcmf_info *drvr_priv = drvr->info;
        /* Room for "event_msgs" + '\0' + bitvec */
        char iovbuf[BRCMF_EVENTING_MASK_LEN + 12];
 
-       ASSERT(drvr_priv);
-
-       DHD_TRACE(("%s:\n", __func__));
+       BRCMF_TRACE(("%s:\n", __func__));
 
        /* Bring up the bus */
        ret = brcmf_sdbrcm_bus_init(&drvr_priv->pub, true);
        if (ret != 0) {
-               DHD_ERROR(("%s, brcmf_sdbrcm_bus_init failed %d\n", __func__,
-                          ret));
+               BRCMF_ERROR(("%s, brcmf_sdbrcm_bus_init failed %d\n", __func__,
+                            ret));
                return ret;
        }
 
        /* If bus is not ready, can't come up */
-       if (drvr_priv->pub.busstate != DHD_BUS_DATA) {
-               DHD_ERROR(("%s failed bus is not ready\n", __func__));
+       if (drvr_priv->pub.busstate != BRCMF_BUS_DATA) {
+               BRCMF_ERROR(("%s failed bus is not ready\n", __func__));
                return -ENODEV;
        }
 
@@ -1599,30 +1430,6 @@ int brcmf_bus_start(dhd_pub_t *drvr)
        return 0;
 }
 
-int brcmf_iovar(dhd_pub_t *drvr, int ifidx, char *name, char *cmd_buf,
-         uint cmd_len, int set)
-{
-       char buf[strlen(name) + 1 + cmd_len];
-       int len = sizeof(buf);
-       struct brcmf_ioctl ioc;
-       int ret;
-
-       len = brcmu_mkiovar(name, cmd_buf, cmd_len, buf, len);
-
-       memset(&ioc, 0, sizeof(ioc));
-
-       ioc.cmd = set ? BRCMF_C_SET_VAR : BRCMF_C_GET_VAR;
-       ioc.buf = buf;
-       ioc.len = len;
-       ioc.set = set;
-
-       ret = brcmf_proto_ioctl(drvr, ifidx, &ioc, ioc.buf, ioc.len);
-       if (!set && ret >= 0)
-               memcpy(cmd_buf, buf, cmd_len);
-
-       return ret;
-}
-
 static struct net_device_ops brcmf_netdev_ops_pri = {
        .ndo_open = brcmf_netdev_open,
        .ndo_stop = brcmf_netdev_stop,
@@ -1633,21 +1440,16 @@ static struct net_device_ops brcmf_netdev_ops_pri = {
        .ndo_set_multicast_list = brcmf_netdev_set_multicast_list
 };
 
-int brcmf_net_attach(dhd_pub_t *drvr, int ifidx)
+int brcmf_net_attach(struct brcmf_pub *drvr, int ifidx)
 {
        struct brcmf_info *drvr_priv = drvr->info;
        struct net_device *net;
        u8 temp_addr[ETH_ALEN] = {
                0x00, 0x90, 0x4c, 0x11, 0x22, 0x33};
 
-       DHD_TRACE(("%s: ifidx %d\n", __func__, ifidx));
-
-       ASSERT(drvr_priv && drvr_priv->iflist[ifidx]);
+       BRCMF_TRACE(("%s: ifidx %d\n", __func__, ifidx));
 
        net = drvr_priv->iflist[ifidx]->net;
-       ASSERT(net);
-
-       ASSERT(!net->netdev_ops);
        net->netdev_ops = &brcmf_netdev_ops_pri;
 
        /*
@@ -1660,7 +1462,7 @@ int brcmf_net_attach(dhd_pub_t *drvr, int ifidx)
        }
 
        if (ifidx == 1) {
-               DHD_TRACE(("%s ACCESS POINT MAC:\n", __func__));
+               BRCMF_TRACE(("%s ACCESS POINT MAC:\n", __func__));
                /*  ACCESSPOINT INTERFACE CASE */
                temp_addr[0] |= 0X02;   /* set bit 2 ,
                         - Locally Administered address  */
@@ -1675,12 +1477,12 @@ int brcmf_net_attach(dhd_pub_t *drvr, int ifidx)
        memcpy(net->dev_addr, temp_addr, ETH_ALEN);
 
        if (register_netdev(net) != 0) {
-               DHD_ERROR(("%s: couldn't register the net device\n",
-                       __func__));
+               BRCMF_ERROR(("%s: couldn't register the net device\n",
+                            __func__));
                goto fail;
        }
 
-       DHD_INFO(("%s: Broadcom Dongle Host Driver\n", net->name));
+       BRCMF_INFO(("%s: Broadcom Dongle Host Driver\n", net->name));
 
        return 0;
 
@@ -1689,11 +1491,11 @@ fail:
        return -EBADE;
 }
 
-static void brcmf_bus_detach(dhd_pub_t *drvr)
+static void brcmf_bus_detach(struct brcmf_pub *drvr)
 {
        struct brcmf_info *drvr_priv;
 
-       DHD_TRACE(("%s: Enter\n", __func__));
+       BRCMF_TRACE(("%s: Enter\n", __func__));
 
        if (drvr) {
                drvr_priv = drvr->info;
@@ -1707,11 +1509,11 @@ static void brcmf_bus_detach(dhd_pub_t *drvr)
        }
 }
 
-void brcmf_detach(dhd_pub_t *drvr)
+void brcmf_detach(struct brcmf_pub *drvr)
 {
        struct brcmf_info *drvr_priv;
 
-       DHD_TRACE(("%s: Enter\n", __func__));
+       BRCMF_TRACE(("%s: Enter\n", __func__));
 
        if (drvr) {
                drvr_priv = drvr->info;
@@ -1719,18 +1521,11 @@ void brcmf_detach(dhd_pub_t *drvr)
                        struct brcmf_if *ifp;
                        int i;
 
-#if defined(CONFIG_HAS_EARLYSUSPEND)
-                       if (drvr_priv->early_suspend.suspend)
-                               unregister_early_suspend(
-                                       &drvr_priv->early_suspend);
-#endif                         /* defined(CONFIG_HAS_EARLYSUSPEND) */
-
                        for (i = 1; i < BRCMF_MAX_IFS; i++)
                                if (drvr_priv->iflist[i])
                                        brcmf_del_if(drvr_priv, i);
 
                        ifp = drvr_priv->iflist[0];
-                       ASSERT(ifp);
                        if (ifp->net->netdev_ops == &brcmf_netdev_ops_pri) {
                                brcmf_netdev_stop(ifp->net);
                                unregister_netdev(ifp->net);
@@ -1747,9 +1542,8 @@ void brcmf_detach(dhd_pub_t *drvr)
                        if (drvr->prot)
                                brcmf_proto_detach(drvr);
 
-                       wl_cfg80211_detach();
+                       brcmf_cfg80211_detach();
 
-                       /* && defined(DHD_GPL) */
                        free_netdev(ifp->net);
                        kfree(ifp);
                        kfree(drvr_priv);
@@ -1759,21 +1553,21 @@ void brcmf_detach(dhd_pub_t *drvr)
 
 static void __exit brcmf_module_cleanup(void)
 {
-       DHD_TRACE(("%s: Enter\n", __func__));
+       BRCMF_TRACE(("%s: Enter\n", __func__));
 
-       dhd_bus_unregister();
+       brcmf_bus_unregister();
 }
 
 static int __init brcmf_module_init(void)
 {
        int error;
 
-       DHD_TRACE(("%s: Enter\n", __func__));
+       BRCMF_TRACE(("%s: Enter\n", __func__));
 
-       error = dhd_bus_register();
+       error = brcmf_bus_register();
 
        if (error) {
-               DHD_ERROR(("%s: dhd_bus_register failed\n", __func__));
+               BRCMF_ERROR(("%s: brcmf_bus_register failed\n", __func__));
                goto failed;
        }
        return 0;
@@ -1785,10 +1579,7 @@ failed:
 module_init(brcmf_module_init);
 module_exit(brcmf_module_cleanup);
 
-/*
- * OS specific functions required to implement DHD driver in OS independent way
- */
-int brcmf_os_proto_block(dhd_pub_t *drvr)
+int brcmf_os_proto_block(struct brcmf_pub *drvr)
 {
        struct brcmf_info *drvr_priv = drvr->info;
 
@@ -1799,7 +1590,7 @@ int brcmf_os_proto_block(dhd_pub_t *drvr)
        return 0;
 }
 
-int brcmf_os_proto_unblock(dhd_pub_t *drvr)
+int brcmf_os_proto_unblock(struct brcmf_pub *drvr)
 {
        struct brcmf_info *drvr_priv = drvr->info;
 
@@ -1821,7 +1612,8 @@ void brcmf_os_set_ioctl_resp_timeout(unsigned int timeout_msec)
        brcmf_ioctl_timeout_msec = (int)timeout_msec;
 }
 
-int brcmf_os_ioctl_resp_wait(dhd_pub_t *drvr, uint *condition, bool *pending)
+int brcmf_os_ioctl_resp_wait(struct brcmf_pub *drvr, uint *condition,
+                            bool *pending)
 {
        struct brcmf_info *drvr_priv = drvr->info;
        DECLARE_WAITQUEUE(wait, current);
@@ -1846,7 +1638,7 @@ int brcmf_os_ioctl_resp_wait(dhd_pub_t *drvr, uint *condition, bool *pending)
        return timeout;
 }
 
-int brcmf_os_ioctl_resp_wake(dhd_pub_t *drvr)
+int brcmf_os_ioctl_resp_wake(struct brcmf_pub *drvr)
 {
        struct brcmf_info *drvr_priv = drvr->info;
 
@@ -1857,20 +1649,17 @@ int brcmf_os_ioctl_resp_wake(dhd_pub_t *drvr)
 }
 
 static int brcmf_host_event(struct brcmf_info *drvr_priv, int *ifidx, void *pktdata,
-                           brcmf_event_msg_t *event, void **data)
+                           struct brcmf_event_msg *event, void **data)
 {
        int bcmerror = 0;
 
-       ASSERT(drvr_priv != NULL);
-
        bcmerror = brcmf_c_host_event(drvr_priv, ifidx, pktdata, event, data);
        if (bcmerror != 0)
                return bcmerror;
 
-       ASSERT(drvr_priv->iflist[*ifidx] != NULL);
-       ASSERT(drvr_priv->iflist[*ifidx]->net != NULL);
        if (drvr_priv->iflist[*ifidx]->net)
-               wl_cfg80211_event(drvr_priv->iflist[*ifidx]->net, event, *data);
+               brcmf_cfg80211_event(drvr_priv->iflist[*ifidx]->net,
+                                    event, *data);
 
        return bcmerror;
 }
@@ -1884,71 +1673,6 @@ int brcmf_netdev_reset(struct net_device *dev, u8 flag)
        return 1;
 }
 
-int brcmf_netdev_set_suspend_disable(struct net_device *dev, int val)
-{
-       struct brcmf_info *drvr_priv = *(struct brcmf_info **)netdev_priv(dev);
-       int ret = 0;
-
-       if (drvr_priv) {
-               ret = drvr_priv->pub.suspend_disable_flag;
-               drvr_priv->pub.suspend_disable_flag = val;
-       }
-       return ret;
-}
-
-int brcmf_netdev_set_suspend(struct net_device *dev, int val)
-{
-       int ret = 0;
-#if defined(CONFIG_HAS_EARLYSUSPEND)
-       struct brcmf_info *drvr_priv = *(struct brcmf_info **)netdev_priv(dev);
-
-       if (drvr_priv) {
-               brcmf_os_proto_block(&drvr_priv->pub);
-               ret = brcmf_set_suspend(val, &drvr_priv->pub);
-               brcmf_os_proto_unblock(&drvr_priv->pub);
-       }
-#endif         /* defined(CONFIG_HAS_EARLYSUSPEND) */
-       return ret;
-}
-
-int brcmf_netdev_set_dtim_skip(struct net_device *dev, int val)
-{
-       struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(dev);
-
-       if (drvr_priv)
-               drvr_priv->pub.dtim_skip = val;
-
-       return 0;
-}
-
-int brcmf_netdev_set_packet_filter(struct net_device *dev, int val)
-{
-       struct brcmf_info *drvr_priv = *(struct brcmf_info **) netdev_priv(dev);
-       int ret = 0;
-
-       /* Packet filtering is set only if we still in early-suspend and
-        * we need either to turn it ON or turn it OFF
-        * We can always turn it OFF in case of early-suspend, but we turn it
-        * back ON only if suspend_disable_flag was not set
-        */
-       if (drvr_priv && drvr_priv->pub.up) {
-               brcmf_os_proto_block(&drvr_priv->pub);
-               if (drvr_priv->pub.in_suspend) {
-                       if (!val || (val && !drvr_priv->pub.suspend_disable_flag))
-                               brcmf_set_packet_filter(val, &drvr_priv->pub);
-               }
-               brcmf_os_proto_unblock(&drvr_priv->pub);
-       }
-       return ret;
-}
-
-void brcmf_netdev_init_ioctl(struct net_device *dev)
-{
-       struct brcmf_info *drvr_priv = *(struct brcmf_info **)netdev_priv(dev);
-
-       brcmf_c_preinit_ioctls(&drvr_priv->pub);
-}
-
 static int brcmf_get_pend_8021x_cnt(struct brcmf_info *drvr_priv)
 {
        return atomic_read(&drvr_priv->pend_8021x_cnt);
@@ -1976,7 +1700,7 @@ int brcmf_netdev_wait_pend8021x(struct net_device *dev)
 }
 
 #ifdef BCMDBG
-int brcmf_write_to_file(dhd_pub_t *drvr, u8 *buf, int size)
+int brcmf_write_to_file(struct brcmf_pub *drvr, u8 *buf, int size)
 {
        int ret = 0;
        struct file *fp;
@@ -1990,7 +1714,7 @@ int brcmf_write_to_file(dhd_pub_t *drvr, u8 *buf, int size)
        /* open file to write */
        fp = filp_open("/tmp/mem_dump", O_WRONLY | O_CREAT, 0640);
        if (!fp) {
-               DHD_ERROR(("%s: open file error\n", __func__));
+               BRCMF_ERROR(("%s: open file error\n", __func__));
                ret = -1;
                goto exit;
        }
@@ -2010,50 +1734,3 @@ exit:
        return ret;
 }
 #endif                         /* BCMDBG */
-
-#if defined(BCMDBG)
-void osl_assert(char *exp, char *file, int line)
-{
-       char tempbuf[256];
-       char *basename;
-
-       basename = strrchr(file, '/');
-       /* skip the '/' */
-       if (basename)
-               basename++;
-
-       if (!basename)
-               basename = file;
-
-       snprintf(tempbuf, 256,
-                "assertion \"%s\" failed: file \"%s\", line %d\n", exp,
-                basename, line);
-
-       /*
-        * Print assert message and give it time to
-        * be written to /var/log/messages
-        */
-       if (!in_interrupt()) {
-               const int delay = 3;
-               printk(KERN_ERR "%s", tempbuf);
-               printk(KERN_ERR "panic in %d seconds\n", delay);
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(delay * HZ);
-       }
-
-       switch (g_assert_type) {
-       case 0:
-               panic(KERN_ERR "%s", tempbuf);
-               break;
-       case 1:
-               printk(KERN_ERR "%s", tempbuf);
-               BUG();
-               break;
-       case 2:
-               printk(KERN_ERR "%s", tempbuf);
-               break;
-       default:
-               break;
-       }
-}
-#endif                         /* defined(BCMDBG) */
This page took 0.045072 seconds and 5 git commands to generate.