modify 3.0LTS code

Signed-off-by: jifengfei <jifengfei2@huawei.com>
This commit is contained in:
jifengfei
2021-11-16 16:47:40 +08:00
parent bc3892d61c
commit 2d3c3af53e
4 changed files with 16 additions and 10 deletions
@@ -299,7 +299,7 @@ BASE_CONFIG_EXIT:
(void)memset_s(&drvData->accelCfg->sensorInfo, sizeof(struct SensorBasicInfo), 0, sizeof(struct SensorBasicInfo));
(void)memset_s(&drvData->accelCfg->busCfg, sizeof(struct SensorBusCfg), 0, sizeof(struct SensorBusCfg));
(void)memset_s(&drvData->accelCfg->sensorAttr, sizeof(struct SensorAttr), 0, sizeof(struct SensorAttr));
return NULL;
return drvData->accelCfg;
}
void AccelReleaseCfgData(struct SensorCfgData *accelCfg)
@@ -346,7 +346,7 @@ void AccelReleaseDriver(struct HdfDeviceObject *device)
struct AccelDrvData *drvData = (struct AccelDrvData *)device->service;
CHECK_NULL_PTR_RETURN(drvData);
if (drvData->detectFlag) {
if (drvData->detectFlag && drvData->accelCfg != NULL) {
AccelReleaseCfgData(drvData->accelCfg);
}
@@ -300,7 +300,7 @@ BASE_CONFIG_EXIT:
sizeof(struct SensorBasicInfo));
(void)memset_s(&drvData->barometerCfg->busCfg, sizeof(struct SensorBusCfg), 0, sizeof(struct SensorBusCfg));
(void)memset_s(&drvData->barometerCfg->sensorAttr, sizeof(struct SensorAttr), 0, sizeof(struct SensorAttr));
return NULL;
return drvData->barometerCfg;
}
void BarometerReleaseCfgData(struct SensorCfgData *barometerCfg)
@@ -347,7 +347,7 @@ void BarometerReleaseDriver(struct HdfDeviceObject *device)
struct BarometerDrvData *drvData = (struct BarometerDrvData *)device->service;
CHECK_NULL_PTR_RETURN(drvData);
if (drvData->detectFlag) {
if (drvData->detectFlag && drvData->barometerCfg != NULL) {
BarometerReleaseCfgData(drvData->barometerCfg);
}
@@ -187,7 +187,8 @@ int32_t Bmi160InitDriver(struct HdfDeviceObject *device)
}
drvData->sensorCfg = AccelCreateCfgData(device->property);
if (drvData->sensorCfg == NULL) {
if (drvData->sensorCfg == NULL || drvData->sensorCfg->root == NULL) {
HDF_LOGD("%s: Creating accelcfg failed because detection failed", __func__);
return HDF_ERR_NOT_SUPPORT;
}
@@ -215,8 +216,10 @@ void Bmi160ReleaseDriver(struct HdfDeviceObject *device)
struct Bmi160DrvData *drvData = (struct Bmi160DrvData *)device->service;
CHECK_NULL_PTR_RETURN(drvData);
AccelReleaseCfgData(drvData->sensorCfg);
drvData->sensorCfg = NULL;
if (drvData->sensorCfg != NULL) {
AccelReleaseCfgData(drvData->sensorCfg);
drvData->sensorCfg = NULL;
}
OsalMemFree(drvData);
}
@@ -367,7 +367,8 @@ int32_t Bmp180InitDriver(struct HdfDeviceObject *device)
}
drvData->sensorCfg = BarometerCreateCfgData(device->property);
if (drvData->sensorCfg == NULL) {
if (drvData->sensorCfg == NULL || drvData->sensorCfg->root == NULL) {
HDF_LOGD("%s: Creating barometercfg failed because detection failed", __func__);
return HDF_ERR_NOT_SUPPORT;
}
@@ -395,8 +396,10 @@ void Bmp180ReleaseDriver(struct HdfDeviceObject *device)
struct Bmp180DrvData *drvData = (struct Bmp180DrvData *)device->service;
CHECK_NULL_PTR_RETURN(drvData);
BarometerReleaseCfgData(drvData->sensorCfg);
drvData->sensorCfg = NULL;
if (drvData->sensorCfg != NULL) {
BarometerReleaseCfgData(drvData->sensorCfg);
drvData->sensorCfg = NULL;
}
OsalMemFree(drvData);
}