int rtw_init_cmd_priv(struct cmd_priv *pcmdpriv)
 {
-       sema_init(&(pcmdpriv->cmd_queue_sema), 0);
+       init_completion(&pcmdpriv->cmd_queue_comp);
        sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0);
 
        _rtw_init_queue(&(pcmdpriv->cmd_queue));
        res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj);
 
        if (res == _SUCCESS)
-               up(&pcmdpriv->cmd_queue_sema);
+               complete(&pcmdpriv->cmd_queue_comp);
 
 exit:
 
        RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n"));
 
        while (1) {
-               if (_rtw_down_sema(&pcmdpriv->cmd_queue_sema) == _FAIL)
+               if (wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp))
                        break;
 
                if (padapter->bDriverStopped ||
 
        RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_stop_drv_threads\n"));
 
        /* Below is to terminate rtw_cmd_thread & event_thread... */
-       up(&padapter->cmdpriv.cmd_queue_sema);
+       complete(&padapter->cmdpriv.cmd_queue_comp);
        if (padapter->cmdThread)
                _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);