staging: brcm80211: move assert function to dhd_linux.c
[deliverable/linux.git] / drivers / staging / brcm80211 / brcmfmac / dhd_linux.c
index f356c564cfb99bf56390bfbfda38e6bb6be21193..e0cd8e14ec7abb249ea32b91130882afeb737158 100644 (file)
 #include <linux/fcntl.h>
 #include <linux/fs.h>
 #include <linux/uaccess.h>
-#include <bcmdefs.h>
-#include <bcmutils.h>
-
-#include <dngl_stats.h>
-#include <dhd.h>
-#include <dhd_bus.h>
-#include <dhd_proto.h>
-#include <dhd_dbg.h>
-
-#include <wl_cfg80211.h>
+#include <net/cfg80211.h>
+#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 "dhd_dbg.h"
+#include "wl_cfg80211.h"
 
 #define EPI_VERSION_STR                "4.218.248.5"
 #define ETH_P_BRCM                     0x886c
 
+/* Global ASSERT type flag */
+u32 g_assert_type;
+
 #if defined(CUSTOMER_HW2) && defined(CONFIG_WIFI_CONTROL_FUNC)
 #include <linux/wifi_tiwlan.h>
 
@@ -179,8 +183,6 @@ MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN fullmac driver.");
 MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN fullmac cards");
 MODULE_LICENSE("Dual BSD/GPL");
 
-#define DRV_MODULE_NAME "brcmfmac"
-
 /* Linux wireless extension support */
 #if defined(CONFIG_WIRELESS_EXT)
 #include <wl_iw.h>
@@ -231,7 +233,6 @@ typedef struct dhd_info {
        bool wd_timer_valid;
        struct tasklet_struct tasklet;
        spinlock_t sdlock;
-       spinlock_t txqlock;
        /* Thread based operation */
        bool threads_only;
        struct semaphore sdsem;
@@ -264,6 +265,10 @@ char nvram_path[MOD_PARAM_PATHLEN];
 module_param_string(firmware_path, firmware_path, MOD_PARAM_PATHLEN, 0);
 module_param_string(nvram_path, nvram_path, MOD_PARAM_PATHLEN, 0);
 
+/* No firmware required */
+bool dhd_no_fw_req;
+module_param(dhd_no_fw_req, bool, 0);
+
 /* Error bits */
 module_param(dhd_msg_level, int, 0);
 
@@ -338,13 +343,9 @@ int dhd_idletime = DHD_IDLETIME_TICKS;
 module_param(dhd_idletime, int, 0);
 
 /* Use polling */
-uint dhd_poll = false;
+uint dhd_poll;
 module_param(dhd_poll, uint, 0);
 
-/* Use cfg80211 */
-uint dhd_cfg80211 = true;
-module_param(dhd_cfg80211, uint, 0);
-
 /* Use interrupts */
 uint dhd_intr = true;
 module_param(dhd_intr, uint, 0);
@@ -373,11 +374,6 @@ uint dhd_pktgen_len;
 module_param(dhd_pktgen_len, uint, 0);
 #endif
 
-#define FAVORITE_WIFI_CP       (!!dhd_cfg80211)
-#define IS_CFG80211_FAVORITE() FAVORITE_WIFI_CP
-#define DBG_CFG80211_GET() ((dhd_cfg80211 & WL_DBG_MASK) >> 1)
-#define NO_FW_REQ() (dhd_cfg80211 & 0x80)
-
 /* Version string to report */
 #ifdef DHD_DEBUG
 #define DHD_COMPILED "\nCompiled in " SRCBASE
@@ -400,32 +396,6 @@ static int dhd_toe_set(dhd_info_t *dhd, int idx, u32 toe_ol);
 static int dhd_wl_host_event(dhd_info_t *dhd, int *ifidx, void *pktdata,
                             wl_event_msg_t *event_ptr, void **data_ptr);
 
-#if defined(CONFIG_PM_SLEEP)
-static int dhd_sleep_pm_callback(struct notifier_block *nfb,
-                                unsigned long action, void *ignored)
-{
-       switch (action) {
-       case PM_HIBERNATION_PREPARE:
-       case PM_SUSPEND_PREPARE:
-               atomic_set(&dhd_mmc_suspend, true);
-               return NOTIFY_OK;
-       case PM_POST_HIBERNATION:
-       case PM_POST_SUSPEND:
-               atomic_set(&dhd_mmc_suspend, false);
-               return NOTIFY_OK;
-       }
-       return 0;
-}
-
-static struct notifier_block dhd_sleep_pm_notifier = {
-       .notifier_call = dhd_sleep_pm_callback,
-       .priority = 0
-};
-
-extern int register_pm_notifier(struct notifier_block *nb);
-extern int unregister_pm_notifier(struct notifier_block *nb);
-#endif /* defined(CONFIG_PM_SLEEP) */
-       /* && defined(DHD_GPL) */
 static void dhd_set_packet_filter(int value, dhd_pub_t *dhd)
 {
 #ifdef PKT_FILTER_SUPPORT
@@ -483,7 +453,7 @@ static int dhd_set_suspend(int value, dhd_pub_t *dhd)
                                bcn_li_dtim = 3;
                        else
                                bcn_li_dtim = dhd->dtim_skip;
-                       bcm_mkiovar("bcn_li_dtim", (char *)&bcn_li_dtim,
+                       brcmu_mkiovar("bcn_li_dtim", (char *)&bcn_li_dtim,
                                    4, iovbuf, sizeof(iovbuf));
                        dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf,
                                         sizeof(iovbuf));
@@ -491,7 +461,7 @@ static int dhd_set_suspend(int value, dhd_pub_t *dhd)
                        /* Disable build-in roaming to allowed \
                         * supplicant to take of romaing
                         */
-                       bcm_mkiovar("roam_off", (char *)&roamvar, 4,
+                       brcmu_mkiovar("roam_off", (char *)&roamvar, 4,
                                    iovbuf, sizeof(iovbuf));
                        dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf,
                                         sizeof(iovbuf));
@@ -511,14 +481,14 @@ static int dhd_set_suspend(int value, dhd_pub_t *dhd)
                        dhd_set_packet_filter(0, dhd);
 
                        /* restore pre-suspend setting for dtim_skip */
-                       bcm_mkiovar("bcn_li_dtim", (char *)&dhd->dtim_skip,
+                       brcmu_mkiovar("bcn_li_dtim", (char *)&dhd->dtim_skip,
                                    4, iovbuf, sizeof(iovbuf));
 
                        dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf,
                                         sizeof(iovbuf));
 #ifdef CUSTOMER_HW2
                        roamvar = 0;
-                       bcm_mkiovar("roam_off", (char *)&roamvar, 4, iovbuf,
+                       brcmu_mkiovar("roam_off", (char *)&roamvar, 4, iovbuf,
                                    sizeof(iovbuf));
                        dhdcdc_set_ioctl(dhd, 0, WLC_SET_VAR, iovbuf,
                                         sizeof(iovbuf));
@@ -748,7 +718,7 @@ static void _dhd_set_multicast_list(dhd_info_t *dhd, int ifidx)
        }
        allmulti = cpu_to_le32(allmulti);
 
-       if (!bcm_mkiovar
+       if (!brcmu_mkiovar
            ("allmulti", (void *)&allmulti, sizeof(allmulti), buf, buflen)) {
                DHD_ERROR(("%s: mkiovar failed for allmulti, datalen %d "
                        "buflen %u\n", dhd_ifname(&dhd->pub, ifidx),
@@ -800,7 +770,7 @@ _dhd_set_mac_address(dhd_info_t *dhd, int ifidx, u8 *addr)
        int ret;
 
        DHD_TRACE(("%s enter\n", __func__));
-       if (!bcm_mkiovar
+       if (!brcmu_mkiovar
            ("cur_etheraddr", (char *)addr, ETH_ALEN, buf, 32)) {
                DHD_ERROR(("%s: mkiovar failed for cur_etheraddr\n",
                           dhd_ifname(&dhd->pub, ifidx)));
@@ -1490,7 +1460,7 @@ static void dhd_ethtool_get_drvinfo(struct net_device *net,
 {
        dhd_info_t *dhd = *(dhd_info_t **) netdev_priv(net);
 
-       sprintf(info->driver, DRV_MODULE_NAME);
+       sprintf(info->driver, KBUILD_MODNAME);
        sprintf(info->version, "%lu", dhd->pub.drv_version);
        sprintf(info->fw_version, "%s", wl_cfg80211_get_fwname());
        sprintf(info->bus_info, "%s", dev_name(&wl_cfg80211_get_sdio_func()->dev));
@@ -1742,9 +1712,7 @@ static int dhd_stop(struct net_device *net)
        dhd_info_t *dhd = *(dhd_info_t **) netdev_priv(net);
 
        DHD_TRACE(("%s: Enter\n", __func__));
-       if (IS_CFG80211_FAVORITE()) {
-               wl_cfg80211_down();
-       }
+       wl_cfg80211_down();
        if (dhd->pub.up == 0)
                return 0;
 
@@ -1794,12 +1762,10 @@ static int dhd_open(struct net_device *net)
        /* Allow transmit calls */
        netif_start_queue(net);
        dhd->pub.up = 1;
-       if (IS_CFG80211_FAVORITE()) {
-               if (unlikely(wl_cfg80211_up())) {
-                       DHD_ERROR(("%s: failed to bring up cfg80211\n",
-                                  __func__));
-                       return -1;
-               }
+       if (unlikely(wl_cfg80211_up())) {
+               DHD_ERROR(("%s: failed to bring up cfg80211\n",
+                          __func__));
+               return -1;
        }
 
        return ret;
@@ -1816,9 +1782,12 @@ dhd_add_if(dhd_info_t *dhd, int ifidx, void *handle, char *name,
        ASSERT(dhd && (ifidx < DHD_MAX_IFS));
 
        ifp = dhd->iflist[ifidx];
-       if (!ifp && !(ifp = kmalloc(sizeof(dhd_if_t), GFP_ATOMIC))) {
-               DHD_ERROR(("%s: OOM - dhd_if_t\n", __func__));
-               return -ENOMEM;
+       if (!ifp) {
+               ifp = kmalloc(sizeof(dhd_if_t), GFP_ATOMIC);
+               if (!ifp) {
+                       DHD_ERROR(("%s: OOM - dhd_if_t\n", __func__));
+                       return -ENOMEM;
+               }
        }
 
        memset(ifp, 0, sizeof(dhd_if_t));
@@ -1914,7 +1883,6 @@ dhd_pub_t *dhd_attach(struct dhd_bus *bus, uint bus_hdrlen)
 
        /* Initialize the spinlocks */
        spin_lock_init(&dhd->sdlock);
-       spin_lock_init(&dhd->txqlock);
 
        /* Link to info module */
        dhd->pub.info = dhd;
@@ -1937,15 +1905,13 @@ dhd_pub_t *dhd_attach(struct dhd_bus *bus, uint bus_hdrlen)
 #endif /* defined(CONFIG_WIRELESS_EXT) */
 
        /* Attach and link in the cfg80211 */
-       if (IS_CFG80211_FAVORITE()) {
-               if (unlikely(wl_cfg80211_attach(net, &dhd->pub))) {
-                       DHD_ERROR(("wl_cfg80211_attach failed\n"));
-                       goto fail;
-               }
-               if (!NO_FW_REQ()) {
-                       strcpy(fw_path, wl_cfg80211_get_fwname());
-                       strcpy(nv_path, wl_cfg80211_get_nvramname());
-               }
+       if (unlikely(wl_cfg80211_attach(net, &dhd->pub))) {
+               DHD_ERROR(("wl_cfg80211_attach failed\n"));
+               goto fail;
+       }
+       if (!dhd_no_fw_req) {
+               strcpy(fw_path, wl_cfg80211_get_fwname());
+               strcpy(nv_path, wl_cfg80211_get_nvramname());
        }
 
        /* Set up the watchdog timer */
@@ -2011,8 +1977,6 @@ dhd_pub_t *dhd_attach(struct dhd_bus *bus, uint bus_hdrlen)
 #endif
 #if defined(CONFIG_PM_SLEEP)
        atomic_set(&dhd_mmc_suspend, false);
-       if (!IS_CFG80211_FAVORITE())
-               register_pm_notifier(&dhd_sleep_pm_notifier);
 #endif /* defined(CONFIG_PM_SLEEP) */
        /* && defined(DHD_GPL) */
        /* Init lock suspend to prevent kernel going to suspend */
@@ -2089,8 +2053,8 @@ int dhd_bus_start(dhd_pub_t *dhdp)
                return -ENODEV;
        }
 #ifdef EMBEDDED_PLATFORM
-       bcm_mkiovar("event_msgs", dhdp->eventmask, WL_EVENTING_MASK_LEN, iovbuf,
-                   sizeof(iovbuf));
+       brcmu_mkiovar("event_msgs", dhdp->eventmask, WL_EVENTING_MASK_LEN,
+                     iovbuf, sizeof(iovbuf));
        dhdcdc_query_ioctl(dhdp, 0, WLC_GET_VAR, iovbuf, sizeof(iovbuf));
        memcpy(dhdp->eventmask, iovbuf, WL_EVENTING_MASK_LEN);
 
@@ -2140,7 +2104,7 @@ dhd_iovar(dhd_pub_t *pub, int ifidx, char *name, char *cmd_buf, uint cmd_len,
        wl_ioctl_t ioc;
        int ret;
 
-       len = bcm_mkiovar(name, cmd_buf, cmd_len, buf, len);
+       len = brcmu_mkiovar(name, cmd_buf, cmd_len, buf, len);
 
        memset(&ioc, 0, sizeof(ioc));
 
@@ -2302,13 +2266,8 @@ void dhd_detach(dhd_pub_t *dhdp)
                        wl_iw_detach();
 #endif                         /* (CONFIG_WIRELESS_EXT) */
 
-                       if (IS_CFG80211_FAVORITE())
-                               wl_cfg80211_detach();
+                       wl_cfg80211_detach();
 
-#if defined(CONFIG_PM_SLEEP)
-                       if (!IS_CFG80211_FAVORITE())
-                               unregister_pm_notifier(&dhd_sleep_pm_notifier);
-#endif /* defined(CONFIG_PM_SLEEP) */
                        /* && defined(DHD_GPL) */
                        free_netdev(ifp->net);
                        kfree(ifp);
@@ -2509,7 +2468,7 @@ void *dhd_os_open_image(char *filename)
 {
        struct file *fp;
 
-       if (IS_CFG80211_FAVORITE() && !NO_FW_REQ())
+       if (!dhd_no_fw_req)
                return wl_cfg80211_request_fw(filename);
 
        fp = filp_open(filename, O_RDONLY, 0);
@@ -2530,7 +2489,7 @@ int dhd_os_get_image_block(char *buf, int len, void *image)
        struct file *fp = (struct file *)image;
        int rdlen;
 
-       if (IS_CFG80211_FAVORITE() && !NO_FW_REQ())
+       if (!dhd_no_fw_req)
                return wl_cfg80211_read_fw(buf, len);
 
        if (!image)
@@ -2545,7 +2504,7 @@ int dhd_os_get_image_block(char *buf, int len, void *image)
 
 void dhd_os_close_image(void *image)
 {
-       if (IS_CFG80211_FAVORITE() && !NO_FW_REQ())
+       if (!dhd_no_fw_req)
                return wl_cfg80211_release_fw();
        if (image)
                filp_close((struct file *)image, NULL);
@@ -2575,40 +2534,6 @@ void dhd_os_sdunlock(dhd_pub_t *pub)
                spin_unlock_bh(&dhd->sdlock);
 }
 
-void dhd_os_sdlock_txq(dhd_pub_t *pub)
-{
-       dhd_info_t *dhd;
-
-       dhd = (dhd_info_t *) (pub->info);
-       spin_lock_bh(&dhd->txqlock);
-}
-
-void dhd_os_sdunlock_txq(dhd_pub_t *pub)
-{
-       dhd_info_t *dhd;
-
-       dhd = (dhd_info_t *) (pub->info);
-       spin_unlock_bh(&dhd->txqlock);
-}
-
-void dhd_os_sdlock_rxq(dhd_pub_t *pub)
-{
-}
-
-void dhd_os_sdunlock_rxq(dhd_pub_t *pub)
-{
-}
-
-void dhd_os_sdtxlock(dhd_pub_t *pub)
-{
-       dhd_os_sdlock(pub);
-}
-
-void dhd_os_sdtxunlock(dhd_pub_t *pub)
-{
-       dhd_os_sdunlock(pub);
-}
-
 static int
 dhd_wl_host_event(dhd_info_t *dhd, int *ifidx, void *pktdata,
                  wl_event_msg_t *event, void **data)
@@ -2621,26 +2546,10 @@ dhd_wl_host_event(dhd_info_t *dhd, int *ifidx, void *pktdata,
        if (bcmerror != 0)
                return bcmerror;
 
-#if defined(CONFIG_WIRELESS_EXT)
-       if (!IS_CFG80211_FAVORITE()) {
-               if ((dhd->iflist[*ifidx] == NULL)
-                   || (dhd->iflist[*ifidx]->net == NULL)) {
-                       DHD_ERROR(("%s Exit null pointer\n", __func__));
-                       return bcmerror;
-               }
-
-               if (dhd->iflist[*ifidx]->net)
-                       wl_iw_event(dhd->iflist[*ifidx]->net, event, *data);
-       }
-#endif                         /* defined(CONFIG_WIRELESS_EXT)  */
-
-       if (IS_CFG80211_FAVORITE()) {
-               ASSERT(dhd->iflist[*ifidx] != NULL);
-               ASSERT(dhd->iflist[*ifidx]->net != NULL);
-               if (dhd->iflist[*ifidx]->net)
-                       wl_cfg80211_event(dhd->iflist[*ifidx]->net, event,
-                                         *data);
-       }
+       ASSERT(dhd->iflist[*ifidx] != NULL);
+       ASSERT(dhd->iflist[*ifidx]->net != NULL);
+       if (dhd->iflist[*ifidx]->net)
+               wl_cfg80211_event(dhd->iflist[*ifidx]->net, event, *data);
 
        return bcmerror;
 }
@@ -2860,3 +2769,50 @@ exit:
        return ret;
 }
 #endif                         /* DHD_DEBUG */
+
+#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.032226 seconds and 5 git commands to generate.