From 003c4d6e134c519d7a9fc298a521adc39e7b0fb4 Mon Sep 17 00:00:00 2001 From: yinshuqing Date: Thu, 22 Jul 2021 21:30:22 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=91=8A=E8=AD=A6platform=5Fdevice=20platform=5Fmanager.c=20mm?= =?UTF-8?q?c=5Fif.c=20mmc=5Fprotocol.c=20uart=5Fcore.c=20i2c=5Ftest.c=20sp?= =?UTF-8?q?i=5Ftest.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 ++-- support/platform/src/mmc/mmc_if.c | 1 - support/platform/src/mmc/mmc_protocol.c | 3 ++- support/platform/src/uart_core.c | 1 + test/unittest/platform/common/i2c_test.c | 6 ++++++ test/unittest/platform/common/spi_test.c | 2 +- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/support/platform/src/common/platform_device.c b/support/platform/src/common/platform_device.c index 05ae7ea72..62050c05a 100644 --- 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!=NULL && pos->notifier != NULL && pos->notifier->handle != NULL) { pos->notifier->handle(device, PLAT_EVENT_DEAD, pos->notifier->data); } } @@ -153,14 +153,15 @@ static void PlatformDeviceRemoveNotifier(struct PlatformDevice *device, struct P (void)OsalSpinLock(&device->spin); DLIST_FOR_EACH_ENTRY_SAFE(pos, tmp, &device->notifiers, struct PlatformNotifierNode, node) { - if (pos != NULL && pos->notifier != NULL) { + if (pos->notifier != NULL) { /* if notifier not set, we remove all the notifier nodes. */ - if (notifier == NULL || notifier == pos->notifier) { + if (notifier == pos->notifier) { DListRemove(&pos->node); OsalMemFree(pos); - } - if (notifier == pos->notifier) { 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 0f3ccf662..2dbc222d6 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); } } diff --git a/support/platform/src/mmc/mmc_if.c b/support/platform/src/mmc/mmc_if.c index 8b37d0d79..dba2d503a 100644 --- a/support/platform/src/mmc/mmc_if.c +++ b/support/platform/src/mmc/mmc_if.c @@ -29,7 +29,6 @@ static void *MmcCntlrObjGetByNumber(int16_t id) char *serviceName = NULL; if (id < 0) { - HDF_LOGE("MmcCntlrObjGetByNumber: invalid id:%d", id); return NULL; } serviceName = OsalMemCalloc(MMC_SVC_NAME_LEN + 1); diff --git a/support/platform/src/mmc/mmc_protocol.c b/support/platform/src/mmc/mmc_protocol.c index 304c3e127..a2ee8cfcb 100644 --- a/support/platform/src/mmc/mmc_protocol.c +++ b/support/platform/src/mmc/mmc_protocol.c @@ -3494,7 +3494,7 @@ static void SdioDecodeCisTplManfId(struct MmcCntlr *cntlr, struct SdioFunction * */ vendorId = (tuple->tplBody[1] << BITS_PER_BYTE) | tuple->tplBody[0]; deviceId = (tuple->tplBody[3] << BITS_PER_BYTE) | tuple->tplBody[2]; - HDF_LOGD("Sdio vendorId = 0x%x, deviceId = 0x%x.", vendorId, deviceId); + /* function CISTPL_MANFID. */ if (function != NULL) { function->deviceId = deviceId; @@ -3838,6 +3838,7 @@ static int32_t SdioAddFunctions(struct MmcCntlr *cntlr, uint32_t funcs) } ret = SdioReadFbr(cntlr, function); if (ret != HDF_SUCCESS) { + SdioDeleteFunction(function); return ret; } ret = SdioReadCis(cntlr, function); diff --git a/support/platform/src/uart_core.c b/support/platform/src/uart_core.c index 71cfcb050..caf03d1aa 100644 --- a/support/platform/src/uart_core.c +++ b/support/platform/src/uart_core.c @@ -75,6 +75,7 @@ static int32_t UartUserRead(struct UartHost *host, struct HdfSBuf *reply) } if (!HdfSbufWriteBuffer(reply, buf, len)) { HDF_LOGE("%s: sbuf write buffer failed", __func__); + OsalMemFree(buf); return HDF_ERR_IO; } OsalMemFree(buf); diff --git a/test/unittest/platform/common/i2c_test.c b/test/unittest/platform/common/i2c_test.c index cba586b29..2c6a9ed04 100644 --- a/test/unittest/platform/common/i2c_test.c +++ b/test/unittest/platform/common/i2c_test.c @@ -75,6 +75,7 @@ static int32_t I2cTestGetConfig(struct I2cTestConfig *config) HdfSBufRecycle(reply); HDF_LOGD("I2cTestGetConfig: exit!"); + HdfIoServiceRecycle(service); return HDF_SUCCESS; } @@ -260,6 +261,7 @@ int32_t I2cTestMultiThread(void) ret = OsalThreadCreate(&thread2, (OsalThreadEntry)I2cTestThreadFunc, (void *)&count2); if (ret != HDF_SUCCESS) { + (void)OsalThreadDestroy(&thread1); HDF_LOGE("create test thread1 fail:%d", ret); return HDF_FAILURE; } @@ -271,12 +273,16 @@ int32_t I2cTestMultiThread(void) ret = OsalThreadStart(&thread1, &cfg1); if (ret != HDF_SUCCESS) { + (void)OsalThreadDestroy(&thread1); + (void)OsalThreadDestroy(&thread2); HDF_LOGE("start test thread1 fail:%d", ret); return HDF_FAILURE; } ret = OsalThreadStart(&thread2, &cfg2); if (ret != HDF_SUCCESS) { + (void)OsalThreadDestroy(&thread1); + (void)OsalThreadDestroy(&thread2); HDF_LOGE("start test thread2 fail:%d", ret); return HDF_FAILURE; } diff --git a/test/unittest/platform/common/spi_test.c b/test/unittest/platform/common/spi_test.c index 671d3fd4c..d1603ac08 100644 --- a/test/unittest/platform/common/spi_test.c +++ b/test/unittest/platform/common/spi_test.c @@ -175,7 +175,7 @@ static int32_t SpiSetDmaIntMsg(struct SpiMsg *msg, uint32_t len) return HDF_ERR_MALLOC_FAIL; } rbuf = (uint8_t *)OsalMemAllocAlign(DMA_ALIGN_SIZE, len); - if (wbuf == NULL) { + if (rbuf == NULL) { OsalMemFree(wbuf); return HDF_ERR_MALLOC_FAIL; } -- Gitee From 4a68366c7aa2f73e4c870ee5b0262d2e10d284d4 Mon Sep 17 00:00:00 2001 From: yinshuqing Date: Fri, 23 Jul 2021 10:04:01 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86platform=5Fdevic?= =?UTF-8?q?e.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 | 9 ++++----- support/platform/src/common/platform_manager.c | 4 ++-- 2 files changed, 6 insertions(+), 7 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 62050c05a..734845563 --- 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 == pos->notifier) { + if (notifier == NULL || notifier == pos->notifier) { DListRemove(&pos->node); OsalMemFree(pos); + } + if (notifier == pos->notifier) { 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 2dbc222d6..0f3ccf662 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); } } -- Gitee From 08446825d5658335ff741e22e567ca16da2fbdb4 Mon Sep 17 00:00:00 2001 From: yinshuqing Date: Fri, 23 Jul 2021 14:11:47 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86platform=5Fdevic?= =?UTF-8?q?e.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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/support/platform/src/common/platform_device.c b/support/platform/src/common/platform_device.c index 734845563..bd8e214a7 100755 --- a/support/platform/src/common/platform_device.c +++ b/support/platform/src/common/platform_device.c @@ -155,12 +155,13 @@ 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) { + if (notifier == pos->notifier) { + DListRemove(&pos->node); + OsalMemFree(pos); + break; + } else if (notifier == NULL) { DListRemove(&pos->node); OsalMemFree(pos); - } - if (notifier == pos->notifier) { - break; } } } -- Gitee