mirror of
https://github.com/openharmony/drivers_framework.git
synced 2026-08-26 18:17:07 -04:00
!101 fix DeviceNode release interface not called issue
Merge pull request !101 from yuanbo/master
This commit is contained in:
@@ -17,15 +17,15 @@
|
||||
|
||||
#define HDF_LOG_TAG devhost_service
|
||||
|
||||
static struct HdfDevice *DevHostServiceFindDevice(struct DevHostService *inst, uint16_t deviceId)
|
||||
static struct HdfDevice *DevHostServiceFindDevice(struct DevHostService *hostService, uint16_t deviceId)
|
||||
{
|
||||
struct HdfDevice *deviceNode = NULL;
|
||||
if (inst == NULL) {
|
||||
HDF_LOGE("failed to find driver, inst is null");
|
||||
if (hostService == NULL) {
|
||||
HDF_LOGE("failed to find driver, hostService is null");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DLIST_FOR_EACH_ENTRY(deviceNode, &inst->devices, struct HdfDevice, node) {
|
||||
DLIST_FOR_EACH_ENTRY(deviceNode, &hostService->devices, struct HdfDevice, node) {
|
||||
if (deviceNode->deviceId == deviceId) {
|
||||
return deviceNode;
|
||||
}
|
||||
@@ -33,12 +33,12 @@ static struct HdfDevice *DevHostServiceFindDevice(struct DevHostService *inst, u
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void DevHostServiceFreeDevice(struct DevHostService *inst, uint16_t deviceId)
|
||||
static void DevHostServiceFreeDevice(struct DevHostService *hostService, uint16_t deviceId)
|
||||
{
|
||||
struct HdfDevice *deviceNode = DevHostServiceFindDevice(inst, deviceId);
|
||||
if (deviceNode != NULL) {
|
||||
DListRemove(&deviceNode->node);
|
||||
HdfDeviceFreeInstance(deviceNode);
|
||||
struct HdfDevice *device = DevHostServiceFindDevice(hostService, deviceId);
|
||||
if (device != NULL) {
|
||||
DListRemove(&device->node);
|
||||
HdfDeviceFreeInstance(device);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,9 +90,7 @@ int DevHostServiceAddDevice(struct IDevHostService *inst, const struct HdfDevice
|
||||
return HDF_SUCCESS;
|
||||
|
||||
error:
|
||||
if (DListIsEmpty(&hostService->devices)) {
|
||||
DevHostServiceFreeDevice(hostService, hostService->hostId);
|
||||
}
|
||||
DevHostServiceFreeDevice(hostService, device->deviceId);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ struct HdfDevice *HdfDeviceNewInstance()
|
||||
void HdfDeviceFreeInstance(struct HdfDevice *device)
|
||||
{
|
||||
if (device != NULL) {
|
||||
HdfObjectManagerFreeObject((struct HdfObject *)device);
|
||||
HdfObjectManagerFreeObject(&device->super.object);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,24 +86,15 @@ int HdfDeviceLaunchNode(struct HdfDeviceNode *devNode, struct IHdfDevice *devIns
|
||||
}
|
||||
int ret = driverEntry->Init(&devNode->deviceObject);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
if (driverEntry->Release != NULL) {
|
||||
driverEntry->Release(&devNode->deviceObject);
|
||||
}
|
||||
return HDF_DEV_ERR_DEV_INIT_FAIL;
|
||||
}
|
||||
ret = HdfDeviceNodePublishService(devNode, deviceInfo, devInst);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
if (driverEntry->Release != NULL) {
|
||||
driverEntry->Release(&devNode->deviceObject);
|
||||
}
|
||||
return HDF_DEV_ERR_PUBLISH_FAIL;
|
||||
}
|
||||
deviceToken = devNode->token;
|
||||
ret = DevmgrServiceClntAttachDevice(deviceInfo, deviceToken);
|
||||
if (ret != HDF_SUCCESS) {
|
||||
if (driverEntry->Release != NULL) {
|
||||
driverEntry->Release(&devNode->deviceObject);
|
||||
}
|
||||
return HDF_DEV_ERR_ATTACHDEV_FAIL;
|
||||
}
|
||||
return ret;
|
||||
@@ -186,6 +177,9 @@ void HdfDeviceNodeDelete(struct HdfSListNode *deviceEntry)
|
||||
}
|
||||
struct HdfDeviceNode *devNode =
|
||||
HDF_SLIST_CONTAINER_OF(struct HdfSListNode, deviceEntry, struct HdfDeviceNode, entry);
|
||||
if (devNode->driverEntry->Release != NULL) {
|
||||
devNode->driverEntry->Release(&devNode->deviceObject);
|
||||
}
|
||||
HdfDeviceNodeFreeInstance(devNode);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user