Exemplo n.º 1
0
/** 
 * \fn     wlanDrvIf_Destroy
 * \brief  Destroy the driver instance
 * 
 * Destroy all driver modules.
 * Release driver OS resources (IRQ, workqueue, events socket)
 * Release driver network interface.
 * Free init files memory.
 * Free driver object.
 *
 * \note   
 * \param  drv - The driver object handle
 * \return void
 * \sa     wlanDrvIf_Create
 */ 
static void wlanDrvIf_Destroy (TWlanDrvIfObj *drv)
{
    /* Release the driver network interface */
    if (drv->netdev)
    {
        netif_stop_queue  (drv->netdev);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
        wlanDrvIf_Stop    (drv->netdev);
#endif
        unregister_netdev (drv->netdev);
        free_netdev(drv->netdev);
    }

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,21))
    cancel_work_sync (&drv->tWork); 
#else
    cancel_delayed_work (&drv->tWork);
#endif
    flush_workqueue (drv->pWorkQueue);
    destroy_workqueue (drv->pWorkQueue);

    /* Destroy all driver modules */
    if (drv->tCommon.hDrvMain)
    {
        drvMain_Destroy (drv->tCommon.hDrvMain);
    }

    /* close the ipc_kernel socket*/
    if (drv && drv->wl_sock) 
    {
        sock_release (drv->wl_sock->sk_socket);
    }

    /* Release the driver interrupt (or polling timer) */
#ifdef PRIODIC_INTERRUPT
    os_timerDestroy (drv, drv->hPollTimer);
#else
    if (drv->irq)
    {
        free_irq (drv->irq, drv);
	drv->irq=NULL;
        hPlatform_freeInterrupt ();
    }
#endif

    /* 
     *  Free init files memory
     */
    if (drv->tCommon.tFwImage.pImage)
    {
        os_memoryFree (drv, drv->tCommon.tFwImage.pImage, drv->tCommon.tFwImage.uSize);
        #ifdef TI_MEM_ALLOC_TRACE        
          os_printf ("MTT:%s:%d ::kfree(0x%p) : %d\n", 
              __FUNCTION__, __LINE__, drv->tCommon.tFwImage.uSize, -drv->tCommon.tFwImage.uSize);
        #endif
    }
    if (drv->tCommon.tNvsImage.pImage)
    {
        kfree (drv->tCommon.tNvsImage.pImage);
        #ifdef TI_MEM_ALLOC_TRACE        
          os_printf ("MTT:%s:%d ::kfree(0x%p) : %d\n", 
              __FUNCTION__, __LINE__, drv->tCommon.tNvsImage.uSize, -drv->tCommon.tNvsImage.uSize);
        #endif
    }
    if (drv->tCommon.tIniFile.pImage)
    {
        kfree (drv->tCommon.tIniFile.pImage);
        #ifdef TI_MEM_ALLOC_TRACE        
          os_printf ("MTT:%s:%d ::kfree(0x%p) : %d\n", 
              __FUNCTION__, __LINE__, drv->tCommon.tIniFile.uSize, -drv->tCommon.tIniFile.uSize);
        #endif
    }

    /* Free the driver object */
#ifdef TI_DBG
    tb_destroy();
#endif  
    kfree (drv);
}
/** 
 * \fn     wlanDrvIf_Destroy
 * \brief  Destroy the driver instance
 * 
 * Destroy all driver modules.
 * Release driver OS resources (IRQ, workqueue, events socket)
 * Release driver network interface.
 * Free init files memory.
 * Free driver object.
 *
 * \note   
 * \param  drv - The driver object handle
 * \return void
 * \sa     wlanDrvIf_Create
 */ 
static void wlanDrvIf_Destroy (TWlanDrvIfObj *drv)
{
	if (!drv)
		return;

	if (drv->tiwlan_wq) {
		cancel_work_sync(&drv->tWork);
		flush_workqueue(drv->tiwlan_wq);
	}

	/* Release the driver network interface */
	if (drv->netdev) {
		netif_stop_queue  (drv->netdev);
		wlanDrvIf_Stop    (drv->netdev);
		unregister_netdev (drv->netdev);
		free_netdev (drv->netdev);
	}

	/* Destroy all driver modules */
	if (drv->tCommon.hDrvMain) {
		drvMain_Destroy (drv->tCommon.hDrvMain);
	}

	/* close the ipc_kernel socket*/
	if (drv && drv->wl_sock) 
	{
		sock_release (drv->wl_sock->sk_socket);
	}
	/* Release the driver interrupt (or polling timer) */
#ifdef PRIODIC_INTERRUPT
	os_timerDestroy (drv, drv->hPollTimer);
#else
	if (drv->irq)
	{
		hPlatform_freeInterrupt(drv);
	}
#endif

	if (drv->tiwlan_wq)
		destroy_workqueue(drv->tiwlan_wq);
		
#ifdef CONFIG_HAS_WAKELOCK
	wake_lock_destroy(&drv->wl_wifi);
	wake_lock_destroy(&drv->wl_rxwake);
#endif
	/* 
	 *  Free init files memory
	 */
    if (drv->tCommon.tFwImage.pImage)
    {
        os_memoryFree (drv, drv->tCommon.tFwImage.pImage, drv->tCommon.tFwImage.uSize);
        #ifdef TI_MEM_ALLOC_TRACE        
          os_printf ("MTT:%s:%d ::kfree(0x%p) : %d\n", 
              __FUNCTION__, __LINE__, drv->tCommon.tFwImage.uSize, -drv->tCommon.tFwImage.uSize);
        #endif
    }
    if (drv->tCommon.tNvsImage.pImage)
    {
        kfree (drv->tCommon.tNvsImage.pImage);
        #ifdef TI_MEM_ALLOC_TRACE        
          os_printf ("MTT:%s:%d ::kfree(0x%p) : %d\n", 
              __FUNCTION__, __LINE__, drv->tCommon.tNvsImage.uSize, -drv->tCommon.tNvsImage.uSize);
        #endif
    }
    if (drv->tCommon.tIniFile.pImage)
    {
        kfree (drv->tCommon.tIniFile.pImage);
        #ifdef TI_MEM_ALLOC_TRACE        
          os_printf ("MTT:%s:%d ::kfree(0x%p) : %d\n", 
              __FUNCTION__, __LINE__, drv->tCommon.tIniFile.uSize, -drv->tCommon.tIniFile.uSize);
        #endif
    }
    /* Free the driver object */
#ifdef TI_DBG
	tb_destroy();
#endif
	kfree (drv);
}