Platform/ECM3532/M3/framework/sensor_mgr/src/sensor.c
/**
 * DeRegister sensor driver to SM
 *
 * @param Name Sensor driver name
 * @param sDrvOps Sensor driver ops struture pointer
 *
 * @return 0 on success, negative error code on failure.
 */
DeRegister sensor driver to SM
@param Name Sensor driver name
@param sDrvOps Sensor driver ops struture pointer

@return 0 on success, negative error code on failure.
DeRegister sensor driver to SM @param Name Sensor driver name @param sDrvOps Sensor driver ops struture pointer @return 0 on success negative error code on failure .
int32_t SensorDrvDeRegister(char *Name)
{
    int ret = 0;
    tSensorDevice *sDev = NULL;
    uint8_t ui8Sidx, ui8Didx = 0;
    tDrvHandle sDrvHandle;
    for(ui8Sidx = 0; ui8Sidx < SENSOR_MAX_CNT; ui8Sidx++)
    {
        if(!strcmp(sSensorDevList[ui8Sidx].name, Name))
        {
            sDev =  &sSensorDevList[ui8Sidx];
            break;
        }
    }
    if (sDev)
    {
        for(ui8Didx = 0; ui8Didx < DRIVER_MAX_CNT; ui8Didx++)
        {
            if(sHandleMapList[ui8Didx].ui8SensorDevIndex == ui8Sidx)
            {
                sDrvHandle = sHandleMapList[ui8Didx].vDrvHandle;
                if (sDrvHandle != INVALID_HANDLE)
                {
                    xSemaphoreTake(SmLock, portMAX_DELAY);
                    ret = sDev->sDops->DrvClose(sDrvHandle);
                    if (ret >= 0 )
                    {
                        sHandleMapList[sDrvHandle].vDrvHandle = INVALID_HANDLE;
                    }
                    else
                    {
                        xSemaphoreGive(SmLock);
                        break;
                    }
                }
                xSemaphoreGive(SmLock);
            }
        }
        if (ret >= 0)
        {
            xSemaphoreTake(SmLock, portMAX_DELAY);
            sSensorDevList[ui8Sidx].name = NULL;
            sSensorDevList[ui8Sidx].sDops = NULL;
            xSemaphoreGive(SmLock);
        }
    }
    return ret;
}
int32_t SensorDrvDeRegister ( char * Name ) { int ret = 0 ; tSensorDevice * sDev = NULL ; uint8_t ui8Sidx , ui8Didx = 0 ; tDrvHandle sDrvHandle ; for ( ui8Sidx = 0 ; ui8Sidx < SENSOR_MAX_CNT ; ui8Sidx ++ ) { if ( ! strcmp ( sSensorDevList [ ui8Sidx ] . name , Name ) ) { sDev = & sSensorDevList [ ui8Sidx ] ; break ; } } if ( sDev ) { for ( ui8Didx = 0 ; ui8Didx < DRIVER_MAX_CNT ; ui8Didx ++ ) { if ( sHandleMapList [ ui8Didx ] . ui8SensorDevIndex == ui8Sidx ) { sDrvHandle = sHandleMapList [ ui8Didx ] . vDrvHandle ; if ( sDrvHandle != INVALID_HANDLE ) { xSemaphoreTake ( SmLock , portMAX_DELAY ) ; ret = sDev -> sDops -> DrvClose ( sDrvHandle ) ; if ( ret >= 0 ) { sHandleMapList [ sDrvHandle ] . vDrvHandle = INVALID_HANDLE ; } else { xSemaphoreGive ( SmLock ) ; break ; } } xSemaphoreGive ( SmLock ) ; } } if ( ret >= 0 ) { xSemaphoreTake ( SmLock , portMAX_DELAY ) ; sSensorDevList [ ui8Sidx ] . name = NULL ; sSensorDevList [ ui8Sidx ] . sDops = NULL ; xSemaphoreGive ( SmLock ) ; } } return ret ; }
DeRegister sensor driver to SM
 @param Name Sensor driver name
 @param sDrvOps Sensor driver ops struture pointer
DeRegister sensor driver to SM @param Name Sensor driver name @param sDrvOps Sensor driver ops struture pointer