From 87fd7cec7feb48ebd07ff420cee60fa2020cd52d Mon Sep 17 00:00:00 2001 From: yinshuqing Date: Fri, 23 Jul 2021 10:04:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86platform=5Fdevice.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yinshuqing --- support/platform/src/common/platform_device.c | 11 +++++------ support/platform/src/common/platform_manager.c | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) mode change 100644 => 100755 support/platform/src/common/platform_device.c diff --git a/support/platform/src/common/platform_device.c b/support/platform/src/common/platform_device.c old mode 100644 new mode 100755 index 62050c05..73484556 --- a/support/platform/src/common/platform_device.c +++ b/support/platform/src/common/platform_device.c @@ -38,7 +38,7 @@ static void PlatformDeviceOnLastPut(struct HdfSRef *sref) device->ready = false; DLIST_FOR_EACH_ENTRY_SAFE(pos, tmp, &device->notifiers, struct PlatformNotifierNode, node) { - if (pos!=NULL && pos->notifier != NULL && pos->notifier->handle != NULL) { + if (pos->notifier != NULL && pos->notifier->handle != NULL) { pos->notifier->handle(device, PLAT_EVENT_DEAD, pos->notifier->data); } } @@ -155,13 +155,12 @@ static void PlatformDeviceRemoveNotifier(struct PlatformDevice *device, struct P DLIST_FOR_EACH_ENTRY_SAFE(pos, tmp, &device->notifiers, struct PlatformNotifierNode, node) { if (pos->notifier != NULL) { /* if notifier not set, we remove all the notifier nodes. */ + if (notifier == NULL || notifier == pos->notifier) { + DListRemove(&pos->node); + OsalMemFree(pos); + } if (notifier == pos->notifier) { - DListRemove(&pos->node); - OsalMemFree(pos); break; - }else if (notifier == NULL) { - DListRemove(&pos->node); - OsalMemFree(pos); } } } diff --git a/support/platform/src/common/platform_manager.c b/support/platform/src/common/platform_manager.c index 2dbc222d..0f3ccf66 100644 --- a/support/platform/src/common/platform_manager.c +++ b/support/platform/src/common/platform_manager.c @@ -78,7 +78,7 @@ int32_t PlatformManagerAddDevice(struct PlatformManager *manager, struct Platfor (void)OsalSpinLock(&manager->spin); DLIST_FOR_EACH_ENTRY(tmp, &manager->devices, struct PlatformDevice, node) { - if (tmp!=NULL && tmp->magic == device->magic) { + if (tmp != NULL && tmp->magic == device->magic) { repeatId = true; HDF_LOGE("PlatformManagerAddDevice: repeated magic:%u!", device->magic); break; @@ -130,7 +130,7 @@ struct PlatformDevice *PlatformManagerFindDevice(struct PlatformManager *manager (void)OsalSpinLock(&manager->spin); DLIST_FOR_EACH_ENTRY(tmp, &manager->devices, struct PlatformDevice, node) { - if (tmp!=NULL && match(tmp, data)) { + if (tmp != NULL && match(tmp, data)) { pdevice = PlatformDeviceGet(tmp); } }