PD #84934: check null pointer for suspend, add wakelock for cfg80211 cmd
authorpeter.lin <peter.lin@amlogic.com>
Mon, 23 Dec 2013 09:41:56 +0000 (17:41 +0800)
committerpeter.lin <peter.lin@amlogic.com>
Tue, 24 Dec 2013 07:25:30 +0000 (15:25 +0800)
broadcm_40181/dhd_config.c
broadcm_40181/dhd_linux.c
broadcm_40181/wl_cfg80211.c
broadcm_40181/wl_cfg80211.h

index 7448476a3d7bb4108db97e7a2962bd3d73958430..56a3744ba8d02e7935e389a340b10b0cdcf73d61 100755 (executable)
@@ -689,20 +689,26 @@ bool wifi_ready = true;
 void\r
 dhd_conf_wifi_power(bool on)\r
 {\r
+       extern struct wl_priv *wlcfg_drv_priv;\r
        printk("%s: Enter %d\n", __FUNCTION__, on);\r
        if (on) {\r
                wl_cfg80211_user_sync(true);\r
                wl_android_wifi_on(g_netdev);\r
                wl_cfg80211_send_disconnect();\r
-               wl_cfgp2p_start_p2p_device(NULL, NULL);\r
+               if (wlcfg_drv_priv && wlcfg_drv_priv->p2p)\r
+                       wl_cfgp2p_start_p2p_device(NULL, NULL);\r
+               else            \r
+                       printk("======= ON : no p2p ======\n");\r
                wl_cfg80211_user_sync(false);\r
                wifi_ready = true;\r
        } else {\r
-               extern struct wl_priv *wlcfg_drv_priv;\r
                wifi_ready = false;\r
-               wl_cfgp2p_clear_management_ie(wlcfg_drv_priv, 0);\r
-               wl_cfgp2p_clear_management_ie(wlcfg_drv_priv, 1);\r
-               wl_cfgp2p_stop_p2p_device(NULL, wlcfg_drv_priv->p2p_wdev);\r
+               if (wlcfg_drv_priv && wlcfg_drv_priv->p2p) {\r
+                       wl_cfgp2p_clear_management_ie(wlcfg_drv_priv, 0);\r
+                       wl_cfgp2p_clear_management_ie(wlcfg_drv_priv, 1);\r
+                       wl_cfgp2p_stop_p2p_device(NULL, wlcfg_drv_priv->p2p_wdev);\r
+               } else \r
+                       printk("======= OFF : no p2p ======\n");\r
                dhd_conf_wifi_stop(g_netdev);\r
        }\r
        printk("%s: Exit %d\n", __FUNCTION__, on);\r
index 244cfc654400528c5c9c2bf8327a88e5b6e19a99..8550a202848fa2e3563af86d190946920cf4769c 100755 (executable)
@@ -2857,7 +2857,7 @@ dhd_stop(struct net_device *net)
        int ifidx = 0;
        dhd_info_t *dhd = *(dhd_info_t **)netdev_priv(net);
        DHD_OS_WAKE_LOCK(&dhd->pub);
-       DHD_TRACE(("%s: Enter %p\n", __FUNCTION__, net));
+       DHD_ERROR(("%s: Enter %p\n", __FUNCTION__, net));
 
        if (dhd->pub.up == 0) {
                goto exit;
@@ -2919,6 +2919,8 @@ dhd_open(struct net_device *net)
        int ifidx;
        int32 ret = 0;
 
+       DHD_ERROR(("%s: Enter %p\n", __FUNCTION__, net));
+
 #if defined(MULTIPLE_SUPPLICANT)
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) && 1 && 1
        if (mutex_is_locked(&_dhd_sdio_mutex_lock_) != 0) {
index f22ddb0d7338c9c409e8a31a56972a304aba7993..4cd2e11b84223fe424d31343f0774107f02f9395 100755 (executable)
@@ -602,6 +602,14 @@ wl_sdo_proto_t wl_sdo_protos [] = {
 };
 #endif
 
+static void wl_wakelock_timeout(struct wl_priv *priv)
+{
+#if defined(CONFIG_HAS_WAKELOCK)       
+       wake_lock_timeout(&priv->priv_lock, msecs_to_jiffies(20));      
+#endif
+}
+
+
 #define RETURN_EIO_IF_NOT_UP(wlpriv)                                           \
 do {                                                                   \
        struct net_device *checkSysUpNDev = wl_to_prmry_ndev(wlpriv);           \
@@ -609,6 +617,11 @@ do {                                                                       \
                WL_INFO(("device is not ready\n"));                     \
                return -EIO;                                            \
        }                                                               \
+       if (unlikely(!g_wifi_on)) {             \
+               WL_ERR(("g_wifi_on is not ready\n"));   \
+               return -EIO;    \
+       }       \
+       wl_wakelock_timeout(wlpriv);    \
 } while (0)
 
 
@@ -9872,7 +9885,10 @@ static s32 wl_init_priv(struct wl_priv *wl)
        wl_init_prof(wl, ndev);
        wl_link_down(wl);
        DNGL_FUNC(dhd_cfg80211_init, (wl));
-
+#ifdef CONFIG_HAS_WAKELOCK
+       wake_lock_init(&wl->priv_lock, WAKE_LOCK_SUSPEND, "wlan_priv_wake");
+       printk("init wlan_priv_wake\n");
+#endif
        return err;
 }
 
@@ -9886,6 +9902,9 @@ static void wl_deinit_priv(struct wl_priv *wl)
        wl_term_iscan(wl);
        wl_deinit_priv_mem(wl);
        unregister_netdevice_notifier(&wl_cfg80211_netdev_notifier);
+#ifdef CONFIG_HAS_WAKELOCK
+       wake_lock_destroy(&wl->priv_lock);
+#endif
 }
 
 #if defined(WL_ENABLE_P2P_IF)
index 5189809d1c3b466b92bccfadb87c3fcb42abfaf2..5c11b4450388369e02f88a3198ddb224874ca071 100755 (executable)
@@ -16,6 +16,9 @@
 #include <linux/wireless.h>
 #include <net/cfg80211.h>
 #include <linux/rfkill.h>
+#ifdef CONFIG_HAS_WAKELOCK
+#include <linux/wakelock.h>
+#endif
 
 #include <wl_cfgp2p.h>
 
@@ -534,6 +537,10 @@ struct wl_priv {
        struct wl_scan_results *bss_list;
        struct wl_scan_results *scan_results;
 
+#if defined(CONFIG_HAS_WAKELOCK)
+               struct wake_lock priv_lock;     
+#endif
+
        /* scan request object for internal purpose */
        struct wl_scan_req *scan_req_int;
        /* information element object for internal purpose */