INT32 wmt_ctrl_ul_cmd ( P_DEV_WMT pWmtDev, const UCHAR *pCmdStr ) { INT32 waitRet = -1; P_OSAL_SIGNAL pCmdSignal; P_OSAL_EVENT pCmdReq; if (osal_test_and_set_bit(WMT_STAT_CMD, &pWmtDev->state)) { WMT_WARN_FUNC("cmd buf is occupied by (%s) \n", pWmtDev->cCmd); return -1; } /* indicate baud rate change to user space app */ #if 0 INIT_COMPLETION(pWmtDev->cmd_comp); pWmtDev->cmd_result = -1; strncpy(pWmtDev->cCmd, pCmdStr, NAME_MAX); pWmtDev->cCmd[NAME_MAX] = '\0'; wake_up_interruptible(&pWmtDev->cmd_wq); #endif pCmdSignal = &pWmtDev->cmdResp; osal_signal_init(pCmdSignal); pCmdSignal->timeoutValue = 2000; osal_strncpy(pWmtDev->cCmd, pCmdStr, NAME_MAX); pWmtDev->cCmd[NAME_MAX] = '\0'; pCmdReq = &pWmtDev->cmdReq; osal_trigger_event(&pWmtDev->cmdReq); WMT_DBG_FUNC("str(%s) request ok\n", pCmdStr); // waitRet = wait_for_completion_interruptible_timeout(&pWmtDev->cmd_comp, msecs_to_jiffies(2000)); waitRet = osal_wait_for_signal_timeout(pCmdSignal); WMT_LOUD_FUNC("wait signal iRet:%d\n", waitRet); if (0 == waitRet) { WMT_ERR_FUNC("wait signal timeout \n"); return -2; } WMT_INFO_FUNC("str(%s) result(%d)\n", pCmdStr, pWmtDev->cmdResult); return pWmtDev->cmdResult; }
static INT32 mtk_wmt_func_on_background(void) { INT32 iRet = 0; OSAL_THREAD bgFuncOnThread; P_OSAL_THREAD pThread = &bgFuncOnThread; /* Create background power on thread */ osal_strncpy(pThread->threadName, ("mtk_wmtd_pwr_bg"), sizeof(pThread->threadName)); pThread->pThreadData = NULL; pThread->pThreadFunc = (VOID *)wmt_pwr_on_thread; iRet = osal_thread_create(pThread); if (iRet) { WMT_ERR_FUNC("osal_thread_create(0x%p) fail(%d)\n", pThread, iRet); return -1; } /* 3. start: start running background power on thread*/ iRet = osal_thread_run(pThread); if (iRet) { WMT_ERR_FUNC("osal_thread_run(0x%p) fail(%d)\n", pThread, iRet); return -2; } return 0; }