net: wireless: bcm4329: Fix pno_enable if disassociated

Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
This commit is contained in:
Dmitry Shmidt 2011-12-15 12:12:20 -08:00
parent 599c8566fa
commit 37ff4411a5

View File

@ -1896,6 +1896,41 @@ dhd_iscan_get_partial_result(void *dhdp, uint *scan_count)
#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;