Merge remote-tracking branch 'remotes/aosp/android-3.0' into develop-3.0
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / bcm4329 / dhd_linux.c
index be7298846bc72f91bddf6c581c19653837b3d95b..4058cbc02589dd4bab0dd811c1ac5f9236a4258f 100644 (file)
@@ -287,7 +287,6 @@ typedef struct dhd_info {
        int wl_count;
        int wl_packet;
 
-       int hang_was_sent; /* flag that message was send at least once */
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
        struct mutex wl_start_lock; /* mutex when START called to prevent any other Linux calls */
 #endif
@@ -1488,7 +1487,8 @@ dhd_dpc_thread(void *data)
                                        dhd_os_wake_unlock(&dhd->pub);
                                }
                        } else {
-                               dhd_bus_stop(dhd->pub.bus, TRUE);
+                               if (dhd->pub.up)
+                                       dhd_bus_stop(dhd->pub.bus, TRUE);
                                dhd_os_wake_unlock(&dhd->pub);
                        }
                }
@@ -1746,6 +1746,14 @@ dhd_ioctl_entry(struct net_device *net, struct ifreq *ifr, int cmd)
 
        dhd_os_wake_lock(&dhd->pub);
 
+       /* send to dongle only if we are not waiting for reload already */
+       if (dhd->pub.hang_was_sent) {
+               DHD_ERROR(("%s: HANG was sent up earlier\n", __FUNCTION__));
+               dhd_os_wake_lock_timeout_enable(&dhd->pub);
+               dhd_os_wake_unlock(&dhd->pub);
+               return OSL_ERROR(BCME_DONGLE_DOWN);
+       }
+
        ifidx = dhd_net2idx(dhd, net);
        DHD_TRACE(("%s: ifidx %d, cmd 0x%04x\n", __FUNCTION__, ifidx, cmd));
 
@@ -1889,7 +1897,7 @@ dhd_stop(struct net_device *net)
 #else
        DHD_ERROR(("BYPASS %s:due to BRCM compilation : under investigation ...\n", __FUNCTION__));
 #endif /* !defined(IGNORE_ETH0_DOWN) */
-
+       dhd->pub.hang_was_sent = 0;
        OLD_MOD_DEC_USE_COUNT;
        return 0;
 }
@@ -3087,8 +3095,8 @@ int net_os_send_hang_message(struct net_device *dev)
        int ret = 0;
 
        if (dhd) {
-               if (!dhd->hang_was_sent) {
-                       dhd->hang_was_sent = 1;
+               if (!dhd->pub.hang_was_sent) {
+                       dhd->pub.hang_was_sent = 1;
                        ret = wl_iw_send_priv_event(dev, "HANG");
                }
        }