inline MCDAQ_t::~MCDAQ_t() { int ret; mc_free_sample(&sample); ret = mc_close_device(&dev); if(ret!=MC_SUCCESS) throw error_t(ret); }
void close_dev() { int ret; ret = mc_close_device(&daq); if(ret!=MC_SUCCESS) { //mc_perror(ret, "Could not close device"); exit(ret); } }
//Close trustlet and driver static int secwidevinemdw_session_close(void) { enum mc_result mc_ret = MC_DRV_OK; mutex_lock(&secwidevinemdw_lock); do { /* session is already closed ? */ if (secwidevinemdw_session_ref == 0) { MSG(WRN, "secwidevinemdw_session already closed\n"); break; } if (secwidevinemdw_session_ref > 1) { secwidevinemdw_session_ref--; break; } /* close session */ mc_ret = mc_close_session(&secwidevinemdwdr_session); /* free WSM for DCI */ mc_ret = mc_free_wsm(secwidevinemdw_devid, (uint8_t*) secwidevinemdw_dci); secwidevinemdw_dci = NULL; secwidevinemdw_session_ref = 0; /* close device */ mc_ret = mc_close_device(secwidevinemdw_devid); if (MC_DRV_OK != mc_ret) { MSG(ERR, "mc_close_device failed: %d\n", mc_ret); } } while(0); MSG(INFO, "secwidevinemdw_session_close: ret=%d, ref=%d\n", mc_ret, secwidevinemdw_session_ref); mutex_unlock(&secwidevinemdw_lock); if (MC_DRV_OK != mc_ret) { return -ENXIO; } return 0; }
/* ------------------------------------------------------------- */ static void tlcClose(void) { enum mc_result ret; pr_debug("tlcClose: Closing driver session\n"); tlcCloseDriver(); pr_debug("tlcClose: Closing tbase\n"); /* Close the tbase device */ ret = mc_close_device(DEVICE_ID); if (MC_DRV_OK != ret) { pr_debug("ERROR tlcClose: Closing tbase device failed: %d\n", ret); } }
/* DO NOT invoke this function unless you get HACC lock */ int close_sdriver_connection(void) { enum mc_result mcRet = 0; do { /* Close session*/ mcRet = mc_close_session(&drSessionHandle); if (MC_DRV_OK != mcRet) { printk("NWD HACC: mc_close_session failed: %d\n", mcRet); break; } printk("NWD HACC: mc_close_session success: %d\n", mcRet); memset(&drSessionHandle, 0, sizeof(drSessionHandle)); /* Free WSM for DCI */ mcRet = mc_free_wsm(deviceId, (uint8_t *)pTci); if (MC_DRV_OK != mcRet) { printk("NWD HACC: mc_free_wsm failed: %d\n", mcRet); break; } pTci = NULL; /* Close MobiCore device */ mcRet = mc_close_device(deviceId); if (MC_DRV_OK != mcRet) { printk("NWD HACC: mc_close_device failed: %d\n", mcRet); break; } printk("NWD HACC: mc_close_device success: %d\n", mcRet); }while(false); if (MC_DRV_OK != mcRet) { return -1; } return 0; }
int32_t cmdq_sec_close_mobicore_impl(const uint32_t deviceId, const uint32_t openMobicoreByOther) { int32_t status = 0; enum mc_result mcRet = 0; if (1 == openMobicoreByOther) { /* do nothing */ /* let last user to close mobicore.... */ CMDQ_MSG("[SEC]_MOBICORE_CLOSE: opened by other, bypass device close\n"); } else { mcRet = mc_close_device(deviceId); CMDQ_MSG("[SEC]_MOBICORE_CLOSE: status[%d], ret[%0x], openMobicoreByOther[%d]\n", status, mcRet, openMobicoreByOther); if (MC_DRV_OK != mcRet) { CMDQ_ERR("[SEC]_MOBICORE_CLOSE: err[0x%x]\n", mcRet); status = -1; } } return status; }
//Open driver in open static int secwidevine_session_open(void) { enum mc_result mc_ret = MC_DRV_OK; mutex_lock(&secwidevine_lock); do { /* sessions reach max numbers ? */ if (secwidevine_session_ref > MAX_OPEN_SESSIONS) { MSG(WRN, "secwidevine_session > 0x%x\n", MAX_OPEN_SESSIONS); break; } if (secwidevine_session_ref > 0) { secwidevine_session_ref++; break; } /* open device */ mc_ret = mc_open_device(secwidevine_devid); if (MC_DRV_OK != mc_ret) { MSG(ERR, "mc_open_device failed: %d\n", mc_ret); break; } /* allocating WSM for DCI */ /*//open trustlet mc_ret = mc_malloc_wsm(secwidevine_devid, 0, sizeof(tci_t), (uint8_t **)&secwidevine_tci, 0); if (MC_DRV_OK != mc_ret) { mc_close_device(secwidevine_devid); MSG(ERR, "mc_malloc_wsm failed: %d\n", mc_ret); break; } // open session secwidevine_session.device_id = secwidevine_devid; mc_ret = mc_open_session(&secwidevine_session, &secwidevine_uuid, (uint8_t *)secwidevine_tci, sizeof(tci_t)); if (MC_DRV_OK != mc_ret) { mc_free_wsm(secwidevine_devid, (uint8_t *)secwidevine_tci); secwidevine_tci = NULL; mc_close_device(secwidevine_devid); MSG(ERR, "mc_open_session failed: %d\n", mc_ret); break; }*/ //open driver mc_ret = mc_malloc_wsm(secwidevine_devid, 0, sizeof(tci_t), (uint8_t **) &secwidevinedr_tci, 0); if (MC_DRV_OK != mc_ret) { /*mc_free_wsm(secwidevine_devid, (uint8_t *) secwidevine_tci); secwidevine_tci = NULL;*/ mc_close_device(secwidevine_devid); MSG(ERR, "2.mc_malloc_wsm failed: %d\n", mc_ret); break; } /* open session */ secwidevinedr_session.device_id = secwidevine_devid; mc_ret = mc_open_session(&secwidevinedr_session, &secwidevinedr_uuid, (uint8_t *) secwidevinedr_tci, sizeof(tci_t)); if (MC_DRV_OK != mc_ret) { /* mc_free_wsm(secwidevine_devid, (uint8_t *) secwidevine_tci); secwidevine_tci = NULL;*/ mc_free_wsm(secwidevine_devid, (uint8_t *) secwidevinedr_tci); secwidevinedr_tci = NULL; mc_close_device(secwidevine_devid); MSG(ERR, "2.mc_open_session failed: %d\n", mc_ret); break; } secwidevine_session_ref = 1; } while(0); MSG(INFO, "secwidevine_session_open: ret=%d, ref=%d\n", mc_ret, secwidevine_session_ref); MSG(INFO, "driver sessionId = %d, deviceId = %d\n", secwidevinedr_session.session_id, secwidevinedr_session.device_id); mutex_unlock(&secwidevine_lock); if (MC_DRV_OK != mc_ret) { MSG(ERR, "secwidevine_session_open fail"); return -ENXIO; } return 0; }
//Open driver in open static int secwidevinemdw_session_open(void) { enum mc_result mc_ret = MC_DRV_OK; mutex_lock(&secwidevinemdw_lock); do { /* sessions reach max numbers ? */ if (secwidevinemdw_session_ref > MAX_OPEN_SESSIONS) { MSG(WRN, "secwidevinemdw_session > 0x%x\n", MAX_OPEN_SESSIONS); break; } if (secwidevinemdw_session_ref > 0) { MSG(WRN, "secwidevinemdw_session already open"); secwidevinemdw_session_ref++; break; } /* open device */ mc_ret = mc_open_device(secwidevinemdw_devid); if (MC_DRV_OK != mc_ret) { MSG(ERR, "mc_open_device failed: %d\n", mc_ret); break; } /* allocating WSM for DCI */ mc_ret = mc_malloc_wsm(secwidevinemdw_devid, 0, sizeof(dciMessage_t), (uint8_t **)&secwidevinemdw_dci, 0); if (MC_DRV_OK != mc_ret) { mc_close_device(secwidevinemdw_devid); MSG(ERR, "mc_malloc_wsm failed: %d\n", mc_ret); break; } // open session secwidevinemdwdr_session.device_id = secwidevinemdw_devid; mc_ret = mc_open_session(&secwidevinemdwdr_session, &secwidevinemdw_uuid, (uint8_t *)secwidevinemdw_dci, sizeof(dciMessage_t)); if (MC_DRV_OK != mc_ret) { mc_free_wsm(secwidevinemdw_devid, (uint8_t *)secwidevinemdw_dci); secwidevinemdw_dci = NULL; mc_close_device(secwidevinemdw_devid); MSG(ERR, "mc_open_session failed: %d\n", mc_ret); break; } /* create a thread for listening DCI signals */ secwidevinemdwDci_th = kthread_run(secwidevinemdw_listenDci, NULL, "secwidevinemdw_Dci"); if (IS_ERR(secwidevinemdwDci_th)) { mc_close_session(&secwidevinemdwdr_session); mc_free_wsm(secwidevinemdw_devid, (uint8_t *) secwidevinemdw_dci); secwidevinemdw_dci = NULL; mc_close_device(secwidevinemdw_devid); MSG(ERR, "%s, init kthread_run failed!\n", __func__); break; } secwidevinemdw_session_ref = 1; } while(0); MSG(INFO, "secwidevinemdw_session_open: ret=%d, ref=%d\n", mc_ret, secwidevinemdw_session_ref); MSG(INFO, "driver sessionId = %d, deviceId = %d\n", secwidevinemdwdr_session.session_id, secwidevinemdwdr_session.device_id); mutex_unlock(&secwidevinemdw_lock); if (MC_DRV_OK != mc_ret) { MSG(ERR, "secwidevinemdw_session_open fail"); return -ENXIO; } return 0; }