wifi: update bcmdhd.1.579.77.41.1.cn from ampak[3/3]
[GitHub/LineageOS/G12/android_hardware_amlogic_kernel-modules_dhd-driver.git] / bcmdhd.1.579.77.41.1.cn / dhd_pcie_linux.c
index 577b3937ad89c1542bf170ad670317ceed0b52e9..ecaed3e935586f8f6fa4a5a9ae6832c0d49634f2 100644 (file)
@@ -884,9 +884,7 @@ dhdpcie_bus_unregister(void)
 int __devinit
 dhdpcie_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-#ifdef BUS_POWER_RESTORE
-       wifi_adapter_info_t *adapter = NULL;
-#endif
+       DHD_MUTEX_LOCK();
 
        if (dhdpcie_chipmatch (pdev->vendor, pdev->device)) {
                DHD_ERROR(("%s: chipmatch failed!!\n", __FUNCTION__));
@@ -906,15 +904,8 @@ dhdpcie_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        device_disable_async_suspend(&pdev->dev);
 #endif /* BCMPCIE_DISABLE_ASYNC_SUSPEND */
 
-#ifdef BUS_POWER_RESTORE
-       adapter = dhd_wifi_platform_get_adapter(PCI_BUS, pdev->bus->number,
-                                               PCI_SLOT(pdev->devfn));
-
-       if (adapter != NULL)
-               adapter->pci_dev = pdev;
-#endif
-
        DHD_TRACE(("%s: PCIe Enumeration done!!\n", __FUNCTION__));
+       DHD_MUTEX_UNLOCK();
        return 0;
 }
 
@@ -942,17 +933,7 @@ dhdpcie_pci_remove(struct pci_dev *pdev)
 
        DHD_TRACE(("%s Enter\n", __FUNCTION__));
 
-#if defined(MULTIPLE_SUPPLICANT)
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
-       if (mutex_is_locked(&_dhd_sdio_mutex_lock_) == 0) {
-               DHD_ERROR(("%s : no mutex held. set lock\n", __FUNCTION__));
-       }
-       else {
-               DHD_ERROR(("%s : mutex is locked!. wait for unlocking\n", __FUNCTION__));
-       }
-       mutex_lock(&_dhd_sdio_mutex_lock_);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) */
-#endif 
+       DHD_MUTEX_LOCK();
 
        pch = pci_get_drvdata(pdev);
        bus = pch->bus;
@@ -1000,12 +981,7 @@ dhdpcie_pci_remove(struct pci_dev *pdev)
 
        dhdpcie_init_succeeded = FALSE;
 
-#if defined(MULTIPLE_SUPPLICANT)
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
-       mutex_unlock(&_dhd_sdio_mutex_lock_);
-       DHD_ERROR(("%s : the lock is released.\n", __FUNCTION__));
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) */
-#endif /* LINUX */
+       DHD_MUTEX_UNLOCK();
 
        DHD_TRACE(("%s Exit\n", __FUNCTION__));
 
@@ -1232,10 +1208,6 @@ void dhdpcie_linkdown_cb(struct_pcie_notify *noti)
        */
 #endif /* SUPPORT_LINKDOWN_RECOVERY */
 
-#if defined(MULTIPLE_SUPPLICANT)
-extern void wl_android_post_init(void); // terence 20120530: fix critical section in dhd_open and dhdsdio_probe
-#endif
-
 int dhdpcie_init(struct pci_dev *pdev)
 {
 
@@ -1250,18 +1222,6 @@ int dhdpcie_init(struct pci_dev *pdev)
        dhdpcie_smmu_info_t     *dhdpcie_smmu_info = NULL;
 #endif /* USE_SMMU_ARCH_MSM */
 
-#if defined(MULTIPLE_SUPPLICANT)
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
-       if (mutex_is_locked(&_dhd_sdio_mutex_lock_) == 0) {
-               DHD_ERROR(("%s : no mutex held. set lock\n", __FUNCTION__));
-       }
-       else {
-               DHD_ERROR(("%s : mutex is locked!. wait for unlocking\n", __FUNCTION__));
-       }
-       mutex_lock(&_dhd_sdio_mutex_lock_);
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)) */
-#endif
-
        do {
                /* osl attach */
                if (!(osh = osl_attach(pdev, PCI_BUS, FALSE))) {
@@ -1272,9 +1232,12 @@ int dhdpcie_init(struct pci_dev *pdev)
                /* initialize static buffer */
                adapter = dhd_wifi_platform_get_adapter(PCI_BUS, pdev->bus->number,
                        PCI_SLOT(pdev->devfn));
-               if (adapter != NULL)
+               if (adapter != NULL) {
                        DHD_ERROR(("%s: found adapter info '%s'\n", __FUNCTION__, adapter->name));
-               else
+#ifdef BUS_POWER_RESTORE
+                       adapter->pci_dev = pdev;
+#endif
+               } else
                        DHD_ERROR(("%s: can't find adapter info for this chip\n", __FUNCTION__));
                osl_static_mem_init(osh, adapter);
 
@@ -1444,11 +1407,7 @@ int dhdpcie_init(struct pci_dev *pdev)
 
 #if defined(MULTIPLE_SUPPLICANT)
                wl_android_post_init(); // terence 20120530: fix critical section in dhd_open and dhdsdio_probe
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
-               mutex_unlock(&_dhd_sdio_mutex_lock_);
-               DHD_ERROR(("%s : the lock is released.\n", __FUNCTION__));
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-#endif 
+#endif /* MULTIPLE_SUPPLICANT */
 
                DHD_TRACE(("%s:Exit - SUCCESS \n", __FUNCTION__));
                return 0;  /* return  SUCCESS  */
@@ -1479,12 +1438,6 @@ int dhdpcie_init(struct pci_dev *pdev)
                osl_detach(osh);
 
        dhdpcie_init_succeeded = FALSE;
-#if defined(MULTIPLE_SUPPLICANT)
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25))
-       mutex_unlock(&_dhd_sdio_mutex_lock_);
-       DHD_ERROR(("%s : the lock is released.\n", __FUNCTION__));
-#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)) */
-#endif 
 
        DHD_TRACE(("%s:Exit - FAILURE \n", __FUNCTION__));
 
@@ -2305,6 +2258,7 @@ bool dhdpcie_is_resume_done(dhd_pub_t *dhdp)
        return bus->runtime_resume_done;
 }
 #endif /* DHD_PCIE_RUNTIMEPM */
+
 struct device * dhd_bus_to_dev(dhd_bus_t *bus)
 {
        struct pci_dev *pdev;
@@ -2315,6 +2269,7 @@ struct device * dhd_bus_to_dev(dhd_bus_t *bus)
        else
                return NULL;
 }
+
 #ifdef HOFFLOAD_MODULES
 void
 dhd_free_module_memory(struct dhd_bus *bus, struct module_metadata *hmem)