diff --git a/support/platform/src/dmac_core.c b/support/platform/src/dmac_core.c index 320fcf5cd211b17454d329990f335ec32aae1d90..b2b207b4c2696000d1129cc671c10ca5071dddda 100644 --- a/support/platform/src/dmac_core.c +++ b/support/platform/src/dmac_core.c @@ -6,16 +6,17 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include "dmac_core.h" #include #include "hdf_log.h" #include "osal_io.h" #include "osal_irq.h" #include "osal_mem.h" -#include "dmac_core.h" #define HDF_LOG_TAG dmac_core #define DMA_ALIGN_SIZE 256 +#define DMA_MAX_TRANS_SIZE_DEFAULT 256 static int DmacCheck(struct DmaCntlr *cntlr) { @@ -66,7 +67,7 @@ static void DmacFreeLli(struct DmacChanInfo *chanInfo) */ void DmaCntlrDestroy(struct DmaCntlr *cntlr) { - int i; + unsigned int i; if (cntlr == NULL || cntlr->channelNum > DMAC_CHAN_NUM_MAX) { HDF_LOGE("%s: cntlr null or channel invalid!", __func__); @@ -107,7 +108,7 @@ static void DmacCallbackHandle(struct DmacChanInfo *chanInfo) static int DmacWaitM2mSendComplete(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo) { - unsigned int ret; + uint32_t ret; if (DmacCheck(cntlr) != HDF_SUCCESS) { HDF_LOGE("check fail"); @@ -130,7 +131,7 @@ static int DmacWaitM2mSendComplete(struct DmaCntlr *cntlr, struct DmacChanInfo * static int DmacAllocateChannel(struct DmaCntlr *cntlr) { - unsigned int flags; + uint32_t flags; int i; if (DmacCheck(cntlr) != HDF_SUCCESS) { @@ -190,7 +191,7 @@ static struct DmacChanInfo *DmacRequestChannel(struct DmaCntlr *cntlr, HDF_LOGE("%s: get channel fail ret = %d", __func__, ret); return NULL; } - HDF_LOGD("channel = %d, transfer type = %d width = %u, config = 0x%x, lliflag = 0x%x", + HDF_LOGD("channel = %d, transfer type = %u width = %u, config = 0x%x, lliflag = 0x%x", ret, chanInfo->transferType, chanInfo->width, chanInfo->config, chanInfo->lliEnFlag); return chanInfo; } @@ -220,19 +221,13 @@ static int DmacFillLli(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, plli->count = cntlr->maxTransSize; } else { plli->nextLli = 0; - plli->count = (length % cntlr->maxTransSize); + plli->count = cntlr->maxTransSize == 0 ? length : (length % cntlr->maxTransSize); } plli->srcAddr = (long long)srcaddr; plli->destAddr = (long long)dstaddr; plli->config = chanInfo->config; - HDF_LOGD("plli->srcAddr = 0x%llx\n", plli->srcAddr); - HDF_LOGD("plli->destAddr = 0x%llx\n", plli->destAddr); - HDF_LOGD("plli->nextLli = 0x%llx\n", plli->nextLli); - HDF_LOGD("plli->config = 0x%x\n", plli->config); - HDF_LOGD("plli->count = 0x%x\n", plli->count); - if (chanInfo->transferType == TRASFER_TYPE_P2M) { dstaddr += plli->count; } else if (chanInfo->transferType == TRASFER_TYPE_M2P) { @@ -240,6 +235,7 @@ static int DmacFillLli(struct DmaCntlr *cntlr, struct DmacChanInfo *chanInfo, } plli++; } + plli = chanInfo->lli; cntlr->dmacCacheFlush((UINTPTR)plli, (UINTPTR)plli + (UINTPTR)(sizeof(struct DmacLli) * lliNum)); HDF_LOGD("alloc_addr = 0x%x, alloc_addr + (sizeof(DmacLli) * lli_num)= 0x%x\n", (UINTPTR)plli, (UINTPTR)plli + (UINTPTR)(sizeof(struct DmacLli) * lliNum)); @@ -369,6 +365,7 @@ static int DmacM2mTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg) return HDF_FAILURE; } if (dmaSize == 0) { + DmacFreeChannel(cntlr, chanInfo->channel); return HDF_FAILURE; } leftSize -= dmaSize; @@ -403,7 +400,7 @@ int32_t DmaCntlrTransfer(struct DmaCntlr *cntlr, struct DmacMsg *msg) } else if (msg->direct == TRASFER_TYPE_M2M) { return DmacM2mTransfer(cntlr, msg); } else { - HDF_LOGE("%s: invalid direct %d", __func__, msg->direct); + HDF_LOGE("%s: invalid direct %u", __func__, msg->direct); return HDF_FAILURE; } return DmacPeriphTransfer(cntlr, msg, periphAddr); @@ -419,7 +416,7 @@ unsigned int DmaGetCurrChanDestAddr(struct DmaCntlr *cntlr, unsigned int chan) return cntlr->dmacGetCurrDestAddr(cntlr, chan); } -static uint32_t DmacIsr(int irq, void *dev) +static uint32_t DmacIsr(uint32_t irq, void *dev) { struct DmaCntlr *cntlr = (struct DmaCntlr *)dev; unsigned int channelStatus; @@ -431,9 +428,9 @@ static uint32_t DmacIsr(int irq, void *dev) } if (irq != cntlr->irq || cntlr->channelNum > DMAC_CHAN_NUM_MAX) { - HDF_LOGE("%s: cntlr parm err! irq:%d, channel:%u", + HDF_LOGE("%s: cntlr param err! irq:%u, channel:%u", __func__, cntlr->irq, cntlr->channelNum); - return HDF_SUCCESS; + return HDF_ERR_INVALID_PARAM; } for (i = 0; i < cntlr->channelNum; i++) { channelStatus = cntlr->dmacGetChanStatus(cntlr, i); @@ -455,15 +452,19 @@ int DmacInit(struct DmaCntlr *cntlr) HDF_LOGE("check fail"); return HDF_FAILURE; } - if (cntlr->channelNum > DMAC_CHAN_NUM_MAX) { - HDF_LOGE("%s: invalid channel:%d", __func__, cntlr->channelNum); + if (cntlr->channelNum == 0 || cntlr->channelNum > DMAC_CHAN_NUM_MAX) { + HDF_LOGE("%s: invalid channel:%u", __func__, cntlr->channelNum); return HDF_FAILURE; } + if (cntlr->maxTransSize == 0) { + cntlr->maxTransSize = DMA_MAX_TRANS_SIZE_DEFAULT; + } cntlr->remapBase = (char *)OsalIoRemap((unsigned long)cntlr->phyBase, (unsigned long)cntlr->regSize); - OsalSpinInit(&cntlr->lock); + (void)OsalSpinInit(&cntlr->lock); cntlr->channelList = (struct DmacChanInfo *)OsalMemCalloc(sizeof(struct DmacChanInfo) * cntlr->channelNum); if (cntlr->channelList == NULL) { HDF_LOGE("channel list malloc fail"); + (void)OsalSpinDestroy(&cntlr->lock); OsalIoUnmap((void *)cntlr->remapBase); return HDF_FAILURE; } @@ -474,9 +475,10 @@ int DmacInit(struct DmaCntlr *cntlr) } ret = OsalRegisterIrq(cntlr->irq, 0, (OsalIRQHandle)DmacIsr, "PlatDmac", cntlr); if (ret != HDF_SUCCESS) { - HDF_LOGE("DMA Irq %d request failed, ret = %d\n", cntlr->irq, ret); + HDF_LOGE("DMA Irq %u request failed, ret = %d\n", cntlr->irq, ret); OsalMemFree(cntlr->channelList); cntlr->channelList = NULL; + (void)OsalSpinDestroy(&cntlr->lock); OsalIoUnmap((void *)cntlr->remapBase); } return ret; diff --git a/support/platform/src/emmc_core.c b/support/platform/src/emmc_core.c index b30cc433f1aeceea257f2cb470d972c4791a0478..91c0061c86461d9b94b5143b16771725d431db84 100644 --- a/support/platform/src/emmc_core.c +++ b/support/platform/src/emmc_core.c @@ -6,8 +6,8 @@ * See the LICENSE file in the root of this repository for complete details. */ -#include "device_resource_if.h" #include "emmc_core.h" +#include "device_resource_if.h" #include "hdf_log.h" #include "osal_mem.h" @@ -16,11 +16,11 @@ int32_t EmmcCntlrFindHost(struct EmmcCntlr *cntlr) { if (cntlr == NULL || cntlr->method == NULL || cntlr->method->findHost == NULL) { - HDF_LOGE("EmmcCntlrFindHost: cntlr or method or findHost is NULL!"); + HDF_LOGE("EmmcCntlrFindHost: cntlr or method or findHost is null!"); return HDF_ERR_INVALID_PARAM; } if (cntlr->method->findHost(cntlr, &(cntlr->configData)) != HDF_SUCCESS) { - HDF_LOGE("EmmcCntlrFindHost: findHost fail!"); + HDF_LOGE("EmmcCntlrFindHost: findHost failed"); return HDF_ERR_INVALID_OBJECT; } return HDF_SUCCESS; @@ -42,8 +42,8 @@ int32_t EmmcCntlrGetCid(struct EmmcCntlr *cntlr, uint8_t *cid, uint32_t size) static int32_t EmmcGetCidWriteBackReply(struct HdfSBuf *reply, uint8_t *cid, uint32_t size) { - if (HdfSbufWriteBuffer(reply, cid, size) == false) { - HDF_LOGE("EmmcGetCidWriteBackReply: write to reply fail!"); + if (!HdfSbufWriteBuffer(reply, cid, size)) { + HDF_LOGE("EmmcGetCidWriteBackReply: write to reply failed"); return HDF_ERR_IO; } return HDF_SUCCESS; @@ -56,7 +56,7 @@ static int32_t EmmcGetCidDispatch(struct EmmcCntlr *cntlr, struct HdfSBuf *reply ret = EmmcCntlrGetCid(cntlr, cid, EMMC_CID_LEN); if (ret != HDF_SUCCESS) { - HDF_LOGE("EmmcGetCidDispatch: EmmcCntlrGetCid fail!"); + HDF_LOGE("EmmcGetCidDispatch: EmmcCntlrGetCid failed"); return ret; } return EmmcGetCidWriteBackReply(reply, cid, EMMC_CID_LEN); @@ -69,23 +69,23 @@ static int32_t EmmcIoDispatch(struct HdfDeviceIoClient *client, int cmd, struct (void)data; if (client == NULL || client->device == NULL) { - HDF_LOGE("EmmcIoDispatch: client or client->device is NULL"); + HDF_LOGE("EmmcIoDispatch: client or client->device is null"); return HDF_ERR_INVALID_OBJECT; } if (reply == NULL) { - HDF_LOGE("EmmcIoDispatch: reply is NULL"); + HDF_LOGE("EmmcIoDispatch: reply is null"); return HDF_ERR_INVALID_PARAM; } cntlr = (struct EmmcCntlr *)client->device->service; if (cntlr == NULL) { - HDF_LOGE("EmmcIoDispatch: service is NULL"); + HDF_LOGE("EmmcIoDispatch: service is null"); return HDF_ERR_INVALID_OBJECT; } if (cntlr->priv == NULL) { if (EmmcCntlrFindHost(cntlr) != HDF_SUCCESS) { - HDF_LOGE("EmmcIoDispatch: find host fail!"); + HDF_LOGE("EmmcIoDispatch: find host failed"); return HDF_ERR_INVALID_OBJECT; } } @@ -107,13 +107,13 @@ struct EmmcCntlr *EmmcCntlrCreateAndBind(struct HdfDeviceObject *device) struct EmmcCntlr *cntlr = NULL; if (device == NULL) { - HDF_LOGE("EmmcCntlrCreateAndBind: device is NULL!"); + HDF_LOGE("EmmcCntlrCreateAndBind: device is null!"); return NULL; } cntlr = (struct EmmcCntlr *)OsalMemCalloc(sizeof(*cntlr)); if (cntlr == NULL) { - HDF_LOGE("EmmcCntlrCreateAndBind: malloc host fail!"); + HDF_LOGE("EmmcCntlrCreateAndBind: malloc host failed"); return NULL; } cntlr->device = device; @@ -139,27 +139,27 @@ int32_t EmmcFillConfigData(struct HdfDeviceObject *device, struct EmmcConfigData int32_t ret; if (device == NULL || configData == NULL) { - HDF_LOGE("EmmcFillConfigData: input para is NULL."); + HDF_LOGE("EmmcFillConfigData: input para is null."); return HDF_FAILURE; } node = device->property; if (node == NULL) { - HDF_LOGE("EmmcFillConfigData: drs node is NULL."); + HDF_LOGE("EmmcFillConfigData: drs node is null."); return HDF_FAILURE; } drsOps = DeviceResourceGetIfaceInstance(HDF_CONFIG_SOURCE); if (drsOps == NULL || drsOps->GetUint32 == NULL) { - HDF_LOGE("EmmcFillConfigData: invalid drs ops fail!"); + HDF_LOGE("EmmcFillConfigData: invalid drs ops failed"); return HDF_FAILURE; } ret = drsOps->GetUint32(node, "hostId", &(configData->hostId), 0); if (ret != HDF_SUCCESS) { - HDF_LOGE("EmmcFillConfigData: read funcNum fail!"); + HDF_LOGE("EmmcFillConfigData: read funcNum failed"); return ret; } - HDF_LOGD("EmmcFillConfigData: Success! hostId = %d.", configData->hostId); + HDF_LOGD("EmmcFillConfigData: Success! hostId = %u.", configData->hostId); return HDF_SUCCESS; } diff --git a/support/platform/src/emmc_if.c b/support/platform/src/emmc_if.c index 1010af751c8a2657b8926ef2ea7d43d57c5663b3..ed70d88c7ee53d588c77062f3c8a5e1e0f451203 100644 --- a/support/platform/src/emmc_if.c +++ b/support/platform/src/emmc_if.c @@ -6,12 +6,12 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include "emmc_if.h" #include #ifndef __USER__ #include "devsvc_manager_clnt.h" #include "emmc_core.h" #endif -#include "emmc_if.h" #include "hdf_base.h" #ifdef __USER__ #include "hdf_io_service_if.h" @@ -96,16 +96,10 @@ static int32_t EmmcGetCidReadReplyData(struct HdfSBuf *reply, uint8_t *cid, uint uint32_t rLen; const void *rBuf = NULL; - if (HdfSbufReadBuffer(reply, &rBuf, &rLen) == false) { + if (!HdfSbufReadBuffer(reply, &rBuf, &rLen)) { HDF_LOGE("EmmcGetCidReadReplyData: read rBuf fail!"); return HDF_ERR_IO; } - if (size != rLen) { - HDF_LOGE("EmmcGetCidReadReplyData: err len:%u, rLen:%u", size, rLen); - if (rLen > size) { - rLen = size; - } - } if (memcpy_s(cid, size, rBuf, rLen) != EOK) { HDF_LOGE("EmmcGetCidReadReplyData: memcpy rBuf fail!"); @@ -115,7 +109,7 @@ static int32_t EmmcGetCidReadReplyData(struct HdfSBuf *reply, uint8_t *cid, uint return HDF_SUCCESS; } -int32_t EmmcServiceGetCid(struct HdfIoService *service, uint8_t *cid, uint32_t size) +static int32_t EmmcServiceGetCid(struct HdfIoService *service, uint8_t *cid, uint32_t size) { int32_t ret; struct HdfSBuf *reply = NULL; @@ -161,7 +155,7 @@ int32_t EmmcGetCid(DevHandle handle, uint8_t *cid, uint32_t size) } if (cid == NULL || size < EMMC_CID_LEN) { - HDF_LOGE("EmmcGetCid: error parms!"); + HDF_LOGE("EmmcGetCid: error params!"); return HDF_ERR_INVALID_PARAM; } #ifdef __USER__ @@ -176,7 +170,7 @@ void EmmcGetHuid(uint8_t *cid, uint32_t size) DevHandle handle = NULL; if (cid == NULL || size == 0) { - HDF_LOGE("EmmcGetUdid: error parms!"); + HDF_LOGE("EmmcGetUdid: error params!"); return; } if (memset_s(cid, sizeof(uint8_t) * size, 0, sizeof(uint8_t) * size) != EOK) { @@ -186,11 +180,11 @@ void EmmcGetHuid(uint8_t *cid, uint32_t size) handle = EmmcOpen(0); if (handle == NULL) { - HDF_LOGD("EmmcGetUdid: open fail, use default value!"); + HDF_LOGW("EmmcGetUdid: open fail, use default value!"); return; } if (EmmcGetCid(handle, cid, size) != HDF_SUCCESS) { - HDF_LOGD("EmmcGetUdid: get fail, use default value!"); + HDF_LOGW("EmmcGetUdid: get fail, use default value!"); } EmmcClose(handle); } diff --git a/support/platform/src/i2c_if.c b/support/platform/src/i2c_if.c index 2da224466a94bbfbd88feb78d8440177674ec21f..59665074332dc15e5edb4b2df987d5d4ae913414 100644 --- a/support/platform/src/i2c_if.c +++ b/support/platform/src/i2c_if.c @@ -267,7 +267,7 @@ int32_t I2cTransfer(DevHandle handle, struct I2cMsg *msgs, int16_t count) } if (msgs == NULL || count <= 0) { - HDF_LOGE("I2cTransfer: err parms! msgs:%s, count:%d", + HDF_LOGE("I2cTransfer: err params! msgs:%s, count:%d", (msgs == NULL) ? "0" : "x", count); return HDF_ERR_INVALID_PARAM; } diff --git a/support/platform/src/mipi_dsi_core.c b/support/platform/src/mipi_dsi_core.c index 0e2c74cb4e32862adfd7835da0a0e80e6eb52f13..6a6169351a017420469f32d9be1e5a4df50c5ee9 100644 --- a/support/platform/src/mipi_dsi_core.c +++ b/support/platform/src/mipi_dsi_core.c @@ -6,10 +6,10 @@ * See the LICENSE file in the root of this repository for complete details. */ -#include "osal_time.h" -#include "osal_mem.h" -#include "hdf_log.h" #include "mipi_dsi_core.h" +#include "hdf_log.h" +#include "osal_mem.h" +#include "osal_time.h" #define HDF_LOG_TAG mipi_dsi_core @@ -36,21 +36,21 @@ int32_t MipiDsiRegisterCntlr(struct MipiDsiCntlr *cntlr) return HDF_FAILURE; } -DevHandle MipiDsiOpen(uint8_t id) +DevHandle MipiDsiOpen(uint8_t number) { - if (id >= MAX_CNTLR_CNT) { - HDF_LOGE("id invalid"); + if (number >= MAX_CNTLR_CNT) { + HDF_LOGE("invalid number"); return NULL; } - if (g_mipiDsihandle[id].cntlr == NULL) { - HDF_LOGE("no mipi_dsi %d cntlr", id); + if (g_mipiDsihandle[number].cntlr == NULL) { + HDF_LOGE("no mipi_dsi %d cntlr", number); return NULL; } - if (OsalMutexLock(&(g_mipiDsihandle[id].lock)) != HDF_SUCCESS) { + if (OsalMutexLock(&(g_mipiDsihandle[number].lock)) != HDF_SUCCESS) { HDF_LOGE("mutex lock fail"); return NULL; } - return (DevHandle)(&(g_mipiDsihandle[id])); + return (DevHandle)(&(g_mipiDsihandle[number])); } void MipiDsiClose(DevHandle handle) @@ -64,7 +64,7 @@ void MipiDsiClose(DevHandle handle) static int32_t MipiDsiSetDevCfg(struct MipiDsiCntlr *cntlr) { - /* set controler config */ + /* set controller config */ if (cntlr->setCntlrCfg == NULL) { HDF_LOGE("setCntlrCfg is NULL"); return HDF_FAILURE; @@ -137,6 +137,7 @@ void MipiDsiSetLpMode(DevHandle handle) HDF_LOGI("toLp not support!"); } } + void MipiDsiSetHsMode(DevHandle handle) { struct MipiDsiCntlr *cntlr = NULL; @@ -151,6 +152,7 @@ void MipiDsiSetHsMode(DevHandle handle) HDF_LOGI("toHs not support!"); } } + void MipiDsiEnterUlps(DevHandle handle) { struct MipiDsiCntlr *cntlr = NULL; @@ -165,6 +167,7 @@ void MipiDsiEnterUlps(DevHandle handle) HDF_LOGI("enterUlps not support!"); } } + void MipiDsiExitUlps(DevHandle handle) { struct MipiDsiCntlr *cntlr = NULL; diff --git a/support/platform/src/rtc_base.c b/support/platform/src/rtc_base.c index 9b63c970b96b054057cda14d6a3b111acc0e3c8b..5e671ac0600b3f65e229b4c602295a4a07f0477b 100644 --- a/support/platform/src/rtc_base.c +++ b/support/platform/src/rtc_base.c @@ -6,9 +6,9 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include "rtc_base.h" #include "hdf_log.h" #include "plat_log.h" -#include "rtc_base.h" #define HDF_LOG_TAG rtc_base @@ -21,7 +21,7 @@ uint8_t RtcGetMonthDays(const uint8_t isLeapYear, const uint8_t month) return 0; } - if (RTC_FEBRUARY == month) { + if (month == RTC_FEBRUARY) { days = RTC_TWO_MONTH_DAY + isLeapYear; } else { oddMonth = (month >= RTC_AUGUST) ? (month - RTC_UNIT_DIFF) : month; diff --git a/support/platform/src/rtc_core.c b/support/platform/src/rtc_core.c index 3df837d3ad4962f13c67512fe39500bbda03cf49..93ae217397c068091f61d1dd0039bc940e5dd852 100644 --- a/support/platform/src/rtc_core.c +++ b/support/platform/src/rtc_core.c @@ -6,9 +6,9 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include "rtc_core.h" #include "hdf_log.h" #include "osal_mem.h" -#include "rtc_core.h" #define HDF_LOG_TAG rtc_core diff --git a/support/platform/src/rtc_if.c b/support/platform/src/rtc_if.c index 232126ca24eaf8cc02508ba9f4f0338299942258..140f3c3f968851596623ecd9eba8928e73d63b7f 100644 --- a/support/platform/src/rtc_if.c +++ b/support/platform/src/rtc_if.c @@ -6,13 +6,13 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include "rtc_if.h" +#include "devsvc_manager_clnt.h" #include "hdf_base.h" #include "hdf_log.h" -#include "devsvc_manager_clnt.h" #include "osal_mem.h" #include "rtc_base.h" #include "rtc_core.h" -#include "rtc_if.h" #define HDF_LOG_TAG rtc_if diff --git a/support/platform/src/sdio_core.c b/support/platform/src/sdio_core.c index 990c460d6b6060f2b1ffbaaec2ad84e074a35f84..737480a90680ad34855101f0adfa59dcf3b284e8 100644 --- a/support/platform/src/sdio_core.c +++ b/support/platform/src/sdio_core.c @@ -6,10 +6,10 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include "sdio_core.h" #include "device_resource_if.h" #include "osal_mem.h" #include "plat_log.h" -#include "sdio_core.h" #define HDF_LOG_TAG sdio_core diff --git a/support/platform/src/spi_if.c b/support/platform/src/spi_if.c index 45eb03af4252a9c81e92aa901c28384ee88e557b..4fb01a58d77979b33ac09bd76597599dff4994a7 100644 --- a/support/platform/src/spi_if.c +++ b/support/platform/src/spi_if.c @@ -6,12 +6,12 @@ * See the LICENSE file in the root of this repository for complete details. */ -#include "securec.h" +#include "spi_if.h" #include "devsvc_manager_clnt.h" #include "hdf_log.h" #include "osal_mem.h" +#include "securec.h" #include "spi_core.h" -#include "spi_if.h" #define HDF_LOG_TAG spi_if #define HOST_NAME_LEN 32 @@ -128,17 +128,19 @@ DevHandle SpiOpen(const struct SpiDevInfo *info) return NULL; } + object = (struct SpiObject *)OsalMemCalloc(sizeof(*object)); + if (object == NULL) { + HDF_LOGE("%s: object malloc error", __func__); + return NULL; + } + ret = SpiCntlrOpen(cntlr, info->csNum); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: SpiCntlrOpen error, ret is %d", __func__, ret); + OsalMemFree(object); return NULL; } - object = (struct SpiObject *)OsalMemCalloc(sizeof(*object)); - if (object == NULL) { - HDF_LOGE("%s: object malloc error", __func__); - return NULL; - } object->cntlr = cntlr; object->csNum = info->csNum; return (DevHandle)object; diff --git a/support/platform/src/uart_core.c b/support/platform/src/uart_core.c index 524ad61f9efcd51f789615520bb961f80221699d..71cfcb0501f1d31a32ee627c5e726c0ee4d5574a 100644 --- a/support/platform/src/uart_core.c +++ b/support/platform/src/uart_core.c @@ -154,7 +154,7 @@ static int32_t UartUserSetTransMode(struct UartHost *host, struct HdfSBuf *data) size_t size; enum UartTransMode *mode = NULL; - if (!HdfSbufReadBuffer(data, (const void **)&mode, &size)) { + if (!HdfSbufReadBuffer(data, (const void **)&mode, &size) || mode == NULL) { HDF_LOGE("%s: sbuf read buffer failed", __func__); return HDF_ERR_IO; } diff --git a/support/platform/src/uart_if.c b/support/platform/src/uart_if.c index 88b1dccb14588775b608f7931ef4ecc66ccbc1cf..8ed38d0f0d18a687ffae46c4ebdc933af3f2453f 100644 --- a/support/platform/src/uart_if.c +++ b/support/platform/src/uart_if.c @@ -6,6 +6,7 @@ * See the LICENSE file in the root of this repository for complete details. */ +#include "uart_if.h" #include "securec.h" #ifndef __USER__ #include "devsvc_manager_clnt.h" @@ -17,7 +18,6 @@ #ifndef __USER__ #include "uart_core.h" #endif -#include "uart_if.h" #define HDF_LOG_TAG uart_if_c #define UART_HOST_NAME_LEN 32