OSDN Git Service

net: wireless: bcm4329: Fix pno_enable if disassociated
authorDmitry Shmidt <dimitrysh@google.com>
Thu, 15 Dec 2011 20:12:20 +0000 (12:12 -0800)
committerDmitry Shmidt <dimitrysh@google.com>
Mon, 19 Dec 2011 21:22:48 +0000 (13:22 -0800)
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
drivers/net/wireless/bcm4329/dhd_common.c

index f7cd372..8b89e39 100644 (file)
@@ -1896,6 +1896,41 @@ fail:
 
 #endif
 
+/*
+ * returns = TRUE if associated, FALSE if not associated
+ */
+bool is_associated(dhd_pub_t *dhd, void *bss_buf)
+{
+       char bssid[ETHER_ADDR_LEN], zbuf[ETHER_ADDR_LEN];
+       int ret = -1;
+
+       bzero(bssid, ETHER_ADDR_LEN);
+       bzero(zbuf, ETHER_ADDR_LEN);
+
+       ret = dhdcdc_set_ioctl(dhd, 0, WLC_GET_BSSID, (char *)bssid, ETHER_ADDR_LEN);
+       DHD_TRACE((" %s WLC_GET_BSSID ioctl res = %d\n", __FUNCTION__, ret));
+
+       if (ret == BCME_NOTASSOCIATED) {
+               DHD_TRACE(("%s: not associated! res:%d\n", __FUNCTION__, ret));
+       }
+
+       if (ret < 0)
+               return FALSE;
+
+       if ((memcmp(bssid, zbuf, ETHER_ADDR_LEN) != 0)) {
+               /*  STA is assocoated BSSID is non zero */
+
+               if (bss_buf) {
+                       /* return bss if caller provided buf */
+                       memcpy(bss_buf, bssid, ETHER_ADDR_LEN);
+               }
+               return TRUE;
+       } else {
+               DHD_TRACE(("%s: WLC_GET_BSSID ioctl returned zero bssid\n", __FUNCTION__));
+               return FALSE;
+       }
+}
+
 /* Function to estimate possible DTIM_SKIP value */
 int dhd_get_dtim_skip(dhd_pub_t *dhd)
 {
@@ -1979,7 +2014,6 @@ int dhd_pno_clean(dhd_pub_t *dhd)
 int dhd_pno_enable(dhd_pub_t *dhd, int pfn_enabled)
 {
        char iovbuf[128];
-       uint8 bssid[6];
        int ret = -1;
 
        if ((!dhd) && ((pfn_enabled != 0) || (pfn_enabled != 1))) {
@@ -1990,12 +2024,7 @@ int dhd_pno_enable(dhd_pub_t *dhd, int pfn_enabled)
        memset(iovbuf, 0, sizeof(iovbuf));
 
        /* Check if disassoc to enable pno */
-       if ((pfn_enabled) && \
-               ((ret = dhdcdc_set_ioctl(dhd, 0, WLC_GET_BSSID, \
-                                (char *)&bssid, ETHER_ADDR_LEN)) == BCME_NOTASSOCIATED)) {
-               DHD_TRACE(("%s pno enable called in disassoc mode\n", __FUNCTION__));
-       }
-       else if (pfn_enabled) {
+       if (pfn_enabled && (is_associated(dhd, NULL) == TRUE)) {
                DHD_ERROR(("%s pno enable called in assoc mode ret=%d\n", \
                        __FUNCTION__, ret));
                return ret;