From 6cd2ab8c95cf75753f034b0dd42801c2f2c79152 Mon Sep 17 00:00:00 2001 From: jiaziyang Date: Tue, 8 Mar 2022 17:50:39 +0800 Subject: [PATCH] Fix: pick branch from master to Release Signed-off-by: jiaziyang --- include/platform/dac_if.h | 6 +- include/platform/i3c_if.h | 4 +- include/platform/mipi_csi_if.h | 6 +- include/platform/pin_if.h | 2 +- include/platform/regulator_if.h | 18 +++--- include/platform/rtc_if.h | 23 ++++---- include/platform/timer_if.h | 6 +- include/platform/uart_if.h | 4 +- model/storage/include/mmc/mmc_protocol.h | 2 +- model/storage/src/mmc/mmc_if.c | 4 +- model/storage/src/mmc/mmc_protocol.c | 2 +- support/platform/include/dma/dmac_core.h | 6 +- .../platform/include/fwk/platform_device.h | 2 +- support/platform/include/fwk/platform_event.h | 12 ++-- support/platform/include/hdmi/hdmi_cec.h | 4 ++ support/platform/include/hdmi/hdmi_edid.h | 21 +++++++ support/platform/include/i3c/i3c_core.h | 13 +---- support/platform/include/pin/pin_core.h | 2 +- .../include/regulator/regulator_core.h | 2 +- support/platform/include/uart/uart_core.h | 7 +-- support/platform/src/adc/adc_core.c | 13 ++--- support/platform/src/adc/adc_if_u.c | 14 ++--- support/platform/src/fwk/platform_device.c | 6 +- support/platform/src/fwk/platform_event.c | 6 +- support/platform/src/fwk/platform_manager.c | 4 +- support/platform/src/gpio/gpio_service.c | 2 +- support/platform/src/hdmi/hdmi_cec.c | 42 ++++++++------ support/platform/src/hdmi/hdmi_edid.c | 45 ++++++++------- support/platform/src/hdmi/hdmi_event.c | 24 ++++---- support/platform/src/hdmi/hdmi_frl.c | 10 +++- support/platform/src/hdmi/hdmi_hdcp.c | 26 ++++----- support/platform/src/hdmi/hdmi_hdr.c | 8 +-- support/platform/src/hdmi/hdmi_if.c | 4 +- support/platform/src/hdmi/hdmi_ncts.c | 13 +++-- support/platform/src/i2c/i2c_core.c | 6 +- support/platform/src/i2s/i2s_core.c | 16 +++--- support/platform/src/i2s/i2s_if.c | 8 +-- support/platform/src/i3c/i3c_core.c | 21 ++++++- support/platform/src/i3c/i3c_if.c | 2 +- support/platform/src/pin/pin_core.c | 2 +- support/platform/src/pwm/pwm_core.c | 2 +- .../platform/src/regulator/regulator_core.c | 44 +++++++-------- support/platform/src/regulator/regulator_if.c | 4 +- .../src/regulator/regulator_tree_mgr.c | 6 +- support/platform/src/rtc/rtc_if_u.c | 21 ++++--- support/platform/src/spi/spi_core.c | 2 +- support/platform/src/spi/spi_if_u.c | 8 +-- support/platform/src/timer/timer_core.c | 2 +- support/platform/src/timer/timer_if_u.c | 4 +- support/platform/src/uart/uart_core.c | 56 ++++++++++++------- support/platform/src/uart/uart_if.c | 13 ++--- support/platform/src/uart/uart_if_u.c | 23 ++++---- support/platform/src/uart/uart_service.c | 14 ++--- .../test/unittest/common/hdf_adc_test.cpp | 3 - .../test/unittest/common/hdf_gpio_test.cpp | 2 +- .../test/unittest/common/hdf_pin_test.cpp | 4 +- .../test/unittest/common/hdf_pwm_test.cpp | 2 +- .../test/unittest/common/hdf_uart_test.cpp | 2 +- test/unittest/platform/common/adc_test.c | 15 +++-- .../platform/common/dac_driver_test.c | 2 +- test/unittest/platform/common/dac_test.c | 12 ++-- test/unittest/platform/common/gpio_test.c | 48 +++++++++++----- test/unittest/platform/common/i2c_test.c | 12 ++-- test/unittest/platform/common/i3c_test.c | 4 +- test/unittest/platform/common/mipi_csi_test.c | 4 +- test/unittest/platform/common/pin_test.c | 8 +-- .../platform/common/platform_assert.h | 8 +-- .../platform/common/platform_device_test.c | 40 ++++++------- .../platform/common/platform_event_test.c | 10 ++-- .../platform/common/platform_manager_test.c | 22 ++++---- .../platform/common/platform_queue_test.c | 6 +- test/unittest/platform/common/pwm_test.c | 13 +++-- .../unittest/platform/common/regulator_test.c | 2 +- test/unittest/platform/common/rtc_test.c | 10 ++-- .../platform/common/spi_driver_test.c | 2 +- test/unittest/platform/common/spi_test.c | 14 ++--- test/unittest/platform/common/timer_test.c | 16 +++--- test/unittest/platform/common/uart_test.c | 15 ++--- .../platform/common/watchdog_driver_test.c | 3 +- test/unittest/platform/common/watchdog_test.c | 15 ++--- .../platform/entry/hdf_spi_entry_test.c | 1 - test/unittest/platform/virtual/dac_virtual.c | 15 ++--- test/unittest/platform/virtual/i3c_virtual.c | 21 +++---- .../platform/virtual/regulator_virtual.c | 26 ++++----- 84 files changed, 525 insertions(+), 449 deletions(-) diff --git a/include/platform/dac_if.h b/include/platform/dac_if.h index 8c8c329f..4c4c1e12 100644 --- a/include/platform/dac_if.h +++ b/include/platform/dac_if.h @@ -22,7 +22,7 @@ * @brief Declares the standard DAC interface functions. * * @since 1.0 - */ + */ #ifndef DAC_IF_H #define DAC_IF_H @@ -59,9 +59,9 @@ DevHandle DacOpen(uint32_t number); * If you no longer need to access the DAC controller, you should call this function to close its handle so as * to release unused memory resources. * - * @param handle Indicates the pointer to the device handle of the DAC controller. + * @param handle Indicates the pointer to the device handle of the DAC controller. * - * @since 1.0 + * @since 1.0 */ void DacClose(DevHandle handle); diff --git a/include/platform/i3c_if.h b/include/platform/i3c_if.h index f269a2f5..bfe076e5 100644 --- a/include/platform/i3c_if.h +++ b/include/platform/i3c_if.h @@ -37,7 +37,7 @@ extern "C" { #endif #endif /* __cplusplus */ -/** CCC(Common Command Code) structure */ +/** CCC(Common Command Code) structure */ struct I3cCccCmd; /** Broatcast commands */ @@ -127,7 +127,7 @@ struct I3cConfig { /** I3C bus mode */ enum I3cBusMode busMode; /** Current master object, its NULL when the controller is the master */ - struct I3cDevice *curMaster; + struct I3cDevice *curMaster; }; /** diff --git a/include/platform/mipi_csi_if.h b/include/platform/mipi_csi_if.h index b9b072d8..a62ed666 100755 --- a/include/platform/mipi_csi_if.h +++ b/include/platform/mipi_csi_if.h @@ -153,7 +153,7 @@ typedef enum { DATA_TYPE_YUV420_8BIT_LEGACY, DATA_TYPE_YUV422_8BIT, /** yuv422 8bit transform user define 16bit raw */ - DATA_TYPE_YUV422_PACKED, + DATA_TYPE_YUV422_PACKED, DATA_TYPE_BUTT } DataType; @@ -170,7 +170,7 @@ typedef struct { } ExtDataType; /** - * @brief MIPI D-PHY WDR MODE defines + * @brief MIPI D-PHY WDR MODE defines * * @since 1.0 */ @@ -181,7 +181,7 @@ typedef enum { /** Data Type */ HI_MIPI_WDR_MODE_DT = 0x2, /** DOL Mode */ - HI_MIPI_WDR_MODE_DOL = 0x3, + HI_MIPI_WDR_MODE_DOL = 0x3, HI_MIPI_WDR_MODE_BUTT } MipiWdrMode; diff --git a/include/platform/pin_if.h b/include/platform/pin_if.h index d760b030..47db2722 100644 --- a/include/platform/pin_if.h +++ b/include/platform/pin_if.h @@ -42,7 +42,7 @@ enum PinPullType { * * @param pinName Indicates the pin which you want to setting properties. * - * @return Returns the pointer to the {@link DevHandle} of the pin controller which + * @return Returns the pointer to the {@link DevHandle} of the pin controller which * to get a pin if the operation is successful; * returns NULL otherwise. * @since 1.0 diff --git a/include/platform/regulator_if.h b/include/platform/regulator_if.h index a2c083ac..7f9baf23 100755 --- a/include/platform/regulator_if.h +++ b/include/platform/regulator_if.h @@ -58,7 +58,7 @@ void RegulatorClose(DevHandle handle); * @return 0 If the regulator enables successfully; Otherwise, a negative value is returned. * * @attention That if the regulator has been enabled before calling this function, calling this function will succeed. - * + * * @since 1.0 */ int32_t RegulatorEnable(DevHandle handle); @@ -69,7 +69,7 @@ int32_t RegulatorEnable(DevHandle handle); * @return 0 If the regulator disable successfully; Otherwise, a negative value is returned. * * @attention If the regulator status alwayson is true or there is regulator child not disable, disabling fail - * + * * @since 1.0 */ int32_t RegulatorDisable(DevHandle handle); @@ -81,7 +81,7 @@ int32_t RegulatorDisable(DevHandle handle); * * @attention No matter whether the status of the regulator is alwayson or the status of the child is enable, * the regulator is disabled. - * + * * @since 1.0 */ int32_t RegulatorForceDisable(DevHandle handle); @@ -94,7 +94,7 @@ int32_t RegulatorForceDisable(DevHandle handle); * @return 0 If the regulator setVoltage successfully; Otherwise, a negative value is returned. * * @attention If the set voltage is not within the contrants, the setting fails. - * + * * @since 1.0 */ int32_t RegulatorSetVoltage(DevHandle handle, uint32_t minUv, uint32_t maxUv); @@ -104,7 +104,7 @@ int32_t RegulatorSetVoltage(DevHandle handle, uint32_t minUv, uint32_t maxUv); * @param handle Represents a pointer to the regulator handle, which is obtained through {@ link RegulatorOpen}. * @param voltage Voltage obtained. * @return 0 If the regulator get voltage successfully; Otherwise, a negative value is returned. - * + * * @since 1.0 */ int32_t RegulatorGetVoltage(DevHandle handle, uint32_t *voltage); @@ -117,7 +117,7 @@ int32_t RegulatorGetVoltage(DevHandle handle, uint32_t *voltage); * @return 0 If the regulator set current range successfully; Otherwise, a negative value is returned. * * @attention If the setting range exceeds the limit, the setting fails - * + * * @since 1.0 */ int32_t RegulatorSetCurrent(DevHandle handle, uint32_t minUa, uint32_t maxUa); @@ -127,7 +127,7 @@ int32_t RegulatorSetCurrent(DevHandle handle, uint32_t minUa, uint32_t maxUa); * @param handle Represents a pointer to the regulator handle, which is obtained through {@ link RegulatorOpen}. * @param voltage Current obtained * @return 0 If the regulator getCurrent successfully; Otherwise, a negative value is returned. - * + * * @since 1.0 */ int32_t RegulatorGetCurrent(DevHandle handle, uint32_t *regCurrent); @@ -137,7 +137,7 @@ int32_t RegulatorGetCurrent(DevHandle handle, uint32_t *regCurrent); * @param handle Represents a pointer to the regulator handle, which is obtained through {@ link RegulatorOpen}. * @param status Status obtained, enable or disable * @return 0 If the regulator get status successfully; Otherwise, a negative value is returned. - * + * * @since 1.0 */ int32_t RegulatorGetStatus(DevHandle handle, uint32_t *status); @@ -148,4 +148,4 @@ int32_t RegulatorGetStatus(DevHandle handle, uint32_t *status); #endif /* __cplusplus */ #endif /* REGULATOR_IF_H */ -/** @} */ \ No newline at end of file +/** @} */ diff --git a/include/platform/rtc_if.h b/include/platform/rtc_if.h index 6644332a..4c3d1318 100644 --- a/include/platform/rtc_if.h +++ b/include/platform/rtc_if.h @@ -81,17 +81,18 @@ struct RtcTime { * @since 1.0 */ enum RtcIoCmd { - RTC_IO_READTIME = 0, /**< Read time. */ - RTC_IO_WRITETIME, /**< Write format-compliant time. */ - RTC_IO_READALARM, /**< Read the RTC alarm time. */ - RTC_IO_WRITEALARM, /**< Write the RTC alarm time. */ - RTC_IO_REGISTERALARMCALLBACK, /**< Registers that will be invoked when an alarm is generated at the specified time. */ - RTC_IO_ALARMINTERRUPTENABLE, /**< Enables or disables alarm interrupts. */ - RTC_IO_GETFREQ, /**< Get the RTC external frequency. */ - RTC_IO_SETFREQ, /**< Set the oscillation frequency of RTC external crystal. */ - RTC_IO_RESET, /**< Reset the RTC device. */ - RTC_IO_READREG, /**< Reads the configuration of a custom RTC register. */ - RTC_IO_WRITEREG, /**< Writes the configuration of a custom RTC register. */ + RTC_IO_READTIME = 0, /**< Read time. */ + RTC_IO_WRITETIME, /**< Write format-compliant time. */ + RTC_IO_READALARM, /**< Read the RTC alarm time. */ + RTC_IO_WRITEALARM, /**< Write the RTC alarm time. */ + RTC_IO_REGISTERALARMCALLBACK, /**< Registers that will be invoked when an alarm + is generated at the specified time. */ + RTC_IO_ALARMINTERRUPTENABLE, /**< Enables or disables alarm interrupts. */ + RTC_IO_GETFREQ, /**< Get the RTC external frequency. */ + RTC_IO_SETFREQ, /**< Set the oscillation frequency of RTC external crystal. */ + RTC_IO_RESET, /**< Reset the RTC device. */ + RTC_IO_READREG, /**< Reads the configuration of a custom RTC register. */ + RTC_IO_WRITEREG, /**< Writes the configuration of a custom RTC register. */ }; /** diff --git a/include/platform/timer_if.h b/include/platform/timer_if.h index 01a29826..219835ac 100755 --- a/include/platform/timer_if.h +++ b/include/platform/timer_if.h @@ -62,7 +62,7 @@ int32_t HwTimerStop(DevHandle handle); * @brief Set a period timer. * If you need the timer run, call this function to set timer info * @param handle Represents a pointer to the timer device handle. - * @param useconds Represents the timer interval. + * @param useconds Represents the timer interval. * @param cb Represents the timer callback function. * @return success or fail * @since 1.0 @@ -71,8 +71,8 @@ int32_t HwTimerSet(DevHandle handle, uint32_t useconds, TimerHandleCb cb); /** * @brief Set a oneshot timer. - * If you need the timer run, call this function to set timer info - * @param useconds Represents the timer interval. + * If you need the timer run, call this function to set timer info + * @param useconds Represents the timer interval. * @param cb Represents the timer callback function. * @return success or fail * @since 1.0 diff --git a/include/platform/uart_if.h b/include/platform/uart_if.h index 94f6ffa5..c7d0dbb1 100644 --- a/include/platform/uart_if.h +++ b/include/platform/uart_if.h @@ -247,8 +247,8 @@ enum UartTransMode { * @since 1.0 */ enum UartIoCmd { - UART_IO_INIT = 0, /**< Initialize the UART device. */ - UART_IO_DEINIT, /**< Deinitialize the UART device. */ + UART_IO_REQUEST = 0, /**< Reference count management and initialize the UART device. */ + UART_IO_RELEASE, /**< Reference count management and deinitialize the UART device. */ UART_IO_READ, /**< Read data. */ UART_IO_WRITE, /**< Write data. */ UART_IO_GET_BAUD, /**< Obtain the baud rate. */ diff --git a/model/storage/include/mmc/mmc_protocol.h b/model/storage/include/mmc/mmc_protocol.h index 6164eb1f..d13f4064 100644 --- a/model/storage/include/mmc/mmc_protocol.h +++ b/model/storage/include/mmc/mmc_protocol.h @@ -252,7 +252,7 @@ enum MmcRspCardStatus { * state change, it will be visible to the host in the response to the next command. * The four bits([12:9]) are interpreted as a binary coded number between 0 and 15. */ -#define MMC_CARD_CURRENT_STATE(x) ((x & 0x00001E00) >> 9) /* sx, b (4 bits) */ +#define MMC_CARD_CURRENT_STATE(x) (((x) & 0x00001E00) >> 9) /* sx, b (4 bits) */ enum MmcCardCurrentState { STATE_IDLE = 0, STATE_READY = 1, diff --git a/model/storage/src/mmc/mmc_if.c b/model/storage/src/mmc/mmc_if.c index f3d15acf..580cdcaf 100644 --- a/model/storage/src/mmc/mmc_if.c +++ b/model/storage/src/mmc/mmc_if.c @@ -37,7 +37,8 @@ static void *MmcCntlrObjGetByNumber(int16_t id) if (snprintf_s(serviceName, MMC_SVC_NAME_LEN + 1, MMC_SVC_NAME_LEN, "HDF_PLATFORM_MMC_%d", id) < 0) { HDF_LOGE("MmcCntlrObjGetByNumber: format service name fail!"); - goto __ERR; + OsalMemFree(serviceName); + return object; } #ifdef __USER__ @@ -51,7 +52,6 @@ static void *MmcCntlrObjGetByNumber(int16_t id) HDF_LOGD("MmcCntlrObjGetByNumber: success"); } -__ERR: OsalMemFree(serviceName); return object; } diff --git a/model/storage/src/mmc/mmc_protocol.c b/model/storage/src/mmc/mmc_protocol.c index c1a38963..84a044a7 100644 --- a/model/storage/src/mmc/mmc_protocol.c +++ b/model/storage/src/mmc/mmc_protocol.c @@ -862,7 +862,7 @@ static void EmmcDecodeExtCsdCardType(struct EmmcExtCsd *extCsd) break; default: HDF_LOGD("EmmcDecodeExtCsdCardType: not support high-speed!"); - break; + break; } } diff --git a/support/platform/include/dma/dmac_core.h b/support/platform/include/dma/dmac_core.h index 2f852574..42018816 100644 --- a/support/platform/include/dma/dmac_core.h +++ b/support/platform/include/dma/dmac_core.h @@ -95,16 +95,16 @@ static inline uintptr_t DmacMsgGetPeriphAddr(struct DmacMsg *msg) uintptr_t reserved1; \ uintptr_t destAddr; \ uintptr_t reserved2; \ - unsigned long config; + unsigned long config struct DmacLliHead { - DMAC_LLI_HEAD + DMAC_LLI_HEAD; }; #define DMAC_LLI_HEAD_SIZE (sizeof(struct DmacLliHead)) #define DMAC_LLI_SIZE 64 // must be 64 Bytes aligned struct DmacLli { - DMAC_LLI_HEAD + DMAC_LLI_HEAD; uint8_t pad[DMAC_LLI_SIZE - DMAC_LLI_HEAD_SIZE]; }; diff --git a/support/platform/include/fwk/platform_device.h b/support/platform/include/fwk/platform_device.h index 43a2efa3..e3a18629 100644 --- a/support/platform/include/fwk/platform_device.h +++ b/support/platform/include/fwk/platform_device.h @@ -84,7 +84,7 @@ int32_t PlatformDeviceSetName(struct PlatformDevice *device, const char *fmt, .. * * @since 1.0 */ -void PlatformDeviceClearName(struct PlatformDevice *device); +void PlatformDeviceClearName(struct PlatformDevice *device); /** * @brief Increase reference count for a platform device. diff --git a/support/platform/include/fwk/platform_event.h b/support/platform/include/fwk/platform_event.h index 925353ae..bf684c7a 100644 --- a/support/platform/include/fwk/platform_event.h +++ b/support/platform/include/fwk/platform_event.h @@ -54,7 +54,7 @@ struct PlatformEventListener { /** * @brief Initialize a platform event instace. * - * @param pe Indicates the pointer to the the platform event instance + * @param pe Indicates the pointer to the the platform event instance * * @return Returns 0 if the operation is successful; returns a negative value otherwise. * @@ -65,7 +65,7 @@ int32_t PlatformEventInit(struct PlatformEvent *pe); /** * @brief Uninitialize a platform event instace. * - * @param pe Indicates the pointer to the the platform event instance + * @param pe Indicates the pointer to the the platform event instance * * @return Returns 0 if the operation is successful; returns a negative value otherwise. * @@ -76,7 +76,7 @@ int32_t PlatformEventUninit(struct PlatformEvent *pe); /** * @brief Write the events to a platform event instace. * - * @param pe Indicates the pointer to the the platform event instance + * @param pe Indicates the pointer to the the platform event instance * @param events The events to write. * * @return Returns 0 if the operation is successful; returns a negative value otherwise. @@ -88,7 +88,7 @@ int32_t PlatformEventPost(struct PlatformEvent *pe, uint32_t events); /** * @brief Listen for CAN bus events. * - * @param pe Indicates the pointer to the the platform event instance + * @param pe Indicates the pointer to the the platform event instance * @param mask Mask bits of the interested events. * @param mode Platorm event mode for this listening. * @param events Pointer for receiving the events. @@ -102,7 +102,7 @@ int32_t PlatformEventWait(struct PlatformEvent *pe, uint32_t mask, int32_t mode, /** * @brief Listen to a platform event instance. * - * @param pe Indicates the pointer to the the platform event instance + * @param pe Indicates the pointer to the the platform event instance * @param listener The pointer to the listener. * * @return Returns 0 if the operation is successful; returns a negative value otherwise. @@ -114,7 +114,7 @@ int32_t PlatformEventListen(struct PlatformEvent *pe, const struct PlatformEvent /** * @brief Unlisten to a platform event instance. * - * @param pe Indicates the pointer to the the platform event instance + * @param pe Indicates the pointer to the the platform event instance * @param listener The pointer to the listener. * * @since 1.0 diff --git a/support/platform/include/hdmi/hdmi_cec.h b/support/platform/include/hdmi/hdmi_cec.h index decac2b2..6f615c92 100644 --- a/support/platform/include/hdmi/hdmi_cec.h +++ b/support/platform/include/hdmi/hdmi_cec.h @@ -437,7 +437,9 @@ enum HdmiCecTimerClearedStatus { */ #define HDMI_CEC_TIMER_OVERLAP_WARNING_NO_OVERLAP 0 #define HDMI_CEC_TIMER_OVERLAP_WARNING_TIMER_BLOCK_OVERLAP 1 +#define HDMI_CEC_TIMER_OVERLAP_WARNING_SHIFT 7 +#define HDMI_CEC_MEDIA_INFO_SHIFT 5 enum HdmiCecMediaInfo { HDMI_CEC_MEDIA_PRESENT_NOT_POTECTED = 0, HDMI_CEC_MEDIA_PRESENT_POTECTED = 1, @@ -454,6 +456,7 @@ enum HdmiCecMediaInfo { /* Progremmed Indicator, 1 bit */ #define HDMI_CEC_PROG_IND_NOT_PROGRAMMED 0 #define HDMI_CEC_PROG_IND_PROGRAMMED 1 +#define HDMI_CEC_PROG_IND_SHIFT 4 /* Progremmed Info, 4 bits */ enum HdmiCecProgremmedInfo { @@ -771,6 +774,7 @@ enum HdmiCecPlayMode { */ #define HDMI_CEC_RECORDING_FALG_NOT_USED 0 #define HDMI_CEC_RECORDING_FALG_USED 1 +#define HDMI_CEC_RECORDING_FALG_SHIFT 7 enum HdmiCecTunerDisplayInfo { HDMI_CEC_TUNER_DISP_DIGITAL = 0, diff --git a/support/platform/include/hdmi/hdmi_edid.h b/support/platform/include/hdmi/hdmi_edid.h index 5678ab97..5b186625 100644 --- a/support/platform/include/hdmi/hdmi_edid.h +++ b/support/platform/include/hdmi/hdmi_edid.h @@ -62,6 +62,7 @@ extern "C" { /* edid vendor/product info */ #define HDMI_EDID_MANUFACRURER_NAME_FIELD_LEN 2 #define HDMI_EDID_MANUFACRURER_NAME_MAX_LEN 4 +#define HDMI_EDID_MANUFACRURER_NAME_EFFECTIVE_LEN 3 #define HDMI_EDID_MANUFACRURER_NAME_CHAR_MARK 0x1F /* 5 bits */ #define HDMI_EDID_MANUFACRURER_NAME_CHAR_SHIFT 5 #define HDMI_EDID_MANUFACRURER_NAME_LOW_INVALID 0 @@ -378,6 +379,17 @@ struct HdmiEdidVideoInfo { #define HDMI_EDID_EXTENSION_VSDB_3D_MULTI_PRESENT_SHIFT 5 #define HDMI_EDID_EXTENSION_VSDB_3D_STR_INVALID_MARK 0x03 +#define HDMI_EDID_VSDB_MIN_LEN_FOR_CEC_PHY_ADDR 5 +#define HDMI_EDID_VSDB_MIN_LEN_FOR_COLOR_DEPTH 6 +#define HDMI_EDID_VSDB_MIN_LEN_FOR_MAX_TMDS_CLOCK 7 +#define HDMI_EDID_VSDB_MIN_LEN_FOR_SINK_PRESENT 8 +#define HDMI_EDID_VSDB_MIN_LEN_FOR_VIDEO_LATENCY 9 +#define HDMI_EDID_VSDB_MIN_LEN_FOR_AUDIO_LATENCY 10 +#define HDMI_EDID_VSDB_MIN_LEN_FOR_INTERLACED_VIDEO_LATENCY 11 +#define HDMI_EDID_VSDB_MIN_LEN_FOR_INTERLACED_AUDIO_LATENCY 12 +#define HDMI_EDID_VSDB_MIN_LEN_FOR_3D_PRESENT_INFO 13 +#define HDMI_EDID_VSDB_MIN_LEN_FOR_VIC_INFO 14 + struct HdmiEdidVsdbCecAddr { bool addrValid; uint8_t phyAddrA; @@ -425,6 +437,8 @@ struct HdmiEdidExtHfVsdbDeepColor { bool dc48bit; }; +#define HDMI_EDID_EXTENSION_HFVSDB_DSC_TOTAL_CHUNK_MARK 0x3F + /* dsc(Display Stream Compression ) */ struct HdmiEdidExtHfVsdbDscInfo { bool dsc1p2; @@ -438,6 +452,10 @@ struct HdmiEdidExtHfVsdbDscInfo { uint8_t dscTotalChunkKBytes; }; +#define HDMI_EDID_EXTENSION_HFVSDB_VRRMIN_MARK 0x3F +#define HDMI_EDID_EXTENSION_HFVSDB_VRRMAX_MARK 0xC0 +#define HDMI_EDID_EXTENSION_HFVSDB_VRRMAX_SHIFT 2 + struct HdmiEdidExtHfVsdbInfo { bool scdcPresent; bool rrCapable; /* read request cap. */ @@ -561,6 +579,9 @@ struct HdmiEdidVideoCapability { /* edid extension block: HDR Static Metadata Data Block */ #define HDMI_EDID_HDR_SMDB_MIN_LEN 3 +#define HDMI_EDID_HDR_SMDB_MIN_LEN_FOR_MAX_LUMINANCE_DATA 4 +#define HDMI_EDID_HDR_SMDB_MIN_LEN_FOR_MAX_FRAME_AVE_LUMINANCE_DATA 5 +#define HDMI_EDID_HDR_SMDB_MIN_LEN_FOR_MIN_LUMINANCE_DATA 6 /* EOTF(Electro-Optical Transfer Functions) */ struct HdmiEdidHdrSmdbEotf { diff --git a/support/platform/include/i3c/i3c_core.h b/support/platform/include/i3c/i3c_core.h index 90f44abe..9806d091 100644 --- a/support/platform/include/i3c/i3c_core.h +++ b/support/platform/include/i3c/i3c_core.h @@ -52,17 +52,6 @@ extern "C" { #define I3C_HOT_JOIN_ADDR I3C_RESERVED_ADDR_7H02 #define I3C_BROADCAST_ADDR I3C_RESERVED_ADDR_7H7E -#define CHECK_RESERVED_ADDR(addr) \ - ({((addr == I3C_RESERVED_ADDR_7H00) || (addr == I3C_RESERVED_ADDR_7H01) || \ - (addr == I3C_RESERVED_ADDR_7H02) || (addr == I3C_RESERVED_ADDR_7H3E) || \ - (addr == I3C_RESERVED_ADDR_7H5E) || (addr == I3C_RESERVED_ADDR_7H6E) || \ - (addr == I3C_RESERVED_ADDR_7H76) || (addr == I3C_RESERVED_ADDR_7H78) || \ - (addr == I3C_RESERVED_ADDR_7H79) || (addr == I3C_RESERVED_ADDR_7H7A) || \ - (addr == I3C_RESERVED_ADDR_7H7B) || (addr == I3C_RESERVED_ADDR_7H7C) || \ - (addr == I3C_RESERVED_ADDR_7H7D) || (addr == I3C_RESERVED_ADDR_7H7E) || \ - (addr == I3C_RESERVED_ADDR_7H7F)) ? I3C_ADDR_RESERVED : I3C_ADDR_FREE; \ - }) - struct I3cCntlr; struct I3cMethod; struct I3cLockMethod; @@ -426,6 +415,8 @@ enum I3cIoCmd { I3C_IO_FREE_IBI, }; +int I3cCheckReservedAddr(uint16_t addr); + #ifdef __cplusplus #if __cplusplus } diff --git a/support/platform/include/pin/pin_core.h b/support/platform/include/pin/pin_core.h index 5bb187ae..bbd545d7 100644 --- a/support/platform/include/pin/pin_core.h +++ b/support/platform/include/pin/pin_core.h @@ -13,7 +13,7 @@ #include "hdf_dlist.h" #include "pin_if.h" #include "osal_spinlock.h" -#include "osal_atomic.h" +#include "osal_atomic.h" #ifdef __cplusplus #if __cplusplus diff --git a/support/platform/include/regulator/regulator_core.h b/support/platform/include/regulator/regulator_core.h index 535b366f..0c237d56 100755 --- a/support/platform/include/regulator/regulator_core.h +++ b/support/platform/include/regulator/regulator_core.h @@ -127,7 +127,7 @@ int32_t RegulatorNodeAdd(struct RegulatorNode *node); int32_t RegulatorNodeRemove(const char *name); /** * @brief remove all regulator controllers - * @param + * @param * @return success or fail */ int32_t RegulatorNodeRemoveAll(void); diff --git a/support/platform/include/uart/uart_core.h b/support/platform/include/uart/uart_core.h index 4bdd8c04..72688ffd 100644 --- a/support/platform/include/uart/uart_core.h +++ b/support/platform/include/uart/uart_core.h @@ -73,9 +73,9 @@ static inline struct UartHost *UartHostFromDevice(struct HdfDeviceObject *device return (device == NULL) ? NULL : (struct UartHost *)device->service; } -int32_t UartHostInit(struct UartHost *host); +int32_t UartHostRequest(struct UartHost *host); -int32_t UartHostDeinit(struct UartHost *host); +int32_t UartHostRelease(struct UartHost *host); static inline int32_t UartHostRead(struct UartHost *host, uint8_t *data, uint32_t size) { @@ -141,8 +141,7 @@ static inline int32_t UartHostPollEvent(struct UartHost *host, void *filep, void return host->method->pollEvent(host, filep, table); } -int32_t UartIoDispatch(struct HdfDeviceIoClient *client, int cmd, - struct HdfSBuf *data, struct HdfSBuf *reply); +int32_t UartIoDispatch(struct HdfDeviceIoClient *client, int cmd, struct HdfSBuf *data, struct HdfSBuf *reply); #ifdef __cplusplus } diff --git a/support/platform/src/adc/adc_core.c b/support/platform/src/adc/adc_core.c index 032fc154..19750530 100644 --- a/support/platform/src/adc/adc_core.c +++ b/support/platform/src/adc/adc_core.c @@ -375,26 +375,26 @@ static int32_t AdcManagerIoRead(struct HdfSBuf *data, struct HdfSBuf *reply) return HDF_ERR_INVALID_PARAM; } - if (!HdfSbufReadUint32(data, &number)) { + if (!HdfSbufReadUint32(data, &number)) { HDF_LOGE("AdcManagerIoRead: read handle failed!"); return HDF_ERR_IO; } - if (!HdfSbufReadUint32(data, &channel)) { + if (!HdfSbufReadUint32(data, &channel)) { HDF_LOGE("AdcManagerIoRead: read handle failed!"); return HDF_ERR_IO; } number = (uint32_t)(number - ADC_HANDLE_SHIFT); ret = AdcDeviceRead(AdcManagerFindDevice(number), channel, &val); - if(ret != HDF_SUCCESS) { - HDF_LOGE("AdcManagerIoRead: read val failed!"); - return HDF_ERR_IO; + if (ret != HDF_SUCCESS) { + HDF_LOGE("AdcManagerIoRead: read val failed!"); + return HDF_ERR_IO; } if (!HdfSbufWriteUint32(reply, val)) { HDF_LOGE("%s: write val fail!", __func__); - return HDF_ERR_IO; + return HDF_ERR_IO; } return ret; @@ -403,7 +403,6 @@ static int32_t AdcManagerIoRead(struct HdfSBuf *data, struct HdfSBuf *reply) static int32_t AdcManagerDispatch(struct HdfDeviceIoClient *client, int cmd, struct HdfSBuf *data, struct HdfSBuf *reply) { - switch (cmd) { case ADC_IO_OPEN: return AdcManagerIoOpen(data, reply); diff --git a/support/platform/src/adc/adc_if_u.c b/support/platform/src/adc/adc_if_u.c index e369d114..508edda5 100644 --- a/support/platform/src/adc/adc_if_u.c +++ b/support/platform/src/adc/adc_if_u.c @@ -130,12 +130,12 @@ int32_t AdcRead(DevHandle handle, uint32_t channel, uint32_t *val) if (!HdfSbufWriteUint32(data, (uint32_t)(uintptr_t)handle)) { HDF_LOGE("%s: write handle fail!", __func__); - ret = HDF_ERR_IO; + ret = HDF_ERR_IO; goto EXIT; } if (!HdfSbufWriteUint32(data, (uint32_t)channel)) { HDF_LOGE("%s: write adc number failed!", __func__); - ret = HDF_ERR_IO; + ret = HDF_ERR_IO; goto EXIT; } ret = service->dispatcher->Dispatch(&service->object, ADC_IO_READ, data, reply); @@ -144,15 +144,15 @@ int32_t AdcRead(DevHandle handle, uint32_t channel, uint32_t *val) goto EXIT; } - if (!HdfSbufReadUint32(reply, val)) { - HDF_LOGE("%s: read sbuf failed", __func__); - ret = HDF_ERR_IO; + if (!HdfSbufReadUint32(reply, val)) { + HDF_LOGE("%s: read sbuf failed", __func__); + ret = HDF_ERR_IO; goto EXIT; } goto EXIT; EXIT: - HdfSbufRecycle(data); - HdfSbufRecycle(reply); + HdfSbufRecycle(data); + HdfSbufRecycle(reply); return ret; } diff --git a/support/platform/src/fwk/platform_device.c b/support/platform/src/fwk/platform_device.c index 5e6b1333..86f6ce15 100644 --- a/support/platform/src/fwk/platform_device.c +++ b/support/platform/src/fwk/platform_device.c @@ -101,7 +101,7 @@ void PlatformDeviceClearName(struct PlatformDevice *device) if (device != NULL && device->name != NULL) { OsalMemFree((char *)device->name); device->name = NULL; - } + } } int32_t PlatformDeviceInit(struct PlatformDevice *device) @@ -298,7 +298,7 @@ void PlatformDeviceUnbind(struct PlatformDevice *device, struct HdfDeviceObject } if (device->hdfDev != hdfDev) { PLAT_LOGW("PlatformDeviceUnbind: hdf device not match!"); - return; + return; } device->hdfDev->service = NULL; @@ -360,6 +360,6 @@ int32_t PlatformDeviceListenEvent(struct PlatformDevice *device, struct Platform void PlatformDeviceUnListenEvent(struct PlatformDevice *device, struct PlatformEventListener *listener) { if (device != NULL && listener != NULL) { - PlatformEventUnlisten(&device->event, listener); + PlatformEventUnlisten(&device->event, listener); } } diff --git a/support/platform/src/fwk/platform_event.c b/support/platform/src/fwk/platform_event.c index aa696290..49f8df2d 100644 --- a/support/platform/src/fwk/platform_event.c +++ b/support/platform/src/fwk/platform_event.c @@ -136,8 +136,8 @@ static int32_t PlatformEventRead(struct PlatformEvent *pe, uint32_t *events, uin uint32_t masked = 0; if (events == NULL || mask == 0) { - return HDF_ERR_INVALID_PARAM; - } + return HDF_ERR_INVALID_PARAM; + } PlatformEventLock(pe); if (((uint32_t)mode & (uint32_t)PLAT_EVENT_MODE_AND) == 0) { if ((pe->eventsWord & mask) != 0) { @@ -226,7 +226,7 @@ static int32_t PlatformEventAsyncCallback(struct PlatformEventWaiter *waiter, in // gona do it in thread context later ... return listener->cb(listener, (uint32_t)events & listener->mask); -} +} int32_t PlatformEventListen(struct PlatformEvent *pe, const struct PlatformEventListener *listener) { diff --git a/support/platform/src/fwk/platform_manager.c b/support/platform/src/fwk/platform_manager.c index 66966d5e..f0cade00 100644 --- a/support/platform/src/fwk/platform_manager.c +++ b/support/platform/src/fwk/platform_manager.c @@ -129,13 +129,13 @@ static int32_t PlatformManagerAddDeviceDefault(struct PlatformManager *manager, DLIST_FOR_EACH_ENTRY(tmp, &manager->devices, struct PlatformDevice, node) { if (device->number == tmp->number) { repeatId = true; - PLAT_LOGE("%s: device:%s(%d) num repeated in manager:%s", __func__, + PLAT_LOGE("%s: device:%s(%d) num repeated in manager:%s", __func__, device->name, device->number, manager->device.name); break; } if (device->name != NULL && device->name == tmp->name) { repeatName = true; - PLAT_LOGE("%s: device:%s(%d) name repeated in manager:%s", __func__, + PLAT_LOGE("%s: device:%s(%d) name repeated in manager:%s", __func__, device->name, device->number, manager->device.name); break; } diff --git a/support/platform/src/gpio/gpio_service.c b/support/platform/src/gpio/gpio_service.c index 254ba4f4..ecb8fa40 100644 --- a/support/platform/src/gpio/gpio_service.c +++ b/support/platform/src/gpio/gpio_service.c @@ -255,7 +255,7 @@ static int32_t GpioServiceDispatch(struct HdfDeviceIoClient *client, int cmd, } static int32_t GpioServiceBind(struct HdfDeviceObject *device) -{ +{ int32_t ret; struct PlatformManager *gpioMgr = NULL; diff --git a/support/platform/src/hdmi/hdmi_cec.c b/support/platform/src/hdmi/hdmi_cec.c index 2d8a0830..3e601be8 100644 --- a/support/platform/src/hdmi/hdmi_cec.c +++ b/support/platform/src/hdmi/hdmi_cec.c @@ -148,7 +148,7 @@ static struct HdmiCecMsgLenInfo *HdmiCecGetMsgLenInfo(uint8_t opcode) static bool HdmiCecCheckTimerStatusMsgLen(struct HdmiCecMsg *msg) { /* Progremmed Info or Not Progremmed Error Info. */ - uint8_t info = (msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT] & 0xf); + uint8_t info = (msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT] & 0xf); /* Progremmed Indicator Check. */ if ((msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT] & 0x10) > 0) { @@ -616,7 +616,8 @@ void HdmiCecEncodingSetTimerProgramTitleMsg(struct HdmiCecMsg *msg, uint8_t *tit length = ((len <= HDMI_CEC_PROGRAM_TITLE_STR_MAX_LEN) ? len : HDMI_CEC_PROGRAM_TITLE_STR_MAX_LEN); msg->len = HDMI_CEC_GET_MSG_LEN(length); msg->data[HDMI_CEC_MSG_DATA_FIRST_ELEMENT] = HDMI_CEC_OPCODE_SET_TIMER_PROGRAM_TITLE; - if (memcpy_s(&(msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT]), (msg->len - 2), title, length) != EOK) { + if (memcpy_s(&(msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT]), (msg->len - HDMI_CEC_MSG_DATA_SECOND_ELEMENT), + title, length) != EOK) { HDF_LOGE("encoding set timer program title, memcpy_s fail."); } } @@ -634,9 +635,9 @@ void HdmiCecEncodingTimerStatusMsg(struct HdmiCecMsg *msg, struct HdmiCecTimerSt msg->len = HDMI_CEC_GET_MSG_LEN(HDMI_CEC_TIMER_STATUS_DATA_MIN_LEN); msg->data[HDMI_CEC_MSG_DATA_FIRST_ELEMENT] = HDMI_CEC_OPCODE_TIMER_STATUS; - msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT] |= (status->timerOverlap << 7); - msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT] |= (status->mediaInfo << 5); - msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT] |= (status->progInfo.indicator << 4); + msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT] |= (status->timerOverlap << HDMI_CEC_TIMER_OVERLAP_WARNING_SHIFT); + msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT] |= (status->mediaInfo << HDMI_CEC_MEDIA_INFO_SHIFT); + msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT] |= (status->progInfo.indicator << HDMI_CEC_PROG_IND_SHIFT); msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT] |= (status->progInfo.info); if (status->progInfo.indicator > 0) { /* Progremmed Info */ @@ -711,7 +712,8 @@ void HdmiCecEncodingSetMenuLanguageMsg(struct HdmiCecMsg *msg, uint8_t *language msg->len = HDMI_CEC_GET_MSG_LEN(len); msg->data[HDMI_CEC_MSG_DATA_ZEROTH_ELEMENT] |= HDMI_CEC_LOG_ADDR_UNREGISTERED_OR_BROADCAST; msg->data[HDMI_CEC_MSG_DATA_FIRST_ELEMENT] = HDMI_CEC_OPCODE_SET_MENU_LANGUAGE; - if (memcpy_s(&(msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT]), (msg->len - 2), language, len) != EOK) { + if (memcpy_s(&(msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT]), (msg->len - HDMI_CEC_MSG_DATA_SECOND_ELEMENT), + language, len) != EOK) { HDF_LOGE("encoding set menu language, memcpy_s fail."); } } @@ -819,7 +821,8 @@ void HdmiCecEncodingSelectDigitalServiceMsg(struct HdmiCecMsg *msg, struct HdmiC void HdmiCecEncodingTunerDeviceStatusMsg(struct HdmiCecMsg *msg, struct HdmiCecTunerDeviceInfo *info) { msg->data[HDMI_CEC_MSG_DATA_FIRST_ELEMENT] = HDMI_CEC_OPCODE_TUNER_DEVICE_STATUS; - msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT] = (info->recordingFlag << 7) | (info->dispInfo); + msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT] = (info->recordingFlag << HDMI_CEC_RECORDING_FALG_SHIFT) | + (info->dispInfo); if (info->isAnalogService == true) { msg->len = HDMI_CEC_GET_MSG_LEN(HDMI_CEC_TUNER_DEVICE_STATUS_MSG_ANA_PARAM_LEN); msg->data[HDMI_CEC_MSG_DATA_THIRD_ELEMENT] = info->data.analog.anaBcastType; @@ -875,7 +878,8 @@ void HdmiCecEncodingVendorCommandMsg(struct HdmiCecMsg *msg, uint8_t *data, uint length = (len > HDMI_CEC_VENDOR_SPECIFIC_DATA_MAX_LEN) ? HDMI_CEC_VENDOR_SPECIFIC_DATA_MAX_LEN : len; msg->len = HDMI_CEC_GET_MSG_LEN(length); msg->data[HDMI_CEC_MSG_DATA_FIRST_ELEMENT] = HDMI_CEC_OPCODE_VENDOR_COMMAND; - if (memcpy_s(&(msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT]), (msg->len - 2), data, length) != EOK) { + if (memcpy_s(&(msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT]), (msg->len - HDMI_CEC_MSG_MIN_LEN), data, length) + != EOK) { HDF_LOGE("encoding vendor cmd, memcpy_s fail."); } } @@ -895,7 +899,8 @@ void HdmiCecEncodingVendorCommandWithIdMsg(struct HdmiCecMsg *msg, uint32_t vend msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT] = (vendorId >> HDMI_TWO_BYTES_SHIFT) & HDMI_ONE_BYTE_MARK; msg->data[HDMI_CEC_MSG_DATA_THIRD_ELEMENT] = (vendorId >> HDMI_ONE_BYTE_SHIFT) & HDMI_ONE_BYTE_MARK; msg->data[HDMI_CEC_MSG_DATA_FORTH_ELEMENT] = (vendorId & HDMI_ONE_BYTE_MARK); - if (memcpy_s(&(msg->data[HDMI_CEC_MSG_DATA_FIFTH_ELEMENT]), (msg->len - 5), data, length) != EOK) { + if (memcpy_s(&(msg->data[HDMI_CEC_MSG_DATA_FIFTH_ELEMENT]), (msg->len - HDMI_CEC_MSG_DATA_FIFTH_ELEMENT), + data, length) != EOK) { HDF_LOGE("encoding vendor cmd with id, memcpy_s fail."); } } @@ -911,7 +916,8 @@ void HdmiCecEncodingVendorRemoteButtonDownMsg(struct HdmiCecMsg *msg, uint8_t *r length = (len > HDMI_CEC_VENDOR_SPECIFIC_RC_CODE_MAX_LEN) ? HDMI_CEC_VENDOR_SPECIFIC_RC_CODE_MAX_LEN : len; msg->len = HDMI_CEC_GET_MSG_LEN(length); msg->data[HDMI_CEC_MSG_DATA_FIRST_ELEMENT] = HDMI_CEC_OPCODE_VENDOR_REMOTE_BUTTON_DOWN; - if (memcpy_s(&(msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT]), (msg->len - 2), rcCode, length) != EOK) { + if (memcpy_s(&(msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT]), (msg->len - HDMI_CEC_MSG_DATA_SECOND_ELEMENT), + rcCode, length) != EOK) { HDF_LOGE("encoding vendor remote button down, memcpy_s fail."); } } @@ -934,7 +940,8 @@ void HdmiCecEncodingSetOsdStringMsg(struct HdmiCecMsg *msg, uint8_t dispControl, msg->len = HDMI_CEC_GET_MSG_LEN(length + HDMI_CEC_DISPLAY_CONTROL_LEN); msg->data[HDMI_CEC_MSG_DATA_FIRST_ELEMENT] = HDMI_CEC_OPCODE_SET_OSD_STRING; msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT] = dispControl; - if (memcpy_s(&(msg->data[HDMI_CEC_MSG_DATA_THIRD_ELEMENT]), (msg->len - 3), str, length) != EOK) { + if (memcpy_s(&(msg->data[HDMI_CEC_MSG_DATA_THIRD_ELEMENT]), (msg->len - HDMI_CEC_MSG_DATA_THIRD_ELEMENT), + str, length) != EOK) { HDF_LOGE("encoding set OSD string, memcpy_s fail."); } } @@ -959,7 +966,8 @@ void HdmiCecEncodingSetOsdNameMsg(struct HdmiCecMsg *msg, uint8_t *name, uint32_ length = (len > HDMI_CEC_OSD_NAME_MAX_LEN) ? HDMI_CEC_OSD_NAME_MAX_LEN : len; msg->len = HDMI_CEC_GET_MSG_LEN(length); msg->data[HDMI_CEC_MSG_DATA_FIRST_ELEMENT] = HDMI_CEC_OPCODE_SET_OSD_NAME; - if (memcpy_s(&(msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT]), (msg->len - 2), name, length) != EOK) { + if (memcpy_s(&(msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT]), (msg->len - HDMI_CEC_MSG_DATA_SECOND_ELEMENT), + name, length) != EOK) { HDF_LOGE("encoding set OSD name, memcpy_s fail."); } } @@ -1093,7 +1101,8 @@ void HdmiCecEncodingRequestShortAudioDescriptorMsg(struct HdmiCecMsg *msg, msg->len = HDMI_CEC_GET_MSG_LEN(num * HDMI_CEC_AUDIO_FORMAT_LEN); msg->data[HDMI_CEC_MSG_DATA_FIRST_ELEMENT] = HDMI_CEC_OPCODE_REQUEST_SHORT_AUDIO_DESCRIPTOR; for (i = 0; i < num; i++) { - msg->data[2 + i] = (id[i] << HDMI_CEC_AUDIO_FORMAT_ID_SHIFT) | (code[i] & HDMI_CEC_AUDIO_FORMAT_CODE_MARK); + msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT + i] = (id[i] << HDMI_CEC_AUDIO_FORMAT_ID_SHIFT) | + (code[i] & HDMI_CEC_AUDIO_FORMAT_CODE_MARK); } if (response == true) { msg->rspMsg = HDMI_CEC_OPCODE_REPORT_SHORT_AUDIO_DESCRIPTOR; @@ -1112,11 +1121,12 @@ void HdmiCecEncodingReportShortAudioDescriptorMsg(struct HdmiCecMsg *msg, uint32 msg->len = HDMI_CEC_GET_MSG_LEN(HDMI_CEC_SHORT_AUDIO_DESCRIPTOR_LEN * num); msg->data[HDMI_CEC_MSG_DATA_FIRST_ELEMENT] = HDMI_CEC_OPCODE_REPORT_SHORT_AUDIO_DESCRIPTOR; for (i = 0; i < num; i++) { - msg->data[2 + i * HDMI_CEC_SHORT_AUDIO_DESCRIPTOR_LEN] = + msg->data[HDMI_CEC_MSG_DATA_SECOND_ELEMENT + i * HDMI_CEC_SHORT_AUDIO_DESCRIPTOR_LEN] = (descriptor[i] >> HDMI_TWO_BYTES_SHIFT) & HDMI_ONE_BYTE_MARK; - msg->data[3 + i * HDMI_CEC_SHORT_AUDIO_DESCRIPTOR_LEN] = + msg->data[HDMI_CEC_MSG_DATA_THIRD_ELEMENT + i * HDMI_CEC_SHORT_AUDIO_DESCRIPTOR_LEN] = (descriptor[i] >> HDMI_ONE_BYTE_SHIFT) & HDMI_ONE_BYTE_MARK; - msg->data[4 + i * HDMI_CEC_SHORT_AUDIO_DESCRIPTOR_LEN] = descriptor[i] & HDMI_ONE_BYTE_MARK; + msg->data[HDMI_CEC_MSG_DATA_FORTH_ELEMENT + i * HDMI_CEC_SHORT_AUDIO_DESCRIPTOR_LEN] = + descriptor[i] & HDMI_ONE_BYTE_MARK; } } diff --git a/support/platform/src/hdmi/hdmi_edid.c b/support/platform/src/hdmi/hdmi_edid.c index 244c58d7..d707a382 100644 --- a/support/platform/src/hdmi/hdmi_edid.c +++ b/support/platform/src/hdmi/hdmi_edid.c @@ -95,7 +95,8 @@ static int32_t HdmiEdidVendorInfoPhase(struct HdmiEdid *edid) tmpData = (tmpData >> (HDMI_EDID_MANUFACRURER_NAME_CHAR_SHIFT * i)); if (tmpData > HDMI_EDID_MANUFACRURER_NAME_LOW_INVALID && tmpData < HDMI_EDID_MANUFACRURER_NAME_HIGH_INVALID) { - sinkCap->vendorInfo.mfrName[2 - i] = (char)('A' + tmpData - 1); + sinkCap->vendorInfo.mfrName[HDMI_EDID_MANUFACRURER_NAME_EFFECTIVE_LEN - 1 - i] = + (char)('A' + tmpData - 1); } } @@ -585,7 +586,7 @@ static int32_t HdmiEdidExtVideoDataBlockPhase(struct HdmiSinkDeviceCapability *s static void HdmiEdidVsdbCecPhyAddrPhase(struct HdmiSinkDeviceCapability *sinkCap, uint8_t *data, uint8_t len) { - if (len >= 5) { + if (len >= HDMI_EDID_VSDB_MIN_LEN_FOR_CEC_PHY_ADDR) { sinkCap->vsdbInfo.cecAddr.phyAddrA = (data[UINT8_ARRAY_TElEMENT_3] & HDMI_UPPER_NIBBLE_MARK) >> HDMI_NIBBLE_SHIFT; sinkCap->vsdbInfo.cecAddr.phyAddrB = (data[UINT8_ARRAY_TElEMENT_3] & HDMI_LOWER_NIBBLE_MARK); @@ -602,7 +603,7 @@ static void HdmiEdidVsdbCecPhyAddrPhase(struct HdmiSinkDeviceCapability *sinkCap static void HdmiEdidVsdbColorDepthPhase(struct HdmiSinkDeviceCapability *sinkCap, uint8_t *data, uint8_t len) { - if (len >= 6) { + if (len >= HDMI_EDID_VSDB_MIN_LEN_FOR_COLOR_DEPTH) { sinkCap->vsdbInfo.supportAi = (data[UINT8_ARRAY_TElEMENT_5] & HDMI_BIT7_MARK) ? true : false; sinkCap->vsdbInfo.supportDviDual = (data[UINT8_ARRAY_TElEMENT_5] & HDMI_BIT0_MARK) ? true : false; sinkCap->vsdbInfo.deepColor.dcY444 = (data[UINT8_ARRAY_TElEMENT_5] & HDMI_BIT3_MARK) ? true : false; @@ -618,7 +619,7 @@ static void HdmiEdidVsdbMaxTmdsClockPhase(struct HdmiSinkDeviceCapability *sinkC * This field shall be set cprrectly and non-zero if the sink support TMDS clock frequencies above 165MHz or * supports ant Deep Color mode or supports DVI dual-link. A value of zeor means that no clock rate is indicated. */ - if (len >= 7) { + if (len >= HDMI_EDID_VSDB_MIN_LEN_FOR_MAX_TMDS_CLOCK) { sinkCap->maxTmdsClk = data[UINT8_ARRAY_TElEMENT_6] * HDMI_EDID_EXTENSION_TMDS_FACTOR; sinkCap->supportHdmi20 = (sinkCap->maxTmdsClk > HDMI_EDID_EXTENSION_MAX_HDMI14_TMDS_RATE) ? true : false; } @@ -626,7 +627,7 @@ static void HdmiEdidVsdbMaxTmdsClockPhase(struct HdmiSinkDeviceCapability *sinkC static void HdmiEdidVsdbSinkPresentPhase(struct HdmiSinkDeviceCapability *sinkCap, uint8_t *data, uint8_t len) { - if (len >= 8) { + if (len >= HDMI_EDID_VSDB_MIN_LEN_FOR_SINK_PRESENT) { sinkCap->vsdbInfo.latencyFieldsPresent = (data[UINT8_ARRAY_TElEMENT_7] & HDMI_BIT7_MARK) ? true : false; sinkCap->vsdbInfo.iLatencyFieldsPresent = (data[UINT8_ARRAY_TElEMENT_7] & HDMI_BIT6_MARK) ? true : false; sinkCap->vsdbInfo.hdmiVideoPresent = (data[UINT8_ARRAY_TElEMENT_7] & HDMI_BIT5_MARK) ? true : false; @@ -636,18 +637,18 @@ static void HdmiEdidVsdbSinkPresentPhase(struct HdmiSinkDeviceCapability *sinkCa static void HdmiEdidVsdbSinkLatencyPhase(struct HdmiSinkDeviceCapability *sinkCap, uint8_t *data, uint8_t len) { if (sinkCap->vsdbInfo.latencyFieldsPresent == true) { - if (len >= 9) { + if (len >= HDMI_EDID_VSDB_MIN_LEN_FOR_VIDEO_LATENCY) { sinkCap->vsdbInfo.videoLatency = data[UINT8_ARRAY_TElEMENT_8]; } - if (len >= 10) { - sinkCap->vsdbInfo.videoLatency = data[UINT8_ARRAY_TElEMENT_9]; + if (len >= HDMI_EDID_VSDB_MIN_LEN_FOR_AUDIO_LATENCY) { + sinkCap->vsdbInfo.audioLatency = data[UINT8_ARRAY_TElEMENT_9]; } } if (sinkCap->vsdbInfo.iLatencyFieldsPresent == true) { - if (len >= 11) { + if (len >= HDMI_EDID_VSDB_MIN_LEN_FOR_INTERLACED_VIDEO_LATENCY) { sinkCap->vsdbInfo.interlacedVideoLatency = data[UINT8_ARRAY_TElEMENT_10]; } - if (len >= 12) { + if (len >= HDMI_EDID_VSDB_MIN_LEN_FOR_INTERLACED_AUDIO_LATENCY) { sinkCap->vsdbInfo.interlacedAudioLatency = data[UINT8_ARRAY_TElEMENT_11]; } } @@ -725,7 +726,7 @@ static void HdmiEdidVsdbVicAnd3dInfoPhase(struct HdmiSinkDeviceCapability *sinkC uint8_t hdmi3dLen = 0; uint8_t offset; - if (len < 13) { + if (len < HDMI_EDID_VSDB_MIN_LEN_FOR_3D_PRESENT_INFO) { HDF_LOGD("vsdb: these is no vic/3d field."); return; } @@ -734,7 +735,7 @@ static void HdmiEdidVsdbVicAnd3dInfoPhase(struct HdmiSinkDeviceCapability *sinkC HDMI_EDID_EXTENSION_VSDB_3D_MULTI_PRESENT_MARK) >> HDMI_EDID_EXTENSION_VSDB_3D_MULTI_PRESENT_SHIFT; - if (len >= 14) { + if (len >= HDMI_EDID_VSDB_MIN_LEN_FOR_VIC_INFO) { hdmiVicLen = (data[UINT8_ARRAY_TElEMENT_13] & HDMI_EDID_EXTENSION_VSDB_VIC_LEN_MARK) >> HDMI_EDID_EXTENSION_VSDB_VIC_LEN_SHIFT; @@ -742,7 +743,7 @@ static void HdmiEdidVsdbVicAnd3dInfoPhase(struct HdmiSinkDeviceCapability *sinkC } /* byte14~byteN: Vic info/3D info */ - offset = 14; + offset = HDMI_EDID_VSDB_MIN_LEN_FOR_VIC_INFO; if (hdmiVicLen > 0 && (hdmiVicLen + offset + 1) <= len) { HdmiEdidVsdbVicInfoPhase(sinkCap, data, hdmiVicLen, &offset); } @@ -757,7 +758,7 @@ static void HdmiEdidVsdbVicAnd3dInfoPhase(struct HdmiSinkDeviceCapability *sinkC static int32_t HdmiEdidVsdbPhase(struct HdmiSinkDeviceCapability *sinkCap, uint8_t *data, uint8_t len) { /* byte3 byte4: cec addr */ - if (len < 5) { + if (len < HDMI_EDID_VSDB_MIN_LEN_FOR_CEC_PHY_ADDR) { HDF_LOGD("vsdb: len = %d, too short.", len); return HDF_SUCCESS; } @@ -794,8 +795,9 @@ static void HdmiEdidHfVsdb21Phase(struct HdmiSinkDeviceCapability *sinkCap, uint sinkCap->hfVsdbInfo.cnmVrr = (data[UINT8_ARRAY_TElEMENT_7] & HDMI_BIT3_MARK) ? true : false; sinkCap->hfVsdbInfo.cinemaVrr = (data[UINT8_ARRAY_TElEMENT_7] & HDMI_BIT4_MARK) ? true : false; sinkCap->hfVsdbInfo.mDelta = (data[UINT8_ARRAY_TElEMENT_7] & HDMI_BIT5_MARK) ? true : false; - sinkCap->hfVsdbInfo.vrrMin = (data[UINT8_ARRAY_TElEMENT_8] & 0x3F); - sinkCap->hfVsdbInfo.vrrMax = ((data[UINT8_ARRAY_TElEMENT_8] & 0xC0) << 2) | data[UINT8_ARRAY_TElEMENT_9]; + sinkCap->hfVsdbInfo.vrrMin = (data[UINT8_ARRAY_TElEMENT_8] & HDMI_EDID_EXTENSION_HFVSDB_VRRMIN_MARK); + sinkCap->hfVsdbInfo.vrrMax = ((data[UINT8_ARRAY_TElEMENT_8] & HDMI_EDID_EXTENSION_HFVSDB_VRRMAX_MARK) << + HDMI_EDID_EXTENSION_HFVSDB_VRRMAX_SHIFT) | data[UINT8_ARRAY_TElEMENT_9]; sinkCap->hfVsdbInfo.dscInfo.dsc1p2 = (data[UINT8_ARRAY_TElEMENT_10] & HDMI_BIT7_MARK) ? true : false; sinkCap->hfVsdbInfo.dscInfo.dscNative420 = (data[UINT8_ARRAY_TElEMENT_10] & HDMI_BIT6_MARK) ? true : false; @@ -806,7 +808,8 @@ static void HdmiEdidHfVsdb21Phase(struct HdmiSinkDeviceCapability *sinkCap, uint sinkCap->hfVsdbInfo.dscInfo.dscMaxSlices = (data[UINT8_ARRAY_TElEMENT_11] & HDMI_LOWER_NIBBLE_MARK); sinkCap->hfVsdbInfo.dscInfo.dscMaxFrlRate = (data[UINT8_ARRAY_TElEMENT_11] & HDMI_UPPER_NIBBLE_MARK) >> HDMI_NIBBLE_SHIFT; - sinkCap->hfVsdbInfo.dscInfo.dscTotalChunkKBytes = (data[UINT8_ARRAY_TElEMENT_12] & 0x3F); + sinkCap->hfVsdbInfo.dscInfo.dscTotalChunkKBytes = (data[UINT8_ARRAY_TElEMENT_12] & + HDMI_EDID_EXTENSION_HFVSDB_DSC_TOTAL_CHUNK_MARK); } static int32_t HdmiEdidHfVsdbPhase(struct HdmiSinkDeviceCapability *sinkCap, uint8_t *data, uint8_t len) @@ -1016,14 +1019,14 @@ static void HdmiEdidExtUseExtDataBlockHdrSmdbPhase(struct HdmiSinkDeviceCapabili * optional to declare. When n is 3, Bytes 5 to 7 are not present. When n is 4, Byte 5 is present; when n is 5, * Bytes 5 and 6 are present; and when n is 6, Bytes 5 to 7 are present. */ - if (len >= 4) { + if (len >= HDMI_EDID_HDR_SMDB_MIN_LEN_FOR_MAX_LUMINANCE_DATA) { sinkCap->hdrCap.maxLuminancedata = data[UINT8_ARRAY_TElEMENT_3]; } - if (len >= 5) { + if (len >= HDMI_EDID_HDR_SMDB_MIN_LEN_FOR_MAX_FRAME_AVE_LUMINANCE_DATA) { sinkCap->hdrCap.maxFrameAverageLuminanceData = data[UINT8_ARRAY_TElEMENT_4]; } - if (len >= 6) { - sinkCap->hdrCap.maxFrameAverageLuminanceData = data[UINT8_ARRAY_TElEMENT_5]; + if (len >= HDMI_EDID_HDR_SMDB_MIN_LEN_FOR_MIN_LUMINANCE_DATA) { + sinkCap->hdrCap.minLuminanceData = data[UINT8_ARRAY_TElEMENT_5]; } } diff --git a/support/platform/src/hdmi/hdmi_event.c b/support/platform/src/hdmi/hdmi_event.c index 3f8a933a..e28fbc5a 100644 --- a/support/platform/src/hdmi/hdmi_event.c +++ b/support/platform/src/hdmi/hdmi_event.c @@ -100,7 +100,9 @@ static int32_t HdmiEventHotPlugHandleComm(struct HdmiCntlr *cntlr) if (cntlr->hdmi == NULL) { ret = HdmiCntlrAllocDev(cntlr); if (ret != HDF_SUCCESS) { - goto __END; + cntlr->event.plugged = false; + cntlr->event.hpdDetected = false; + return ret; } HDF_LOGE("HdmiEventHotPlugHandleComm HdmiCntlrAllocDev success."); } @@ -109,23 +111,23 @@ static int32_t HdmiEventHotPlugHandleComm(struct HdmiCntlr *cntlr) if (HdmiEdidReset(&(cntlr->hdmi->edid)) != HDF_SUCCESS) { HDF_LOGE("edid reset fail."); ret = HDF_ERR_IO; - goto __END; + cntlr->event.plugged = false; + cntlr->event.hpdDetected = false; + return ret; } ret = HdmiEdidRawDataRead(&(cntlr->hdmi->edid), &(cntlr->ddc)); - if (ret != HDF_SUCCESS) { - goto __END; - } - ret = HdmiEdidPhase(&(cntlr->hdmi->edid)); - if (ret != HDF_SUCCESS) { - goto __END; - } - -__END: if (ret != HDF_SUCCESS) { cntlr->event.plugged = false; cntlr->event.hpdDetected = false; return ret; } + ret = HdmiEdidPhase(&(cntlr->hdmi->edid)); + if (ret != HDF_SUCCESS) { + cntlr->event.plugged = false; + cntlr->event.hpdDetected = false; + return ret; + } + cntlr->event.hpdDetected = true; if (cntlr->event.callback.callbackFunc != NULL) { cntlr->event.callback.callbackFunc(cntlr->event.callback.data, true); diff --git a/support/platform/src/hdmi/hdmi_frl.c b/support/platform/src/hdmi/hdmi_frl.c index d6602d6b..b4e1a605 100644 --- a/support/platform/src/hdmi/hdmi_frl.c +++ b/support/platform/src/hdmi/hdmi_frl.c @@ -12,6 +12,10 @@ #include "hdmi_dfm.h" #include "hdmi_ncts.h" +#define HDMI_FRL_TRAIN_STEP_RESULT_HANDLE_MAX_TRIES 3 +#define HDMI_FRL_TRAIN_STEP_READR_CHECK_MAX_TRIES 10 +#define HDMI_FRL_CHECK_SINK_STATUS_DELAY_TIME 2000 + #define HDF_LOG_TAG hdmi_frl_c static uint8_t HdmiFrlGetSinkVersion(struct HdmiScdc *scdc) @@ -633,7 +637,7 @@ static void HdmiFrlTrainingReadyCheckTimeout(struct HdmiFrl *frl) } } else { /* wait for a maximum of 10 times, (wait_ready_ms * 10) ms */ - if (frl->info.machineInfo.timeoutCnt < 10) { + if (frl->info.machineInfo.timeoutCnt < HDMI_FRL_TRAIN_STEP_READR_CHECK_MAX_TRIES) { return; } HDF_LOGD("FRL training READY_CHECK exception."); @@ -707,10 +711,10 @@ static void HdmiFrlTrainingResultHandleTimeout(struct HdmiFrl *frl) break; } /* check the sink's status every 2ms required by protocol */ - OsalUDelay(2000); + OsalUDelay(HDMI_FRL_CHECK_SINK_STATUS_DELAY_TIME); } while (true); - if (frl->info.machineInfo.timeoutCnt >= 3) { + if (frl->info.machineInfo.timeoutCnt >= HDMI_FRL_TRAIN_STEP_RESULT_HANDLE_MAX_TRIES) { HDF_LOGE("FRL training timeout."); frl->info.machineInfo.timeoutCnt = 0; HdmiFrlTrainingException(frl); diff --git a/support/platform/src/hdmi/hdmi_hdcp.c b/support/platform/src/hdmi/hdmi_hdcp.c index eb4bc15d..1680a570 100644 --- a/support/platform/src/hdmi/hdmi_hdcp.c +++ b/support/platform/src/hdmi/hdmi_hdcp.c @@ -388,7 +388,8 @@ static int32_t HdmiHdcpAuthentication(struct HdmiHdcp *hdcp) /* auth prepare, get aksv and driver clear registers. */ ret = HdmiHdcpAuthenticationPrepare(hdcp); if (ret != HDF_SUCCESS) { - goto _END; + HdmiHdcpAuthenticationFail(hdcp); + return ret; } /* @@ -396,12 +397,14 @@ static int32_t HdmiHdcpAuthentication(struct HdmiHdcp *hdcp) */ ret = HdmiHdcpAuthenticationFirstPart(hdcp); if (ret != HDF_SUCCESS) { - goto _END; + HdmiHdcpAuthenticationFail(hdcp); + return ret; } HDF_LOGD("hdcp auth Part I success."); /* receiver (0), repeater (1) */ if ((hdcp->bcaps & HDMI_HDCP_BCAPS_REPEATER_MARK) == 0) { - goto _END; + HdmiHdcpAuthenticationSucc(hdcp); + return ret; } /* @@ -409,15 +412,11 @@ static int32_t HdmiHdcpAuthentication(struct HdmiHdcp *hdcp) */ ret = HdmiHdcpAuthenticationSecondPart(hdcp); if (ret != HDF_SUCCESS) { - goto _END; + HdmiHdcpAuthenticationFail(hdcp); + return ret; } -_END: - if (ret == HDF_SUCCESS) { - HdmiHdcpAuthenticationSucc(hdcp); - } else { - HdmiHdcpAuthenticationFail(hdcp); - } + HdmiHdcpAuthenticationSucc(hdcp); return ret; } @@ -444,17 +443,18 @@ int32_t HdmiHdcpOpen(struct HdmiHdcp *hdcp) ret = HdmiHdcpAuthentication(hdcp); if (ret == HDF_SUCCESS) { HDF_LOGD("hdcp Authentication success!"); - goto __END; + (void)OsalMutexUnlock(&(hdcp->hdcpMutex)); + return ret; } while (hdcp->authRetryCnt <= HDMI_HDCP_AUTH_MAX_RETRY_CNT) { ret = HdmiHdcpAuthenticationRetry(hdcp); if (ret == HDF_SUCCESS) { - goto __END; + (void)OsalMutexUnlock(&(hdcp->hdcpMutex)); + return ret; } hdcp->authRetryCnt++; } - __END : (void)OsalMutexUnlock(&(hdcp->hdcpMutex)); return ret; } diff --git a/support/platform/src/hdmi/hdmi_hdr.c b/support/platform/src/hdmi/hdmi_hdr.c index ef6f7f01..eeef852b 100644 --- a/support/platform/src/hdmi/hdmi_hdr.c +++ b/support/platform/src/hdmi/hdmi_hdr.c @@ -203,7 +203,6 @@ int32_t HdmiHdrAttrHandle(struct HdmiHdr *hdr, struct HdmiHdrAttr *curAttr) HDF_LOGD("hdr attr not change"); return HDF_SUCCESS; } - if (oldAttr->colorimetry != curAttr->colorimetry) { HdmiHdrColorimetryUpdate(&(cntlr->attr.videoAttr), curAttr->colorimetry); } @@ -213,7 +212,10 @@ int32_t HdmiHdrAttrHandle(struct HdmiHdr *hdr, struct HdmiHdrAttr *curAttr) if (HdmiDisableHdr(cntlr, curAttr) == HDF_SUCCESS) { commAttr->vsifDolby = false; cntlr->attr.hdrAttr = *curAttr; - goto _SEND_INFOFRAME; + (void)HdmiAviInfoFrameSend(&(cntlr->infoFrame), (commAttr->enableHdmi && commAttr->avi)); + (void)HdmiVsInfoFrameSend(&(cntlr->infoFrame), commAttr->enableHdmi, commAttr->vsifDolby); + HdmiCntlrVideoPathSet(cntlr, &(cntlr->attr.videoAttr)); + return ret; } else { return HDF_FAILURE; } @@ -226,8 +228,6 @@ int32_t HdmiHdrAttrHandle(struct HdmiHdr *hdr, struct HdmiHdrAttr *curAttr) return ret; } (void)HdmiDrmInfoFrameSend(&(cntlr->infoFrame), (commAttr->enableHdmi && commAttr->drm)); - -_SEND_INFOFRAME: (void)HdmiAviInfoFrameSend(&(cntlr->infoFrame), (commAttr->enableHdmi && commAttr->avi)); (void)HdmiVsInfoFrameSend(&(cntlr->infoFrame), commAttr->enableHdmi, commAttr->vsifDolby); HdmiCntlrVideoPathSet(cntlr, &(cntlr->attr.videoAttr)); diff --git a/support/platform/src/hdmi/hdmi_if.c b/support/platform/src/hdmi/hdmi_if.c index dd1aee19..cc52131f 100644 --- a/support/platform/src/hdmi/hdmi_if.c +++ b/support/platform/src/hdmi/hdmi_if.c @@ -416,14 +416,14 @@ static void *HdmiCntlrObjGet(uint16_t busNum) if (snprintf_s(serviceName, (HDMI_SERVICE_NAME_LEN + 1), HDMI_SERVICE_NAME_LEN, "HDF_PLATFORM_HDMI_%u", busNum) < 0) { HDF_LOGE("get HDMI service name fail."); - goto __ERR; + OsalMemFree(serviceName); + return obj; } #ifdef __USER__ obj = (void *)HdfIoServiceBind(serviceName); #else obj = (void *)HdmiCntlrGetByBusNum(busNum); #endif -__ERR: OsalMemFree(serviceName); return obj; } diff --git a/support/platform/src/hdmi/hdmi_ncts.c b/support/platform/src/hdmi/hdmi_ncts.c index aff34dba..53a0a916 100644 --- a/support/platform/src/hdmi/hdmi_ncts.c +++ b/support/platform/src/hdmi/hdmi_ncts.c @@ -9,11 +9,13 @@ #include "hdmi_ncts.h" #define HDF_LOG_TAG hdmi_ncts_c +#define HDMI_NCTS_KHZ 1000 +#define HDMI_NCTS_TMDS_PER_PIXEL 10 #define HDMI_NCTS_INVALID_VALUE 0xffffffff /* - * see hdmi1.4 table 7-1¡¢7-2¡¢7-3. + * see hdmi1.4 table 7-1ã€7-2ã€7-3. * The exact relationship: 128 * fs = tmdsClock * N / CTS. */ static struct HdmiAudioNCts g_audioNctsMap[] = { @@ -114,10 +116,11 @@ uint32_t HdmiGetCts(uint32_t sampleRate, uint32_t tmdsClock) } } - if (tmpCts == 0 && sampleRate >= 1000) { - tmpCts = (tmpN / HDMI_NCTS_FACTOR) * tmdsClock * 10 / (sampleRate / 1000); - } else if (tmpCts == HDMI_NCTS_INVALID_VALUE && sampleRate >= 1000) { - tmpCts = (HDMI_NCTS_N_DEFAULT / HDMI_NCTS_FACTOR) * tmdsClock * 10 / (sampleRate / 1000); + if (tmpCts == 0 && sampleRate >= HDMI_NCTS_KHZ) { + tmpCts = (tmpN / HDMI_NCTS_FACTOR) * tmdsClock * HDMI_NCTS_TMDS_PER_PIXEL / (sampleRate / HDMI_NCTS_KHZ); + } else if (tmpCts == HDMI_NCTS_INVALID_VALUE && sampleRate >= HDMI_NCTS_KHZ) { + tmpCts = (HDMI_NCTS_N_DEFAULT / HDMI_NCTS_FACTOR) * tmdsClock * HDMI_NCTS_TMDS_PER_PIXEL / + (sampleRate / HDMI_NCTS_KHZ); } return tmpCts; } diff --git a/support/platform/src/i2c/i2c_core.c b/support/platform/src/i2c/i2c_core.c index 0095fcb9..4a9c7676 100644 --- a/support/platform/src/i2c/i2c_core.c +++ b/support/platform/src/i2c/i2c_core.c @@ -317,12 +317,14 @@ static int32_t I2cManagerIoTransfer(struct HdfSBuf *data, struct HdfSBuf *reply) ret = I2cCntlrTransfer(I2cManagerFindCntlr(number), msgs, count); if (ret != count) { - goto __EXIT__; + if (bufReply != NULL) { + OsalMemFree(bufReply); + } + return ret; } ret = I2cTransferWriteBackMsgs(reply, msgs, count); -__EXIT__: if (bufReply != NULL) { OsalMemFree(bufReply); } diff --git a/support/platform/src/i2s/i2s_core.c b/support/platform/src/i2s/i2s_core.c index f4e5fddb..1a0bdcb7 100644 --- a/support/platform/src/i2s/i2s_core.c +++ b/support/platform/src/i2s/i2s_core.c @@ -24,7 +24,7 @@ int32_t I2sCntlrOpen(struct I2sCntlr *cntlr) HDF_LOGE("%s: Open not support", __func__); return HDF_ERR_NOT_SUPPORT; } - (void)OsalMutexLock(&(cntlr->lock)); + (void)OsalMutexLock(&(cntlr->lock)); ret = cntlr->method->Open(cntlr); (void)OsalMutexUnlock(&(cntlr->lock)); return ret; @@ -42,7 +42,7 @@ int32_t I2sCntlrClose(struct I2sCntlr *cntlr) HDF_LOGE("%s: Open not support", __func__); return HDF_ERR_NOT_SUPPORT; } - (void)OsalMutexLock(&(cntlr->lock)); + (void)OsalMutexLock(&(cntlr->lock)); ret = cntlr->method->Close(cntlr); (void)OsalMutexUnlock(&(cntlr->lock)); return ret; @@ -60,7 +60,7 @@ int32_t I2sCntlrEnable(struct I2sCntlr *cntlr) HDF_LOGE("%s: Open not support", __func__); return HDF_ERR_NOT_SUPPORT; } - (void)OsalMutexLock(&(cntlr->lock)); + (void)OsalMutexLock(&(cntlr->lock)); ret = cntlr->method->Enable(cntlr); (void)OsalMutexUnlock(&(cntlr->lock)); return ret; @@ -78,7 +78,7 @@ int32_t I2sCntlrDisable(struct I2sCntlr *cntlr) HDF_LOGE("%s: Open not support", __func__); return HDF_ERR_NOT_SUPPORT; } - (void)OsalMutexLock(&(cntlr->lock)); + (void)OsalMutexLock(&(cntlr->lock)); ret = cntlr->method->Disable(cntlr); (void)OsalMutexUnlock(&(cntlr->lock)); return ret; @@ -96,7 +96,7 @@ int32_t I2sCntlrStartRead(struct I2sCntlr *cntlr) HDF_LOGE("%s: Open not support", __func__); return HDF_ERR_NOT_SUPPORT; } - (void)OsalMutexLock(&(cntlr->lock)); + (void)OsalMutexLock(&(cntlr->lock)); ret = cntlr->method->StartRead(cntlr); (void)OsalMutexUnlock(&(cntlr->lock)); return ret; @@ -115,7 +115,7 @@ int32_t I2sCntlrStopRead(struct I2sCntlr *cntlr) HDF_LOGE("%s: Open not support", __func__); return HDF_ERR_NOT_SUPPORT; } - (void)OsalMutexLock(&(cntlr->lock)); + (void)OsalMutexLock(&(cntlr->lock)); ret = cntlr->method->StopRead(cntlr); (void)OsalMutexUnlock(&(cntlr->lock)); return ret; @@ -133,7 +133,7 @@ int32_t I2sCntlrStartWrite(struct I2sCntlr *cntlr) HDF_LOGE("%s: Open not support", __func__); return HDF_ERR_NOT_SUPPORT; } - (void)OsalMutexLock(&(cntlr->lock)); + (void)OsalMutexLock(&(cntlr->lock)); ret = cntlr->method->StartWrite(cntlr); (void)OsalMutexUnlock(&(cntlr->lock)); return ret; @@ -151,7 +151,7 @@ int32_t I2sCntlrStopWrite(struct I2sCntlr *cntlr) HDF_LOGE("%s: Open not support", __func__); return HDF_ERR_NOT_SUPPORT; } - (void)OsalMutexLock(&(cntlr->lock)); + (void)OsalMutexLock(&(cntlr->lock)); ret = cntlr->method->StopWrite(cntlr); (void)OsalMutexUnlock(&(cntlr->lock)); return ret; diff --git a/support/platform/src/i2s/i2s_if.c b/support/platform/src/i2s/i2s_if.c index d2fb248f..d3153eb6 100644 --- a/support/platform/src/i2s/i2s_if.c +++ b/support/platform/src/i2s/i2s_if.c @@ -39,7 +39,7 @@ static struct I2sCntlr *I2sGetCntlrByBusNum(uint32_t num) return cntlr; } -void I2sEnable(DevHandle handle) +void I2sEnable(DevHandle handle) { struct I2sCntlr *cntlr = (struct I2sCntlr *)handle; if (cntlr == NULL) { @@ -54,7 +54,7 @@ void I2sEnable(DevHandle handle) } } -void I2sDisable(DevHandle handle) +void I2sDisable(DevHandle handle) { struct I2sCntlr *cntlr = (struct I2sCntlr *)handle; if (cntlr == NULL) { @@ -125,7 +125,7 @@ void I2sStopRead(DevHandle handle) } } -int32_t I2sWrite(DevHandle handle, uint8_t *buf, uint32_t len, uint32_t *pWlen) +int32_t I2sWrite(DevHandle handle, uint8_t *buf, uint32_t len, uint32_t *pWlen) { struct I2sMsg msg = {0}; if (pWlen == NULL) { @@ -148,7 +148,7 @@ int32_t I2sWrite(DevHandle handle, uint8_t *buf, uint32_t len, uint32_t *pWlen) return HDF_SUCCESS; } -int32_t I2sRead(DevHandle handle, uint8_t *buf, uint32_t len, uint32_t *pRlen) +int32_t I2sRead(DevHandle handle, uint8_t *buf, uint32_t len, uint32_t *pRlen) { struct I2sMsg msg = {0}; if (pRlen == NULL) { diff --git a/support/platform/src/i3c/i3c_core.c b/support/platform/src/i3c/i3c_core.c index a64960a1..e8dc70ae 100755 --- a/support/platform/src/i3c/i3c_core.c +++ b/support/platform/src/i3c/i3c_core.c @@ -25,6 +25,21 @@ static struct I3cManager *g_i3cManager = NULL; static struct DListHead g_i3cDeviceList; static OsalSpinlock g_listLock; +int I3cCheckReservedAddr(uint16_t addr) +{ + if ((addr == I3C_RESERVED_ADDR_7H00) || (addr == I3C_RESERVED_ADDR_7H01) || + (addr == I3C_RESERVED_ADDR_7H02) || (addr == I3C_RESERVED_ADDR_7H3E) || + (addr == I3C_RESERVED_ADDR_7H5E) || (addr == I3C_RESERVED_ADDR_7H6E) || + (addr == I3C_RESERVED_ADDR_7H76) || (addr == I3C_RESERVED_ADDR_7H78) || + (addr == I3C_RESERVED_ADDR_7H79) || (addr == I3C_RESERVED_ADDR_7H7A) || + (addr == I3C_RESERVED_ADDR_7H7B) || (addr == I3C_RESERVED_ADDR_7H7C) || + (addr == I3C_RESERVED_ADDR_7H7D) || (addr == I3C_RESERVED_ADDR_7H7E) || + (addr == I3C_RESERVED_ADDR_7H7F)) { + return I3C_ADDR_RESERVED; + } + return I3C_ADDR_FREE; +} + static inline int32_t I3cCntlrLockDefault(struct I3cCntlr *cntlr) { if (cntlr == NULL) { @@ -128,7 +143,7 @@ static void inline I3cInitAddrStatus(struct I3cCntlr *cntlr) uint16_t addr; for (addr = 0; addr <= I3C_ADDR_MAX; addr++) { - if (CHECK_RESERVED_ADDR(addr) == I3C_ADDR_RESERVED) { + if (I3cCheckReservedAddr(addr) == I3C_ADDR_RESERVED) { (void)SetAddrStatus(cntlr, addr, I3C_ADDR_RESERVED); } } @@ -300,7 +315,7 @@ void I3cDeviceRemove(struct I3cDevice *device) return; } - ret = SetAddrStatus(device->cntlr, device->addr, I3C_ADDR_RESERVED); + ret = SetAddrStatus(device->cntlr, device->addr, I3C_ADDR_RESERVED); if (ret != HDF_SUCCESS) { return; } @@ -549,7 +564,7 @@ int32_t I3cCntlrGetConfig(struct I3cCntlr *cntlr, struct I3cConfig *config) I3cCntlrUnlock(cntlr); return ret; -} +} int32_t I3cCntlrRequestIbi(struct I3cCntlr *cntlr, uint16_t addr, I3cIbiFunc func, uint32_t payload) { diff --git a/support/platform/src/i3c/i3c_if.c b/support/platform/src/i3c/i3c_if.c index 14ecb7b9..81644fae 100755 --- a/support/platform/src/i3c/i3c_if.c +++ b/support/platform/src/i3c/i3c_if.c @@ -46,7 +46,7 @@ int32_t I3cTransfer(DevHandle handle, struct I3cMsg *msgs, int16_t count, enum T case CCC_CMD_MODE: ret = I3cCntlrSendCccCmd((struct I3cCntlr *)handle, msgs->ccc); break; - default: + default: break; } diff --git a/support/platform/src/pin/pin_core.c b/support/platform/src/pin/pin_core.c index fce5ed37..bb6003a4 100644 --- a/support/platform/src/pin/pin_core.c +++ b/support/platform/src/pin/pin_core.c @@ -25,7 +25,7 @@ static struct DListHead *PinCntlrListGet(void) head = &g_cntlrListHead; DListHeadInit(head); OsalSpinInit(&g_listLock); - } + } while (OsalSpinLockIrqSave(&g_listLock, &irqSave) != HDF_SUCCESS); g_irqSave = irqSave; return head; diff --git a/support/platform/src/pwm/pwm_core.c b/support/platform/src/pwm/pwm_core.c index c13371a8..ddd510f3 100644 --- a/support/platform/src/pwm/pwm_core.c +++ b/support/platform/src/pwm/pwm_core.c @@ -132,7 +132,7 @@ void *PwmGetPriv(struct PwmDev *pwm) static int32_t PwmUserSetConfig(struct PwmDev *pwm, struct HdfSBuf *data) { size_t size; - struct PwmConfig *config = NULL;; + struct PwmConfig *config = NULL; if (data == NULL) { HDF_LOGE("%s: data null", __func__); diff --git a/support/platform/src/regulator/regulator_core.c b/support/platform/src/regulator/regulator_core.c index 9ee4f886..804b682c 100755 --- a/support/platform/src/regulator/regulator_core.c +++ b/support/platform/src/regulator/regulator_core.c @@ -74,10 +74,10 @@ void RegulatorNodeListPrint(void) } DLIST_FOR_EACH_ENTRY_SAFE(pos, tmp, &manager->regulatorHead, struct RegulatorNode, node) { - HDF_LOGI("RegulatorNodeListPrint: name[%s], [%d][%d][%d], [%d][%d]--[%d][%d]", + HDF_LOGI("RegulatorNodeListPrint: name[%s], [%d][%d][%d], [%d][%d]--[%d][%d]", pos->regulatorInfo.name, pos->regulatorInfo.status, - pos->regulatorInfo.constraints.alwaysOn, pos->regulatorInfo.constraints.mode, - pos->regulatorInfo.constraints.minUv, pos->regulatorInfo.constraints.maxUv, + pos->regulatorInfo.constraints.alwaysOn, pos->regulatorInfo.constraints.mode, + pos->regulatorInfo.constraints.minUv, pos->regulatorInfo.constraints.maxUv, pos->regulatorInfo.constraints.minUa, pos->regulatorInfo.constraints.maxUa); if ((pos->regulatorInfo.parentName != NULL) && (strlen(pos->regulatorInfo.parentName) > 0)) { HDF_LOGI("RegulatorNodeListPrint:parentName[%s]", pos->regulatorInfo.parentName); @@ -101,7 +101,7 @@ int32_t RegulatorNodeSetParent(struct RegulatorNode *node) return HDF_ERR_DEVICE_BUSY; } // parent set - if ((node->regulatorInfo.parentName != NULL) + if ((node->regulatorInfo.parentName != NULL) && (strlen(node->regulatorInfo.parentName) > 0)) { DLIST_FOR_EACH_ENTRY_SAFE(pos, tmp, &manager->regulatorHead, struct RegulatorNode, node) { if (strcmp(node->regulatorInfo.parentName, pos->regulatorInfo.name) == 0) { @@ -117,7 +117,7 @@ int32_t RegulatorNodeSetParent(struct RegulatorNode *node) } } - HDF_LOGE("%s: RegulatorTreeSet find %s parent %s error", + HDF_LOGE("%s: RegulatorTreeSet find %s parent %s error", __func__, node->regulatorInfo.name, node->regulatorInfo.parentName); (void)OsalMutexUnlock(&manager->lock); return HDF_FAILURE; @@ -142,9 +142,9 @@ int32_t RegulatorNodeSetChild(struct RegulatorNode *parent) } DLIST_FOR_EACH_ENTRY_SAFE(pos, tmp, &manager->regulatorHead, struct RegulatorNode, node) { - if ((pos->regulatorInfo.parentName != NULL) && + if ((pos->regulatorInfo.parentName != NULL) && (strcmp(parent->regulatorInfo.name, pos->regulatorInfo.parentName) == 0)) { - HDF_LOGD("%s: node[%s] parent is %s, tree info process", __func__, + HDF_LOGD("%s: node[%s] parent is %s, tree info process", __func__, pos->regulatorInfo.parentName, parent->regulatorInfo.name); if (RegulatorTreeSet(pos->regulatorInfo.name, pos, parent) != HDF_SUCCESS) { HDF_LOGE("%s: RegulatorTreeSet failed", __func__); @@ -394,7 +394,7 @@ int32_t RegulatorNodeDisable(struct RegulatorNode *node) { CHECK_NULL_PTR_RETURN_VALUE(node, HDF_ERR_INVALID_PARAM); if ((node->regulatorInfo.status == REGULATOR_STATUS_OFF) || (node->regulatorInfo.constraints.alwaysOn)) { - HDF_LOGI("RegulatorNodeDisable: %s [%d][%d], unsatisfied closing adjusment", + HDF_LOGI("RegulatorNodeDisable: %s [%d][%d], unsatisfied closing adjusment", node->regulatorInfo.name, node->regulatorInfo.status, node->regulatorInfo.constraints.alwaysOn); return HDF_SUCCESS; } @@ -431,7 +431,7 @@ int32_t RegulatorNodeDisable(struct RegulatorNode *node) } if (RegulatorNodeDisable(parent) != HDF_SUCCESS) { (void)OsalMutexUnlock(&node->lock); - HDF_LOGD("RegulatorNodeDisable: disable %s's parent %s failed", + HDF_LOGD("RegulatorNodeDisable: disable %s's parent %s failed", node->regulatorInfo.name, parent->regulatorInfo.name); return HDF_SUCCESS; } @@ -486,7 +486,7 @@ int32_t RegulatorNodeForceDisable(struct RegulatorNode *node) } if (RegulatorNodeDisable(parent) != HDF_SUCCESS) { (void)OsalMutexUnlock(&node->lock); - HDF_LOGD("RegulatorNodeDisable: disable %s's parent %s failed", + HDF_LOGD("RegulatorNodeDisable: disable %s's parent %s failed", node->regulatorInfo.name, parent->regulatorInfo.name); return HDF_SUCCESS; } @@ -500,7 +500,7 @@ int32_t RegulatorNodeSetVoltage(struct RegulatorNode *node, uint32_t minUv, uint { CHECK_NULL_PTR_RETURN_VALUE(node, HDF_ERR_INVALID_PARAM); if (node->regulatorInfo.constraints.mode != REGULATOR_CHANGE_VOLTAGE) { - HDF_LOGE("RegulatorNodeSetVoltage: %s mode %d invalid!", + HDF_LOGE("RegulatorNodeSetVoltage: %s mode %d invalid!", node->regulatorInfo.name, node->regulatorInfo.constraints.mode); return HDF_FAILURE; } @@ -509,10 +509,10 @@ int32_t RegulatorNodeSetVoltage(struct RegulatorNode *node, uint32_t minUv, uint return HDF_SUCCESS; } - if ((minUv > maxUv) || - (minUv < node->regulatorInfo.constraints.minUv || + if ((minUv > maxUv) || + (minUv < node->regulatorInfo.constraints.minUv || maxUv > node->regulatorInfo.constraints.maxUv)) { - HDF_LOGE("RegulatorNodeSetVoltage: %s Uv [%d, %d] invalid!", + HDF_LOGE("RegulatorNodeSetVoltage: %s Uv [%d, %d] invalid!", node->regulatorInfo.name, minUv, maxUv); return HDF_FAILURE; } @@ -542,7 +542,7 @@ int32_t RegulatorNodeGetVoltage(struct RegulatorNode *node, uint32_t *voltage) CHECK_NULL_PTR_RETURN_VALUE(voltage, HDF_ERR_INVALID_PARAM); if (node->regulatorInfo.constraints.mode != REGULATOR_CHANGE_VOLTAGE) { - HDF_LOGE("RegulatorNodeSetVoltage: %s mode %d invalid!", + HDF_LOGE("RegulatorNodeSetVoltage: %s mode %d invalid!", node->regulatorInfo.name, node->regulatorInfo.constraints.mode); return HDF_FAILURE; } @@ -560,7 +560,7 @@ int32_t RegulatorNodeSetCurrent(struct RegulatorNode *node, uint32_t minUA, uint { CHECK_NULL_PTR_RETURN_VALUE(node, HDF_ERR_INVALID_PARAM); if (node->regulatorInfo.constraints.mode != REGULATOR_CHANGE_CURRENT) { - HDF_LOGE("RegulatorNodeSetVoltage: %s mode %d invalid!", + HDF_LOGE("RegulatorNodeSetVoltage: %s mode %d invalid!", node->regulatorInfo.name, node->regulatorInfo.constraints.mode); return HDF_FAILURE; } @@ -569,10 +569,10 @@ int32_t RegulatorNodeSetCurrent(struct RegulatorNode *node, uint32_t minUA, uint return HDF_SUCCESS; } - if ((minUA > maxUA) || - (minUA < node->regulatorInfo.constraints.minUa || + if ((minUA > maxUA) || + (minUA < node->regulatorInfo.constraints.minUa || maxUA > node->regulatorInfo.constraints.maxUa)) { - HDF_LOGE("RegulatorNodeSetCurrent: %s UA [%d, %d] invalid!", + HDF_LOGE("RegulatorNodeSetCurrent: %s UA [%d, %d] invalid!", node->regulatorInfo.name, minUA, maxUA); return HDF_FAILURE; } @@ -600,7 +600,7 @@ int32_t RegulatorNodeGetCurrent(struct RegulatorNode *node, uint32_t *regCurrent CHECK_NULL_PTR_RETURN_VALUE(node, HDF_ERR_INVALID_OBJECT); CHECK_NULL_PTR_RETURN_VALUE(regCurrent, HDF_ERR_INVALID_OBJECT); if (node->regulatorInfo.constraints.mode != REGULATOR_CHANGE_CURRENT) { - HDF_LOGE("RegulatorNodeGetCurrent: %s mode %d invalid!", + HDF_LOGE("RegulatorNodeGetCurrent: %s mode %d invalid!", node->regulatorInfo.name, node->regulatorInfo.constraints.mode); return HDF_FAILURE; } @@ -642,7 +642,7 @@ int32_t RegulatorTreeInfoInit(struct RegulatorNode *node) struct RegulatorManager *manager = g_regulatorManager; CHECK_NULL_PTR_RETURN_VALUE(manager, HDF_ERR_INVALID_OBJECT); - if ((node->regulatorInfo.parentName != NULL) + if ((node->regulatorInfo.parentName != NULL) && (strlen(node->regulatorInfo.parentName) > 0)) { DLIST_FOR_EACH_ENTRY_SAFE(pos, tmp, &manager->regulatorHead, struct RegulatorNode, node) { if (strcmp(node->regulatorInfo.parentName, pos->regulatorInfo.name) == 0) { @@ -656,7 +656,7 @@ int32_t RegulatorTreeInfoInit(struct RegulatorNode *node) } } - HDF_LOGE("%s: RegulatorTreeSet find %s parent %s error", + HDF_LOGE("%s: RegulatorTreeSet find %s parent %s error", __func__, node->regulatorInfo.name, node->regulatorInfo.parentName); return HDF_FAILURE; } diff --git a/support/platform/src/regulator/regulator_if.c b/support/platform/src/regulator/regulator_if.c index 90165741..76c3bc4b 100755 --- a/support/platform/src/regulator/regulator_if.c +++ b/support/platform/src/regulator/regulator_if.c @@ -93,7 +93,7 @@ int32_t RegulatorSetVoltage(DevHandle handle, uint32_t minUv, uint32_t maxUv) } if (minUv > maxUv) { - HDF_LOGE("RegulatorSetVoltage: %s Uv [%d, %d] invalid!", + HDF_LOGE("RegulatorSetVoltage: %s Uv [%d, %d] invalid!", node->regulatorInfo.name, minUv, maxUv); return HDF_FAILURE; } @@ -133,7 +133,7 @@ int32_t RegulatorSetCurrent(DevHandle handle, uint32_t minUa, uint32_t maxUa) } if (minUa > maxUa) { - HDF_LOGE("RegulatorSetCurrent: %s Ua [%d, %d] invalid!", + HDF_LOGE("RegulatorSetCurrent: %s Ua [%d, %d] invalid!", node->regulatorInfo.name, minUa, maxUa); return HDF_FAILURE; } diff --git a/support/platform/src/regulator/regulator_tree_mgr.c b/support/platform/src/regulator/regulator_tree_mgr.c index a1386fa2..1f11d984 100755 --- a/support/platform/src/regulator/regulator_tree_mgr.c +++ b/support/platform/src/regulator/regulator_tree_mgr.c @@ -65,7 +65,7 @@ struct RegulatorNode *RegulatorTreeGetParent(const char *name) return NULL; } (void)OsalMutexUnlock(&manager->lock); - HDF_LOGI("RegulatorTreeGetParent: get %s parent %s success!", + HDF_LOGI("RegulatorTreeGetParent: get %s parent %s success!", name, pos->parent->regulatorInfo.name); return pos->parent; } @@ -352,7 +352,7 @@ static void RegulatorTreePrintChild(const char *name, struct DListHead *childHea struct RegulatorChildNode *tmp = NULL; DLIST_FOR_EACH_ENTRY_SAFE(nodeInfo, tmp, childHead, struct RegulatorChildNode, node) { - HDF_LOGI("RegulatorTreePrintChild: %s's child %s !", + HDF_LOGI("RegulatorTreePrintChild: %s's child %s !", name, nodeInfo->child->regulatorInfo.name); } } @@ -372,7 +372,7 @@ void RegulatorTreePrint(void) DLIST_FOR_EACH_ENTRY_SAFE(pos, tmp, &manager->treeMgrHead, struct RegulatorTreeInfo, node) { HDF_LOGI("RegulatorTreePrint %s info IN ---->", pos->name); if (pos->parent != NULL) { - HDF_LOGI("RegulatorTreePrint %s info, parent name[%s]", + HDF_LOGI("RegulatorTreePrint %s info, parent name[%s]", pos->name, pos->parent->regulatorInfo.name); } diff --git a/support/platform/src/rtc/rtc_if_u.c b/support/platform/src/rtc/rtc_if_u.c index 52ad81d4..fcc3ebd7 100755 --- a/support/platform/src/rtc/rtc_if_u.c +++ b/support/platform/src/rtc/rtc_if_u.c @@ -28,7 +28,6 @@ DevHandle RtcOpen() void *host = NULL; host = HdfIoServiceBind("HDF_PLATFORM_RTC"); - if (host == NULL) { HDF_LOGE("%s: rtc service bind fail", __func__); return NULL; @@ -59,7 +58,7 @@ int32_t RtcReadTime(DevHandle handle, struct RtcTime *time) struct HdfIoService *service = NULL; struct RtcTime *temp = NULL; - if(handle == NULL || time == NULL) { + if (handle == NULL || time == NULL) { HDF_LOGE("%s: handle or time is NULL.", __func__); return HDF_ERR_INVALID_OBJECT; } @@ -115,7 +114,7 @@ int32_t RtcWriteTime(DevHandle handle, const struct RtcTime *time) struct HdfSBuf *data = NULL; struct HdfIoService *service = NULL; - if(handle == NULL || time == NULL) { + if (handle == NULL || time == NULL) { HDF_LOGE("%s: handle or time is NULL.", __func__); return HDF_ERR_INVALID_OBJECT; } @@ -162,7 +161,7 @@ int32_t RtcReadAlarm(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct Rtc struct RtcTime *temp = NULL; struct HdfIoService *service = NULL; - if(handle == NULL || time == NULL) { + if (handle == NULL || time == NULL) { HDF_LOGE("%s: handle or time is NULL.", __func__); return HDF_ERR_INVALID_OBJECT; } @@ -232,7 +231,7 @@ int32_t RtcWriteAlarm(DevHandle handle, enum RtcAlarmIndex alarmIndex, const str struct HdfSBuf *data = NULL; struct HdfIoService *service = NULL; - if(handle == NULL || time == NULL) { + if (handle == NULL || time == NULL) { HDF_LOGE("%s: handle or time is NULL.", __func__); return HDF_ERR_INVALID_OBJECT; } @@ -278,7 +277,7 @@ int32_t RtcWriteAlarm(DevHandle handle, enum RtcAlarmIndex alarmIndex, const str int32_t RtcRegisterAlarmCallback(DevHandle handle, enum RtcAlarmIndex alarmIndex, RtcAlarmCallback cb) { (void)alarmIndex; - if(handle == NULL || cb == NULL) { + if (handle == NULL || cb == NULL) { HDF_LOGE("%s: handle or cb is NULL.", __func__); return HDF_ERR_INVALID_OBJECT; } @@ -293,7 +292,7 @@ int32_t RtcAlarmInterruptEnable(DevHandle handle, enum RtcAlarmIndex alarmIndex, struct HdfSBuf *data = NULL; struct HdfIoService *service = NULL; - if(handle == NULL) { + if (handle == NULL) { HDF_LOGE("%s: handle is NULL.", __func__); return HDF_ERR_INVALID_OBJECT; } @@ -343,7 +342,7 @@ int32_t RtcGetFreq(DevHandle handle, uint32_t *freq) struct HdfSBuf *reply = NULL; struct HdfIoService *service = NULL; - if(handle == NULL || freq == NULL) { + if (handle == NULL || freq == NULL) { HDF_LOGE("%s: handle or freq is NULL.", __func__); return HDF_ERR_INVALID_OBJECT; } @@ -386,7 +385,7 @@ int32_t RtcSetFreq(DevHandle handle, uint32_t freq) struct HdfSBuf *data = NULL; struct HdfIoService *service = NULL; - if(handle == NULL) { + if (handle == NULL) { HDF_LOGE("%s: handle is NULL.", __func__); return HDF_ERR_INVALID_OBJECT; } @@ -459,7 +458,7 @@ int32_t RtcReadReg(DevHandle handle, uint8_t usrDefIndex, uint8_t *value) struct HdfSBuf *reply = NULL; struct HdfIoService *service = NULL; - if(handle == NULL || value == NULL) { + if (handle == NULL || value == NULL) { HDF_LOGE("%s: handle or value is NULL.", __func__); return HDF_ERR_INVALID_OBJECT; } @@ -517,7 +516,7 @@ int32_t RtcWriteReg(DevHandle handle, uint8_t usrDefIndex, uint8_t value) struct HdfSBuf *data = NULL; struct HdfIoService *service = NULL; - if(handle == NULL) { + if (handle == NULL) { HDF_LOGE("%s: handle is NULL.", __func__); return HDF_ERR_INVALID_OBJECT; } diff --git a/support/platform/src/spi/spi_core.c b/support/platform/src/spi/spi_core.c index 8dfdad56..764ac148 100644 --- a/support/platform/src/spi/spi_core.c +++ b/support/platform/src/spi/spi_core.c @@ -201,7 +201,7 @@ static int32_t SpiIoTransfer(struct SpiCntlr *cntlr, uint32_t csNum, struct HdfS ret = SpiCntlrTransfer(cntlr, csNum, msgs, count); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: do transfer failed:%d", __func__, ret); - goto EXIT; + goto EXIT; } ret = SpiTransferWriteBackMsgs(reply, msgs, count); diff --git a/support/platform/src/spi/spi_if_u.c b/support/platform/src/spi/spi_if_u.c index 55e9f0e8..0f5e9f60 100644 --- a/support/platform/src/spi/spi_if_u.c +++ b/support/platform/src/spi/spi_if_u.c @@ -57,7 +57,7 @@ static int32_t SpiMsgWriteArray(struct SpiObject *object, struct HdfSBuf *data, } for (i = 0; i < count; i++) { - if(msgs[i].wbuf == NULL) { + if (msgs[i].wbuf == NULL) { continue; } @@ -93,13 +93,13 @@ static int32_t SpiMsgReadBack(struct HdfSBuf *data, struct SpiMsg *msg) return HDF_SUCCESS; } -static inline int32_t SpiMsgReadArray(struct HdfSBuf *reply, struct SpiMsg *msgs, uint32_t count) +static int32_t SpiMsgReadArray(struct HdfSBuf *reply, struct SpiMsg *msgs, uint32_t count) { uint32_t i; int32_t ret; for (i = 0; i < count; i++) { - if(msgs[i].rbuf == NULL) { + if (msgs[i].rbuf == NULL) { continue; } ret = SpiMsgReadBack(reply, &msgs[i]); @@ -293,7 +293,7 @@ int32_t SpiGetCfg(DevHandle handle, struct SpiCfg *cfg) HDF_LOGE("%s: memcpy rBuf failed", __func__); ret = HDF_ERR_IO; goto EXIT; - } + } EXIT: HdfSbufRecycle(data); HdfSbufRecycle(reply); diff --git a/support/platform/src/timer/timer_core.c b/support/platform/src/timer/timer_core.c index 3343e8de..4469d7a1 100755 --- a/support/platform/src/timer/timer_core.c +++ b/support/platform/src/timer/timer_core.c @@ -324,7 +324,7 @@ static int32_t TimerIoGet(struct HdfSBuf *data, struct HdfSBuf *reply) return HDF_ERR_IO; } - number = (int16_t)(handle - TIMER_HANDLE_SHIFT); + number = (int16_t)(handle - TIMER_HANDLE_SHIFT); if (number < 0) { HDF_LOGE("%s: number[%d] invalid", __func__, number); return HDF_ERR_INVALID_PARAM; diff --git a/support/platform/src/timer/timer_if_u.c b/support/platform/src/timer/timer_if_u.c index 9ce79a0e..9aa654ef 100755 --- a/support/platform/src/timer/timer_if_u.c +++ b/support/platform/src/timer/timer_if_u.c @@ -206,7 +206,7 @@ int32_t HwTimerSet(DevHandle handle, uint32_t useconds, TimerHandleCb cb) } service = (struct HdfIoService *)TimerManagerGetService(); - if (service == NULL || service->dispatcher == NULL + if (service == NULL || service->dispatcher == NULL || service->dispatcher->Dispatch == NULL || cb == NULL) { HDF_LOGE("%s:param is invalid", __func__); return HDF_ERR_INVALID_PARAM; @@ -257,7 +257,7 @@ int32_t HwTimerSetOnce(DevHandle handle, uint32_t useconds, TimerHandleCb cb) } service = (struct HdfIoService *)TimerManagerGetService(); - if (service == NULL || service->dispatcher == NULL + if (service == NULL || service->dispatcher == NULL || service->dispatcher->Dispatch == NULL || cb == NULL) { HDF_LOGE("%s: service is invalid", __func__); return HDF_ERR_INVALID_PARAM; diff --git a/support/platform/src/uart/uart_core.c b/support/platform/src/uart/uart_core.c index 7b364b91..74dfc538 100644 --- a/support/platform/src/uart/uart_core.c +++ b/support/platform/src/uart/uart_core.c @@ -13,44 +13,56 @@ #define HDF_LOG_TAG uart_core_c -int32_t UartHostInit(struct UartHost *host) +int32_t UartHostRequest(struct UartHost *host) { int32_t ret; - if (host == NULL || host->method == NULL) { - HDF_LOGE("%s: host or method is NULL", __func__); + if (host == NULL) { + HDF_LOGE("%s: host is NULL", __func__); return HDF_ERR_INVALID_PARAM; } - if (OsalAtomicRead(&host->atom) == 1) { - HDF_LOGE("%s: device is busy", __func__); + + if (host->method == NULL || host->method->Init == NULL) { + HDF_LOGE("%s: method or init is NULL", __func__); + return HDF_ERR_NOT_SUPPORT; + } + + if (OsalAtomicIncReturn(&host->atom) > 1) { + HDF_LOGE("%s: uart device is busy", __func__); + OsalAtomicDec(&host->atom); return HDF_ERR_DEVICE_BUSY; } - OsalAtomicInc(&host->atom); - if (host->method->Init != NULL) { - ret = host->method->Init(host); - if (ret != HDF_SUCCESS) { - OsalAtomicDec(&host->atom); - HDF_LOGE("%s: host init failed", __func__); - return ret; - } + + ret = host->method->Init(host); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: host init fail", __func__); + OsalAtomicDec(&host->atom); + return ret; } + return HDF_SUCCESS; } -int32_t UartHostDeinit(struct UartHost *host) +int32_t UartHostRelease(struct UartHost *host) { int32_t ret; - if (host == NULL || host->method == NULL) { + + if (host == NULL) { HDF_LOGE("%s: host or method is NULL", __func__); return HDF_ERR_INVALID_PARAM; } - if (host->method->Deinit != NULL) { - ret = host->method->Deinit(host); - if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: host deinit failed", __func__); - return ret; - } + + if (host->method == NULL || host->method->Deinit == NULL) { + HDF_LOGE("%s: method or Deinit is NULL", __func__); + return HDF_ERR_NOT_SUPPORT; } + + ret = host->method->Deinit(host); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: host deinit fail", __func__); + return ret; + } + OsalAtomicDec(&host->atom); return HDF_SUCCESS; } @@ -71,11 +83,13 @@ struct UartHost *UartHostCreate(struct HdfDeviceObject *device) HDF_LOGE("%s: invalid parameter", __func__); return NULL; } + host = (struct UartHost *)OsalMemCalloc(sizeof(*host)); if (host == NULL) { HDF_LOGE("%s: OsalMemCalloc error", __func__); return NULL; } + host->device = device; device->service = &(host->service); host->device->service->Dispatch = UartIoDispatch; diff --git a/support/platform/src/uart/uart_if.c b/support/platform/src/uart/uart_if.c index 442ad08f..589c5a2d 100644 --- a/support/platform/src/uart/uart_if.c +++ b/support/platform/src/uart/uart_if.c @@ -19,10 +19,9 @@ static void *UartGetObjGetByBusNum(uint32_t num) { int ret; - char name[UART_HOST_NAME_LEN + 1] = { 0 }; + char name[UART_HOST_NAME_LEN + 1] = {0}; - ret = snprintf_s(name, UART_HOST_NAME_LEN + 1, UART_HOST_NAME_LEN, - "HDF_PLATFORM_UART_%u", num); + ret = snprintf_s(name, UART_HOST_NAME_LEN + 1, UART_HOST_NAME_LEN, "HDF_PLATFORM_UART_%u", num); if (ret < 0) { HDF_LOGE("%s: snprintf_s failed", __func__); return NULL; @@ -48,9 +47,9 @@ DevHandle UartOpen(uint32_t port) HDF_LOGE("%s: get handle error", __func__); return NULL; } - ret = UartHostInit((struct UartHost *)handle); + ret = UartHostRequest((struct UartHost *)handle); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: UartHostInit error, ret %d", __func__, ret); + HDF_LOGE("%s: UartHostRequest error, ret %d", __func__, ret); UartPutObjByPointer(handle); return NULL; } @@ -64,9 +63,9 @@ void UartClose(DevHandle handle) HDF_LOGE("%s: handle is NULL", __func__); return; } - ret = UartHostDeinit((struct UartHost *)handle); + ret = UartHostRelease((struct UartHost *)handle); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: UartHostDeinit error, ret %d", __func__, ret); + HDF_LOGE("%s: UartHostRelease error, ret %d", __func__, ret); } UartPutObjByPointer(handle); } diff --git a/support/platform/src/uart/uart_if_u.c b/support/platform/src/uart/uart_if_u.c index e13b41d4..83253c17 100644 --- a/support/platform/src/uart/uart_if_u.c +++ b/support/platform/src/uart/uart_if_u.c @@ -6,11 +6,11 @@ * See the LICENSE file in the root of this repository for complete details. */ -#include "uart_if.h" #include "hdf_io_service_if.h" #include "hdf_log.h" #include "osal_mem.h" #include "securec.h" +#include "uart_if.h" #define HDF_LOG_TAG uart_if_u_c #define UART_HOST_NAME_LEN 32 @@ -18,10 +18,9 @@ static void *UartGetObjGetByBusNum(uint32_t num) { int ret; - char name[UART_HOST_NAME_LEN + 1] = { 0 }; + char name[UART_HOST_NAME_LEN + 1] = {0}; - ret = snprintf_s(name, UART_HOST_NAME_LEN + 1, UART_HOST_NAME_LEN, - "HDF_PLATFORM_UART_%u", num); + ret = snprintf_s(name, UART_HOST_NAME_LEN + 1, UART_HOST_NAME_LEN, "HDF_PLATFORM_UART_%u", num); if (ret < 0) { HDF_LOGE("%s: snprintf_s failed", __func__); return NULL; @@ -55,10 +54,9 @@ DevHandle UartOpen(uint32_t port) UartPutObjByPointer(handle); return NULL; } - ret = service->dispatcher->Dispatch(&service->object, UART_IO_INIT, NULL, NULL); - + ret = service->dispatcher->Dispatch(&service->object, UART_IO_REQUEST, NULL, NULL); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: UartHostInit error, ret %d", __func__, ret); + HDF_LOGE("%s: UartHostRequest error, ret %d", __func__, ret); UartPutObjByPointer(handle); return NULL; } @@ -82,14 +80,14 @@ void UartClose(DevHandle handle) return; } - ret = service->dispatcher->Dispatch(&service->object, UART_IO_DEINIT, NULL, NULL); + ret = service->dispatcher->Dispatch(&service->object, UART_IO_RELEASE, NULL, NULL); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: UartHostDeinit error, ret %d", __func__, ret); + HDF_LOGE("%s: UartHostRelease error, ret %d", __func__, ret); } UartPutObjByPointer(handle); } -static int32_t UartDispatch(DevHandle handle, int cmd, struct HdfSBuf *data, struct HdfSBuf *reply) +static int32_t UartDispatch(DevHandle handle, int cmd, struct HdfSBuf *data, struct HdfSBuf *reply) { int32_t ret; struct HdfIoService *service = (struct HdfIoService *)handle; @@ -103,7 +101,7 @@ static int32_t UartDispatch(DevHandle handle, int cmd, struct HdfSBuf *data, st HDF_LOGE("%s: dispatcher is null", __func__); return HDF_ERR_INVALID_PARAM; } - + ret = service->dispatcher->Dispatch(&service->object, cmd, data, reply); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Dispatch failed: %d", __func__, ret); @@ -280,8 +278,7 @@ int32_t UartGetAttribute(DevHandle handle, struct UartAttribute *attribute) } if (tmpLen != sizeof(*attribute)) { - HDF_LOGE("%s: reply data len not match, exp:%zu, got:%u", - __func__, sizeof(*attribute), tmpLen); + HDF_LOGE("%s: reply data len not match, exp:%zu, got:%u", __func__, sizeof(*attribute), tmpLen); HdfSbufRecycle(reply); return HDF_ERR_IO; } diff --git a/support/platform/src/uart/uart_service.c b/support/platform/src/uart/uart_service.c index c82cb075..802d1ab3 100644 --- a/support/platform/src/uart/uart_service.c +++ b/support/platform/src/uart/uart_service.c @@ -119,8 +119,7 @@ static int32_t UartIoSetAttribute(struct UartHost *host, struct HdfSBuf *data) } if (size != sizeof(*attribute)) { - HDF_LOGE("%s: sbuf read size not match, exp:%zu, got:%u", - __func__, sizeof(*attribute), size); + HDF_LOGE("%s: sbuf read size not match, exp:%zu, got:%u", __func__, sizeof(*attribute), size); return HDF_ERR_IO; } @@ -138,8 +137,7 @@ static int32_t UartIoSetTransMode(struct UartHost *host, struct HdfSBuf *data) return UartHostSetTransMode(host, mode); } -int32_t UartIoDispatch(struct HdfDeviceIoClient *client, int cmd, - struct HdfSBuf *data, struct HdfSBuf *reply) +int32_t UartIoDispatch(struct HdfDeviceIoClient *client, int cmd, struct HdfSBuf *data, struct HdfSBuf *reply) { struct UartHost *host = NULL; @@ -160,10 +158,10 @@ int32_t UartIoDispatch(struct HdfDeviceIoClient *client, int cmd, host = (struct UartHost *)client->device->service; switch (cmd) { - case UART_IO_INIT: - return UartHostInit(host); - case UART_IO_DEINIT: - return UartHostDeinit(host); + case UART_IO_REQUEST: + return UartHostRequest(host); + case UART_IO_RELEASE: + return UartHostRelease(host); case UART_IO_READ: return UartIoRead(host, data, reply); case UART_IO_WRITE: diff --git a/support/platform/test/unittest/common/hdf_adc_test.cpp b/support/platform/test/unittest/common/hdf_adc_test.cpp index 4cd134f2..c610610e 100644 --- a/support/platform/test/unittest/common/hdf_adc_test.cpp +++ b/support/platform/test/unittest/common/hdf_adc_test.cpp @@ -59,7 +59,6 @@ HWTEST_F(HdfLiteAdcTest, AdcTestRead001, TestSize.Level1) printf("%s: kernel test done, then for user...\n", __func__); EXPECT_EQ(0, AdcTestExecute(ADC_TEST_CMD_READ)); printf("%s: exit!\n", __func__); - } /** @@ -76,7 +75,6 @@ HWTEST_F(HdfLiteAdcTest, AdcTestMultiThread001, TestSize.Level1) printf("%s: kernel test done, then for user...\n", __func__); EXPECT_EQ(0, AdcTestExecute(ADC_TEST_CMD_MULTI_THREAD)); printf("%s: exit!\n", __func__); - } /** @@ -93,7 +91,6 @@ HWTEST_F(HdfLiteAdcTest, AdcTestReliability001, TestSize.Level1) printf("%s: kernel test done, then for user...\n", __func__); EXPECT_EQ(0, AdcTestExecute(ADC_TEST_CMD_RELIABILITY)); printf("%s: exit!\n", __func__); - } /** diff --git a/support/platform/test/unittest/common/hdf_gpio_test.cpp b/support/platform/test/unittest/common/hdf_gpio_test.cpp index d3bf1e3a..fb6eb54a 100644 --- a/support/platform/test/unittest/common/hdf_gpio_test.cpp +++ b/support/platform/test/unittest/common/hdf_gpio_test.cpp @@ -145,7 +145,7 @@ HWTEST_F(HdfLiteGpioTest, GpioTestReliability001, TestSize.Level1) * @tc.name: GpioIfPerformanceTest001 * @tc.desc: gpio user if performance test * @tc.type: FUNC - * @tc.require: + * @tc.require: */ HWTEST_F(HdfLiteGpioTest, GpioIfPerformanceTest001, TestSize.Level1) { diff --git a/support/platform/test/unittest/common/hdf_pin_test.cpp b/support/platform/test/unittest/common/hdf_pin_test.cpp index 0b1ed87c..8f4be42c 100644 --- a/support/platform/test/unittest/common/hdf_pin_test.cpp +++ b/support/platform/test/unittest/common/hdf_pin_test.cpp @@ -88,10 +88,10 @@ HWTEST_F(HdfPinTest, PinSetGetPinFunc001, TestSize.Level1) * @tc.name: PinReliabilityTest001 * @tc.desc: Pin function test * @tc.type: FUNC - * @tc.require: + * @tc.require: */ HWTEST_F(HdfPinTest, PinReliabilityTest001, TestSize.Level1) { struct HdfTestMsg msg = {TEST_PAL_PIN_TYPE, PIN_TEST_CMD_RELIABILITY, -1}; EXPECT_EQ(0, HdfTestSendMsgToService(&msg)); -} \ No newline at end of file +} diff --git a/support/platform/test/unittest/common/hdf_pwm_test.cpp b/support/platform/test/unittest/common/hdf_pwm_test.cpp index 52b0648d..e4f55a72 100644 --- a/support/platform/test/unittest/common/hdf_pwm_test.cpp +++ b/support/platform/test/unittest/common/hdf_pwm_test.cpp @@ -127,7 +127,7 @@ HWTEST_F(HdfLitePwmTest, PwmDisableTest001, TestSize.Level1) * @tc.name: PwmIfPerformanceTest001 * @tc.desc: pwm user if performance test * @tc.type: FUNC - * @tc.require: + * @tc.require: */ HWTEST_F(HdfLitePwmTest, PwmIfPerformanceTest001, TestSize.Level1) { diff --git a/support/platform/test/unittest/common/hdf_uart_test.cpp b/support/platform/test/unittest/common/hdf_uart_test.cpp index f2767056..2894c46c 100644 --- a/support/platform/test/unittest/common/hdf_uart_test.cpp +++ b/support/platform/test/unittest/common/hdf_uart_test.cpp @@ -177,7 +177,7 @@ HWTEST_F(HdfLiteUartTest, UartReliabilityTest001, TestSize.Level1) * @tc.name: UartIfPerformanceTest001 * @tc.desc: uart user if performance test * @tc.type: FUNC - * @tc.require: + * @tc.require: */ HWTEST_F(HdfLiteUartTest, UartIfPerformanceTest001, TestSize.Level1) { diff --git a/test/unittest/platform/common/adc_test.c b/test/unittest/platform/common/adc_test.c index 76e747c0..e3bb663d 100644 --- a/test/unittest/platform/common/adc_test.c +++ b/test/unittest/platform/common/adc_test.c @@ -156,7 +156,7 @@ int32_t AdcTestMultiThread(void) int32_t ret; struct OsalThread thread1, thread2; struct OsalThreadParam cfg1, cfg2; - int32_t count1 = 0; + int32_t count1 = 0; int32_t count2 = 0; HDF_LOGI("%s: enter", __func__); @@ -224,16 +224,15 @@ int32_t AdcTestReliability(void) static int32_t AdcIfPerformanceTest(void) { #ifdef __LITEOS__ - // liteos the accuracy of the obtained time is too large and inaccurate. + // liteos the accuracy of the obtained time is too large and inaccurate. return HDF_SUCCESS; #endif struct AdcTester *tester = NULL; uint64_t startMs; uint64_t endMs; - uint64_t useTime; /*ms*/ + uint64_t useTime; // ms uint32_t val; int32_t ret; - tester = AdcTesterGet(); if (tester == NULL || tester->handle == NULL) { @@ -246,8 +245,8 @@ static int32_t AdcIfPerformanceTest(void) if (ret == HDF_SUCCESS) { endMs = OsalGetSysTimeMs(); useTime = endMs - startMs; - HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", - startMs, endMs, useTime, useTime < 1 ? true : false ); + HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", + startMs, endMs, useTime, useTime < 1 ? true : false); } return HDF_FAILURE; } @@ -273,7 +272,8 @@ int32_t AdcTestExecute(int cmd) if (cmd > ADC_TEST_CMD_MAX) { HDF_LOGE("%s: invalid cmd:%d", __func__, cmd); ret = HDF_ERR_NOT_SUPPORT; - goto __EXIT__; + HDF_LOGE("[%s][======cmd:%d====ret:%d======]", __func__, cmd, ret); + return ret; } for (i = 0; i < sizeof(g_entry) / sizeof(g_entry[0]); i++) { @@ -284,7 +284,6 @@ int32_t AdcTestExecute(int cmd) break; } -__EXIT__: HDF_LOGE("[%s][======cmd:%d====ret:%d======]", __func__, cmd, ret); return ret; } diff --git a/test/unittest/platform/common/dac_driver_test.c b/test/unittest/platform/common/dac_driver_test.c index b83386df..3db6f78b 100644 --- a/test/unittest/platform/common/dac_driver_test.c +++ b/test/unittest/platform/common/dac_driver_test.c @@ -10,7 +10,7 @@ #include "device_resource_if.h" #include "hdf_base.h" #include "hdf_device_desc.h" -#include "hdf_log.h" +#include "hdf_log.h" #define HDF_LOG_TAG dac_test_driver_c diff --git a/test/unittest/platform/common/dac_test.c b/test/unittest/platform/common/dac_test.c index 81dee7b3..8f8ea1a1 100644 --- a/test/unittest/platform/common/dac_test.c +++ b/test/unittest/platform/common/dac_test.c @@ -232,12 +232,12 @@ static int32_t DacIfPerformanceTest(void) uint64_t startMs; uint64_t endMs; - uint64_t useTime; /*ms*/ + uint64_t useTime; // ms struct DacTester *tester = NULL; int32_t ret; uint32_t val; - val = 0; + val = 0; tester = DacTesterGet(); if (tester == NULL || tester->handle == NULL) { HDF_LOGE("%s: get tester failed", __func__); @@ -250,12 +250,12 @@ static int32_t DacIfPerformanceTest(void) HDF_LOGE("%s: write value failed:%u, ret:%d", __func__, val, ret); DacTesterPut(tester); return HDF_ERR_IO; - } + } endMs = OsalGetSysTimeMs(); useTime = endMs - startMs; HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", - startMs, endMs, useTime, useTime < 1 ? true : false ); + startMs, endMs, useTime, useTime < 1 ? true : false); DacTesterPut(tester); return HDF_SUCCESS; } @@ -280,7 +280,8 @@ int32_t DacTestExecute(int cmd) if (cmd > DAC_TEST_CMD_MAX) { HDF_LOGE("%s: invalid cmd:%d", __func__, cmd); ret = HDF_ERR_NOT_SUPPORT; - goto __EXIT__; + HDF_LOGE("[%s][======cmd:%d====ret:%d======]", __func__, cmd, ret); + return ret; } for (i = 0; i < sizeof(g_entry) / sizeof(g_entry[0]); i++) { @@ -291,7 +292,6 @@ int32_t DacTestExecute(int cmd) break; } -__EXIT__: HDF_LOGE("[%s][======cmd:%d====ret:%d======]", __func__, cmd, ret); return ret; } diff --git a/test/unittest/platform/common/gpio_test.c b/test/unittest/platform/common/gpio_test.c index ee3a0811..500a4e4c 100644 --- a/test/unittest/platform/common/gpio_test.c +++ b/test/unittest/platform/common/gpio_test.c @@ -164,7 +164,6 @@ static int32_t GpioTestSetGetDir(void) dirSet = GPIO_DIR_OUT; dirGet = GPIO_DIR_IN; -SET_GET_DIR: ret = GpioSetDir(tester->cfg.gpio, dirSet); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: set dir fail! ret:%d", __func__, ret); @@ -180,10 +179,21 @@ SET_GET_DIR: return HDF_FAILURE; } /* change the value and test one more time */ - if (dirSet == GPIO_DIR_OUT) { - dirSet = GPIO_DIR_IN; - dirGet = GPIO_DIR_OUT; - goto SET_GET_DIR; + dirSet = GPIO_DIR_IN; + dirGet = GPIO_DIR_OUT; + ret = GpioSetDir(tester->cfg.gpio, dirSet); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: set dir fail! ret:%d", __func__, ret); + return ret; + } + ret = GpioGetDir(tester->cfg.gpio, &dirGet); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: get dir fail! ret:%d", __func__, ret); + return ret; + } + if (dirSet != dirGet) { + HDF_LOGE("%s: set dir:%u, but get:%u", __func__, dirSet, dirGet); + return HDF_FAILURE; } return HDF_SUCCESS; } @@ -209,7 +219,6 @@ static int32_t GpioTestWriteRead(void) valWrite = GPIO_VAL_LOW; valRead = GPIO_VAL_HIGH; -WRITE_READ_VAL: ret = GpioWrite(tester->cfg.gpio, valWrite); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: write val:%u fail! ret:%d", __func__, valWrite, ret); @@ -225,10 +234,21 @@ WRITE_READ_VAL: return HDF_FAILURE; } /* change the value and test one more time */ - if (valWrite == GPIO_VAL_HIGH) { - valWrite = GPIO_VAL_HIGH; - valRead = GPIO_VAL_LOW; - goto WRITE_READ_VAL; + valWrite = GPIO_VAL_HIGH; + valRead = GPIO_VAL_LOW; + ret = GpioWrite(tester->cfg.gpio, valWrite); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: write val:%u fail! ret:%d", __func__, valWrite, ret); + return ret; + } + ret = GpioRead(tester->cfg.gpio, &valRead); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: read fail! ret:%d", __func__, ret); + return ret; + } + if (valWrite != valRead) { + HDF_LOGE("%s: write:%u, but get:%u", __func__, valWrite, valRead); + return HDF_FAILURE; } return HDF_SUCCESS; } @@ -401,7 +421,7 @@ static int32_t GpioIfPerformanceTest(void) uint16_t val; uint64_t startMs; uint64_t endMs; - uint64_t useTime; /*ms*/ + uint64_t useTime; // ms struct GpioTester *tester = NULL; tester = GpioTesterGet(); @@ -415,8 +435,8 @@ static int32_t GpioIfPerformanceTest(void) endMs = OsalGetSysTimeMs(); useTime = endMs - startMs; - HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", - startMs, endMs, useTime, useTime < 1 ? true : false ); + HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", + startMs, endMs, useTime, useTime < 1 ? true : false); return HDF_SUCCESS; } @@ -438,7 +458,7 @@ static struct GpioTestEntry g_entry[] = { int32_t GpioTestExecute(int cmd) { - uint32_t i; + uint32_t i; int32_t ret = HDF_ERR_NOT_SUPPORT; #if defined(_LINUX_USER_) || defined(__USER__) diff --git a/test/unittest/platform/common/i2c_test.c b/test/unittest/platform/common/i2c_test.c index 3fee767e..c5005c16 100644 --- a/test/unittest/platform/common/i2c_test.c +++ b/test/unittest/platform/common/i2c_test.c @@ -322,12 +322,12 @@ int32_t I2cTestReliability(void) int32_t I2cTestPeformance(void) { #ifdef __LITEOS__ - // liteos the accuracy of the obtained time is too large and inaccurate. + // liteos the accuracy of the obtained time is too large and inaccurate. return HDF_SUCCESS; #endif uint64_t startMs; uint64_t endMs; - uint64_t useTime; /*ms*/ + uint64_t useTime; // ms struct I2cTester *tester = NULL; DevHandle handle = NULL; @@ -343,8 +343,8 @@ int32_t I2cTestPeformance(void) if (handle != NULL) { useTime = endMs - startMs; - HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", - startMs, endMs, useTime, useTime < 1 ? true : false ); + HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", + startMs, endMs, useTime, useTime < 1 ? true : false); I2cClose(handle); return HDF_SUCCESS; } @@ -378,7 +378,8 @@ int32_t I2cTestExecute(int cmd) if (cmd > I2C_TEST_CMD_MAX) { HDF_LOGE("I2cTestExecute: invalid cmd:%d", cmd); ret = HDF_ERR_NOT_SUPPORT; - goto __EXIT__; + HDF_LOGE("[I2cTestExecute][======cmd:%d====ret:%d======]", cmd, ret); + return ret; } for (i = 0; i < sizeof(g_entry) / sizeof(g_entry[0]); i++) { @@ -389,7 +390,6 @@ int32_t I2cTestExecute(int cmd) break; } -__EXIT__: HDF_LOGE("[I2cTestExecute][======cmd:%d====ret:%d======]", cmd, ret); return ret; } diff --git a/test/unittest/platform/common/i3c_test.c b/test/unittest/platform/common/i3c_test.c index f2666370..0761697a 100644 --- a/test/unittest/platform/common/i3c_test.c +++ b/test/unittest/platform/common/i3c_test.c @@ -498,7 +498,8 @@ int32_t I3cTestExecute(int cmd) if (cmd > I3C_TEST_CMD_MAX) { HDF_LOGE("%s: invalid cmd:%d", __func__, cmd); ret = HDF_ERR_NOT_SUPPORT; - goto __EXIT__; + HDF_LOGI("[%s][======cmd:%d====ret:%d======]", __func__, cmd, ret); + return ret; } for (i = 0; i < sizeof(g_entry) / sizeof(g_entry[0]); i++) { @@ -510,7 +511,6 @@ int32_t I3cTestExecute(int cmd) break; } -__EXIT__: HDF_LOGI("[%s][======cmd:%d====ret:%d======]", __func__, cmd, ret); return ret; } diff --git a/test/unittest/platform/common/mipi_csi_test.c b/test/unittest/platform/common/mipi_csi_test.c index cb028a06..13116842 100755 --- a/test/unittest/platform/common/mipi_csi_test.c +++ b/test/unittest/platform/common/mipi_csi_test.c @@ -122,7 +122,7 @@ static void InitLvdsDevAttr(LvdsDevAttr *lvdsAttr) /** * @brief Initialize MIPI device attributes. - * + * * Data type (DT: data type) * The data type describes the format and content of load data. Up to 64 data types are supported. * There are only two data types for short packets, and the others belong to long packets. @@ -216,7 +216,7 @@ static void InitComboDevAttr(struct MipiCsiTest *test) } else if (interType == INTERFACE_LVDS) { HDF_LOGI("%s: call[InitLvdsDevAttr].", __func__); InitLvdsDevAttr(&attr.lvdsAttr); - } else { + } else { HDF_LOGE("%s: interType = %d is error!", __func__, attr.inputMode); } diff --git a/test/unittest/platform/common/pin_test.c b/test/unittest/platform/common/pin_test.c index 197f7984..ddd5a398 100644 --- a/test/unittest/platform/common/pin_test.c +++ b/test/unittest/platform/common/pin_test.c @@ -336,7 +336,8 @@ int32_t PinTestExecute(int cmd) if (cmd > PIN_TEST_CMD_MAX) { HDF_LOGE("%s: invalid cmd:%d", __func__, cmd); ret = HDF_ERR_NOT_SUPPORT; - goto __EXIT__; + HDF_LOGE("[%s][======cmd:%d====ret:%d======]", __func__, cmd, ret); + return ret; } for (i = 0; i < sizeof(g_entry) / sizeof(g_entry[0]); i++) { @@ -347,9 +348,8 @@ int32_t PinTestExecute(int cmd) break; } -__EXIT__: HDF_LOGE("[%s][======cmd:%d====ret:%d======]", __func__, cmd, ret); - return ret; + return ret; } void PinTestExecuteAll(void) @@ -377,4 +377,4 @@ void PinTestExecuteAll(void) HDF_LOGI("%s: **********PASS:%d FAIL:%d************\n\n", __func__, PIN_TEST_CMD_RELIABILITY + 1 - fails, fails); -} \ No newline at end of file +} diff --git a/test/unittest/platform/common/platform_assert.h b/test/unittest/platform/common/platform_assert.h index fd414e63..aead5b99 100644 --- a/test/unittest/platform/common/platform_assert.h +++ b/test/unittest/platform/common/platform_assert.h @@ -14,10 +14,10 @@ #define ERROR_AND_LOG(expr) \ do { \ PLAT_LOGE(__FILE__ "(line:%d): " #expr " is false!", __LINE__); \ -} while (0) +} while (0) #define CHECK(expr) \ -({ \ +( { \ if (!(expr)) { \ ERROR_AND_LOG(expr); \ } \ @@ -37,10 +37,10 @@ do { \ do { \ PLAT_LOGE(__FILE__ "(line:%d): " #expr " is false!", __LINE__); \ return ret; \ -} while (0) +} while (0) #define CHECK_AND_RETURN(expr, ret) \ -({ \ +( { \ if (!(expr)) { \ ERROR_AND_RETURN(expr, (ret)); \ } \ diff --git a/test/unittest/platform/common/platform_device_test.c b/test/unittest/platform/common/platform_device_test.c index 3ab51edc..b71c0cf4 100644 --- a/test/unittest/platform/common/platform_device_test.c +++ b/test/unittest/platform/common/platform_device_test.c @@ -30,7 +30,7 @@ static int32_t PlatformDeviceTestSetName(struct PlatformDevice *device) PLAT_LOGD("%s: enter", __func__); // should set name success - ret = PlatformDeviceSetName(device, "platform_device_name_%d", 1); + ret = PlatformDeviceSetName(device, "platform_device_name_%d", 1); CHECK_EQ_RETURN(ret, HDF_SUCCESS, ret); ret = strcmp(device->name, "platform_device_name_1"); CHECK_EQ_RETURN(ret, 0, HDF_FAILURE); @@ -40,7 +40,7 @@ static int32_t PlatformDeviceTestSetName(struct PlatformDevice *device) CHECK_EQ_RETURN(device->name, NULL, HDF_FAILURE); // should set name success - ret = PlatformDeviceSetName(device, "platform_device_name"); + ret = PlatformDeviceSetName(device, "platform_device_name"); CHECK_EQ_RETURN(ret, HDF_SUCCESS, ret); ret = strcmp(device->name, "platform_device_name"); CHECK_EQ_RETURN(ret, 0, HDF_FAILURE); @@ -67,24 +67,24 @@ static int32_t PlatformDeviceTestGetDevice(struct PlatformDevice *device) CHECK_EQ_RETURN(ret, HDF_SUCCESS, ret); refCntAfterGet = PlatformDeviceRefCount(device); - // ref count should increase by 1 after get + // ref count should increase by 1 after get CHECK_EQ_RETURN(refCntAfterGet, refCntBeforeGet + 1, ret); ret = PlatformDeviceGet(device); // should get device success again CHECK_EQ_RETURN(ret, HDF_SUCCESS, ret); refCntAfterGet = PlatformDeviceRefCount(device); - // ref count should increase by 2 after double get + // ref count should increase by 2 after double get CHECK_EQ_RETURN(refCntAfterGet, refCntBeforeGet + 2, ret); PlatformDevicePut(device); refCntAfterPut = PlatformDeviceRefCount(device); - // ref count should decrease by 1 after put + // ref count should decrease by 1 after put CHECK_EQ_RETURN(refCntAfterPut, refCntBeforeGet + 1, ret); PlatformDevicePut(device); refCntAfterPut = PlatformDeviceRefCount(device); - // ref count should decrease by 2 after put + // ref count should decrease by 2 after put CHECK_EQ_RETURN(refCntAfterPut, refCntBeforeGet, ret); PLAT_LOGD("%s: exit", __func__); @@ -103,17 +103,17 @@ static int32_t PlatformDeviceTestWaitEvent(struct PlatformDevice *device) device->name = "platform_device_test_event"; // should not wait success before post ret = PlatformDeviceWaitEvent(device, mask, PLAT_DEV_WAIT_TIMEOUT, &events); - CHECK_NE_RETURN(ret, HDF_SUCCESS, HDF_FAILURE); + CHECK_NE_RETURN(ret, HDF_SUCCESS, HDF_FAILURE); // should post event success ret = PlatformDevicePostEvent(device, eventA | eventB); - CHECK_EQ_RETURN(ret, HDF_SUCCESS, ret); + CHECK_EQ_RETURN(ret, HDF_SUCCESS, ret); // should wait success after post ret = PlatformDeviceWaitEvent(device, mask, PLAT_DEV_WAIT_TIMEOUT, &events); PLAT_LOGD("%s: events:%x", __func__, events); - CHECK_EQ_RETURN(ret, HDF_SUCCESS, ret); - CHECK_EQ_RETURN(events, eventA | eventB, ret); + CHECK_EQ_RETURN(ret, HDF_SUCCESS, ret); + CHECK_EQ_RETURN(events, eventA | eventB, ret); PLAT_LOGD("%s: exit", __func__); return HDF_SUCCESS; @@ -143,7 +143,7 @@ static int32_t PlatformDeviceTestAddDevice(struct PlatformDevice *device) PlatformDevicePut(deviceGet); PlatformDeviceDel(device); - // should not get the device after del + // should not get the device after del deviceGet = PlatformManagerGetDeviceByNumber(manager, device->number); CHECK_EQ_RETURN(deviceGet, NULL, ret); @@ -222,11 +222,11 @@ static int32_t PlatformDeviceTestReliability(struct PlatformDevice *device) ret = PlatformDeviceSetName(NULL, "device_name"); CHECK_NE_RETURN(ret, HDF_SUCCESS, HDF_FAILURE); - ret = PlatformDeviceSetName(device, NULL); + ret = PlatformDeviceSetName(device, NULL); CHECK_NE_RETURN(ret, HDF_SUCCESS, HDF_FAILURE); PlatformDeviceClearName(device); - ret = PlatformDeviceGet(NULL); + ret = PlatformDeviceGet(NULL); CHECK_NE_RETURN(ret, HDF_SUCCESS, HDF_FAILURE); PlatformDevicePut(NULL); @@ -239,22 +239,22 @@ static int32_t PlatformDeviceTestReliability(struct PlatformDevice *device) ret = PlatformDeviceWaitEvent(NULL, 0x1, 1, &events); CHECK_NE_RETURN(ret, HDF_SUCCESS, HDF_FAILURE); - ret = PlatformDeviceAdd(NULL); + ret = PlatformDeviceAdd(NULL); CHECK_NE_RETURN(ret, HDF_SUCCESS, HDF_FAILURE); PlatformDeviceDel(NULL); - ret = PlatformDeviceCreateService(NULL, TestDispatch); + ret = PlatformDeviceCreateService(NULL, TestDispatch); CHECK_NE_RETURN(ret, HDF_SUCCESS, HDF_FAILURE); PlatformDeviceDestroyService(NULL); - ret = PlatformDeviceBind(device, NULL); + ret = PlatformDeviceBind(device, NULL); CHECK_NE_RETURN(ret, HDF_SUCCESS, HDF_FAILURE); - ret = PlatformDeviceBind(NULL, &hdfDev); + ret = PlatformDeviceBind(NULL, &hdfDev); CHECK_NE_RETURN(ret, HDF_SUCCESS, HDF_FAILURE); PlatformDeviceUnbind(device, NULL); PlatformDeviceUnbind(NULL, NULL); - devGet = PlatformDeviceFromHdfDev(NULL); + devGet = PlatformDeviceFromHdfDev(NULL); CHECK_NULL_RETURN(devGet, HDF_FAILURE); PLAT_LOGD("%s: exit", __func__); @@ -287,7 +287,8 @@ int PlatformDeviceTestExecute(int cmd) if (cmd > PLAT_DEVICE_TEST_CMD_MAX) { PLAT_LOGE("PlatformDeviceTestExecute: invalid cmd:%d", cmd); ret = HDF_ERR_NOT_SUPPORT; - goto __EXIT__; + PLAT_LOGE("[PlatformDeviceTestExecute][======cmd:%d====ret:%d======]", cmd, ret); + return ret; } for (i = 0; i < (sizeof(g_entry) / sizeof(g_entry[0])); i++) { @@ -311,7 +312,6 @@ int PlatformDeviceTestExecute(int cmd) ret = entry->func(&device); PlatformDeviceUninit(&device); -__EXIT__: PLAT_LOGE("[PlatformDeviceTestExecute][======cmd:%d====ret:%d======]", cmd, ret); return ret; } diff --git a/test/unittest/platform/common/platform_event_test.c b/test/unittest/platform/common/platform_event_test.c index b33fbb94..4162b356 100644 --- a/test/unittest/platform/common/platform_event_test.c +++ b/test/unittest/platform/common/platform_event_test.c @@ -40,7 +40,7 @@ static int32_t PlatformEventTestInitAndUninit(struct PlatformEvent *pe) } (void)OsalSpinUnlock(&pe->spin); - // can use sem after init + // can use sem after init ret = OsalSemPost(&pe->sem); if (!CHECK_EQ(ret, HDF_SUCCESS)) { return HDF_FAILURE; @@ -154,7 +154,7 @@ static int32_t PlatformEventTestReliability(struct PlatformEvent *pe) struct PlatformEventListener listener; PLAT_LOGD("%s: enter", __func__); - // should return invalid obj when init null pointer + // should return invalid obj when init null pointer ret = PlatformEventInit(NULL); CHECK_EQ_RETURN(ret, HDF_ERR_INVALID_OBJECT, HDF_FAILURE); @@ -170,7 +170,7 @@ static int32_t PlatformEventTestReliability(struct PlatformEvent *pe) ret = PlatformEventWait(pe, 0, 0, PLAT_EVENT_TEST_TIMEOUT, &events); CHECK_NE_RETURN(ret, HDF_SUCCESS, HDF_FAILURE); - // should not listen success when event instance is NULL + // should not listen success when event instance is NULL ret = PlatformEventListen(NULL, &listener); CHECK_NE_RETURN(ret, HDF_SUCCESS, HDF_FAILURE); @@ -205,7 +205,8 @@ int PlatformEventTestExecute(int cmd) if (cmd > PLAT_EVENT_TEST_CMD_MAX) { PLAT_LOGE("PlatformEventTestExecute: invalid cmd:%d", cmd); ret = HDF_ERR_NOT_SUPPORT; - goto __EXIT__; + PLAT_LOGE("[PlatformEventTestExecute][======cmd:%d====ret:%d======]", cmd, ret); + return ret; } for (i = 0; i < sizeof(g_entry) / sizeof(g_entry[0]); i++) { @@ -229,7 +230,6 @@ int PlatformEventTestExecute(int cmd) ret = entry->func(&pe); PlatformEventUninit(&pe); -__EXIT__: PLAT_LOGE("[PlatformEventTestExecute][======cmd:%d====ret:%d======]", cmd, ret); return ret; } diff --git a/test/unittest/platform/common/platform_manager_test.c b/test/unittest/platform/common/platform_manager_test.c index f7983888..229cbe5e 100644 --- a/test/unittest/platform/common/platform_manager_test.c +++ b/test/unittest/platform/common/platform_manager_test.c @@ -62,7 +62,7 @@ static void PlatformManagerTestDestroyDevices(void) PlatformDeviceUninit(g_platDevices[i]); OsalMemFree(g_platDevices[i]); g_platDevices[i] = NULL; - } + } } static int32_t PlatformManagerTestAddAndDel(struct PlatformManager *manager) @@ -111,16 +111,16 @@ static int32_t PlatformManagerTestAddAndDel(struct PlatformManager *manager) ret = PlatformManagerAddDevice(manager, device2); CHECK_NE_RETURN(ret, HDF_SUCCESS, ret); - // should add fail on repeated name + // should add fail on repeated name device2->number = number; // give it a right number - device2->name = device0->name; + device2->name = device0->name; ret = PlatformManagerAddDevice(manager, device2); CHECK_NE_RETURN(ret, HDF_SUCCESS, ret); refCntBeforeDel = PlatformDeviceRefCount(device0); (void)PlatformManagerDelDevice(manager, device0); refCntAfterDel = PlatformDeviceRefCount(device0); - // ref count should decrease by 1 after del + // ref count should decrease by 1 after del CHECK_EQ_RETURN(refCntAfterDel + 1, refCntBeforeDel, HDF_FAILURE); // should not get the device removed @@ -157,7 +157,7 @@ static int32_t PlatformManagerTestGetDevice(struct PlatformManager *manager) CHECK_EQ_RETURN(ret, HDF_SUCCESS, ret); refCntBeforeGet = PlatformDeviceRefCount(device0); - // should get the device by number + // should get the device by number device0Get = PlatformManagerGetDeviceByNumber(manager, device0->number); CHECK_EQ_RETURN(device0Get, device0, HDF_FAILURE); @@ -168,11 +168,11 @@ static int32_t PlatformManagerTestGetDevice(struct PlatformManager *manager) refCntBeforePut = PlatformDeviceRefCount(device0); PlatformDevicePut(device0Get); refCntAfterPut = PlatformDeviceRefCount(device0); - // should dcrease refcount after put + // should dcrease refcount after put CHECK_EQ_RETURN(refCntBeforePut, refCntAfterPut + 1, HDF_FAILURE); refCntBeforeGet = PlatformDeviceRefCount(device1); - // should get the device by name + // should get the device by name device1Get = PlatformManagerGetDeviceByName(manager, "platform_device1"); CHECK_EQ_RETURN(device1Get, device1, HDF_FAILURE); @@ -183,11 +183,11 @@ static int32_t PlatformManagerTestGetDevice(struct PlatformManager *manager) refCntBeforePut = PlatformDeviceRefCount(device1); PlatformDevicePut(device1Get); refCntAfterPut = PlatformDeviceRefCount(device1); - // should dcrease refcount after put + // should dcrease refcount after put CHECK_EQ_RETURN(refCntBeforePut, refCntAfterPut + 1, HDF_FAILURE); PLAT_LOGD("%s: exit", __func__); - return HDF_SUCCESS; + return HDF_SUCCESS; } static int32_t PlatformManagerTestReliability(struct PlatformManager *manager) @@ -241,7 +241,8 @@ int PlatformManagerTestExecute(int cmd) if (cmd > PLAT_MANAGER_TEST_CMD_MAX) { PLAT_LOGE("PlatformManagerTestExecute: invalid cmd:%d", cmd); ret = HDF_ERR_NOT_SUPPORT; - goto __EXIT__; + PLAT_LOGE("[PlatformManagerTestExecute][======cmd:%d====ret:%d======]", cmd, ret); + return ret; } for (i = 0; i < sizeof(g_entry) / sizeof(g_entry[0]); i++) { @@ -274,7 +275,6 @@ int PlatformManagerTestExecute(int cmd) PlatformManagerDestroy(manager); PlatformManagerTestDestroyDevices(); -__EXIT__: PLAT_LOGE("[PlatformManagerTestExecute][======cmd:%d====ret:%d======]", cmd, ret); return ret; } diff --git a/test/unittest/platform/common/platform_queue_test.c b/test/unittest/platform/common/platform_queue_test.c index aa2bd63f..911265f7 100644 --- a/test/unittest/platform/common/platform_queue_test.c +++ b/test/unittest/platform/common/platform_queue_test.c @@ -33,7 +33,7 @@ static int32_t PlatformQueueTestHandle(struct PlatformQueue *queue, struct Platf tmsg->status = HDF_ERR_INVALID_OBJECT; PLAT_LOGE("%s: queue object is NULL", __func__); return HDF_ERR_INVALID_OBJECT; - } + } if (msg->data != queue) { tmsg->status = HDF_ERR_INVALID_OBJECT; @@ -123,7 +123,8 @@ int PlatformQueueTestExecute(int cmd) if (cmd > PLAT_QUEUE_TEST_CMD_MAX) { PLAT_LOGE("PlatformQueueTestExecute: invalid cmd:%d", cmd); ret = HDF_ERR_NOT_SUPPORT; - goto __EXIT__; + PLAT_LOGE("[PlatformQueueTestExecute][======cmd:%d====ret:%d======]", cmd, ret); + return ret; } for (i = 0; i < sizeof(g_entry) / sizeof(g_entry[0]); i++) { @@ -155,7 +156,6 @@ int PlatformQueueTestExecute(int cmd) ret = entry->func(pq); PlatformQueueDestroy(pq); -__EXIT__: PLAT_LOGE("[PlatformQueueTestExecute][======cmd:%d====ret:%d======]", cmd, ret); return ret; } diff --git a/test/unittest/platform/common/pwm_test.c b/test/unittest/platform/common/pwm_test.c index ef18ecd9..b749ecd8 100644 --- a/test/unittest/platform/common/pwm_test.c +++ b/test/unittest/platform/common/pwm_test.c @@ -330,7 +330,7 @@ static int32_t PwmReliabilityTest(struct PwmTester *tester) static int32_t PwmIfPerformanceTest(struct PwmTester *tester) { #ifdef __LITEOS__ - // liteos the accuracy of the obtained time is too large and inaccurate. + // liteos the accuracy of the obtained time is too large and inaccurate. if (tester == NULL) { return HDF_FAILURE; } @@ -340,15 +340,15 @@ static int32_t PwmIfPerformanceTest(struct PwmTester *tester) struct PwmConfig cfg = {0}; uint64_t startMs; uint64_t endMs; - uint64_t useTime; /*ms*/ + uint64_t useTime; // ms startMs = OsalGetSysTimeMs(); PwmGetConfig(tester->handle, &cfg); endMs = OsalGetSysTimeMs(); useTime = endMs - startMs; - HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", - startMs, endMs, useTime, useTime < 1 ? true : false ); + HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", + startMs, endMs, useTime, useTime < 1 ? true : false); return HDF_SUCCESS; } @@ -390,7 +390,9 @@ int32_t PwmTestExecute(int cmd) ret = PwmGetConfig(tester->handle, &(tester->originCfg)); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: [PwmGetConfig] failed, ret %d.", __func__, ret); - goto __EXIT__; + HDF_LOGI("[%s][======cmd:%d====ret:%d======]", __func__, cmd, ret); + PwmTesterPut(tester); + return ret; } } @@ -407,7 +409,6 @@ int32_t PwmTestExecute(int cmd) PwmSetConfig(tester->handle, &(tester->originCfg)); } -__EXIT__: HDF_LOGI("[%s][======cmd:%d====ret:%d======]", __func__, cmd, ret); PwmTesterPut(tester); return ret; diff --git a/test/unittest/platform/common/regulator_test.c b/test/unittest/platform/common/regulator_test.c index 3bbebe10..7ea95125 100755 --- a/test/unittest/platform/common/regulator_test.c +++ b/test/unittest/platform/common/regulator_test.c @@ -360,7 +360,7 @@ static int32_t RegulatorTestInitFromHcs(struct RegulatorTest *test, const struct return HDF_FAILURE; } - HDF_LOGI("regulator test init:[%s][%d]--[%d][%d]--[%d][%d]!", + HDF_LOGI("regulator test init:[%s][%d]--[%d][%d]--[%d][%d]!", test->name, test->mode, test->minUv, test->maxUv, test->minUa, test->maxUa); return HDF_SUCCESS; diff --git a/test/unittest/platform/common/rtc_test.c b/test/unittest/platform/common/rtc_test.c index cd21390a..39f2b173 100644 --- a/test/unittest/platform/common/rtc_test.c +++ b/test/unittest/platform/common/rtc_test.c @@ -128,7 +128,8 @@ static int32_t IsSameRtcTestTime(const struct RtcTime *readTime, const struct Rt return HDF_SUCCESS; } -static int32_t TestReadWriteTime(struct RtcTester *tester) { +static int32_t TestReadWriteTime(struct RtcTester *tester) +{ int32_t ret; struct RtcTime readTime = {0}; @@ -221,7 +222,8 @@ static int32_t RtcReadWriteMinTimeTest(struct RtcTester *tester) return HDF_SUCCESS; } -static int32_t TestReadWriteAlarm(struct RtcTester *tester) { +static int32_t TestReadWriteAlarm(struct RtcTester *tester) +{ int32_t ret; struct RtcTime readTime = {0}; @@ -235,7 +237,7 @@ static int32_t TestReadWriteAlarm(struct RtcTester *tester) { ret = RtcReadAlarm(tester->handle, RTC_ALARM_INDEX_A, &readTime); if (ret != HDF_SUCCESS) { - HDF_LOGE("%s: read alarm fail, ret :%d",__func__, ret); + HDF_LOGE("%s: read alarm fail, ret :%d", __func__, ret); return HDF_FAILURE; } @@ -666,5 +668,5 @@ int32_t RtcTestExecute(int cmd) EXIT: HDF_LOGE("[%s][======cmd:%d====ret:%d======]", __func__, cmd, ret); RtcTesterPut(tester); - return ret; + return ret; } \ No newline at end of file diff --git a/test/unittest/platform/common/spi_driver_test.c b/test/unittest/platform/common/spi_driver_test.c index 103161bc..18705d06 100644 --- a/test/unittest/platform/common/spi_driver_test.c +++ b/test/unittest/platform/common/spi_driver_test.c @@ -93,7 +93,7 @@ static int32_t SpiTestBind(struct HdfDeviceObject *device) struct IDeviceIoService *service = NULL; service = (struct IDeviceIoService *)OsalMemCalloc(sizeof(*service)); - if(service == NULL) { + if (service == NULL) { HDF_LOGE("%s: malloc service failed!", __func__); return HDF_ERR_MALLOC_FAIL; } diff --git a/test/unittest/platform/common/spi_test.c b/test/unittest/platform/common/spi_test.c index 95cd63a9..1f4836ec 100644 --- a/test/unittest/platform/common/spi_test.c +++ b/test/unittest/platform/common/spi_test.c @@ -138,11 +138,11 @@ static void SpiTesterPut(struct SpiTester *tester) return; } SpiClose(tester->handle); - if(tester->config.rbuf != NULL) { + if (tester->config.rbuf != NULL) { OsalMemFree(tester->config.rbuf); tester->config.rbuf = NULL; } - if(tester->config.wbuf != NULL) { + if (tester->config.wbuf != NULL) { OsalMemFree(tester->config.wbuf); tester->config.wbuf = NULL; } @@ -475,7 +475,7 @@ static int32_t SpiTestAll(struct SpiTester *tester) static int32_t SpiIfPerformanceTest(struct SpiTester *tester) { #ifdef __LITEOS__ - // liteos the accuracy of the obtained time is too large and inaccurate. + // liteos the accuracy of the obtained time is too large and inaccurate. if (tester == NULL || tester->handle == NULL) { return HDF_FAILURE; } @@ -485,7 +485,7 @@ static int32_t SpiIfPerformanceTest(struct SpiTester *tester) struct SpiCfg cfg = {0}; uint64_t startMs; uint64_t endMs; - uint64_t useTime; /*ms*/ + uint64_t useTime; // ms startMs = OsalGetSysTimeMs(); ret = SpiGetCfg(tester->handle, &cfg); @@ -493,8 +493,8 @@ static int32_t SpiIfPerformanceTest(struct SpiTester *tester) if (ret == HDF_SUCCESS) { useTime = endMs - startMs; - HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", - startMs, endMs, useTime, useTime < 1 ? true : false ); + HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", + startMs, endMs, useTime, useTime < 1 ? true : false); return HDF_SUCCESS; } return HDF_FAILURE; @@ -513,7 +513,7 @@ static struct SpiTestFunc g_spiTestEntry[] = { {SPI_INT_TRANSFER_TEST, SpiIntTransferTest, "SpiIntTransferTest"}, {SPI_RELIABILITY_TEST, SpiReliabilityTest, "SpiReliabilityTest"}, {SPI_PERFORMANCE_TEST, SpiIfPerformanceTest, "SpiIfPerformanceTest"}, - {SPI_TEST_ALL,SpiTestAll,"SpiTestAll"}, + {SPI_TEST_ALL, SpiTestAll, "SpiTestAll"}, }; int32_t SpiTestExecute(int cmd) diff --git a/test/unittest/platform/common/timer_test.c b/test/unittest/platform/common/timer_test.c index 4169d256..0f7f6cd9 100755 --- a/test/unittest/platform/common/timer_test.c +++ b/test/unittest/platform/common/timer_test.c @@ -116,7 +116,7 @@ static int TimerOnceTestThreadFunc(void *param) return HDF_FAILURE; } - if(HwTimerSetOnce(handle, TIMER_TEST_TIME_USECONDS, TimerTestcaseOnceCb) != HDF_SUCCESS) { + if (HwTimerSetOnce(handle, TIMER_TEST_TIME_USECONDS, TimerTestcaseOnceCb) != HDF_SUCCESS) { HDF_LOGE("%s: TimerSetOnce fail", __func__); g_theard1Flag = true; return HDF_FAILURE; @@ -138,7 +138,7 @@ static int TimerPeriodTestThreadFunc(void *param) return HDF_FAILURE; } - if(HwTimerSet(handle, TIMER_TEST_TIME_USECONDS, TimerTestcaseCb) != HDF_SUCCESS) { + if (HwTimerSet(handle, TIMER_TEST_TIME_USECONDS, TimerTestcaseCb) != HDF_SUCCESS) { HDF_LOGE("%s: TimerSet fail", __func__); g_theard2Flag = true; return HDF_FAILURE; @@ -222,7 +222,7 @@ int32_t TimerTestMultiThread(struct TimerTest *test) } } ret = HDF_SUCCESS; - } while(0); + } while (0); if (handle1 != NULL) { HwTimerClose(handle1); @@ -341,7 +341,7 @@ struct TimerTest *TimerTestGet(void) static int32_t TimerIfPerformanceTest(struct TimerTest *test) { #ifdef __LITEOS__ - // liteos the accuracy of the obtained time is too large and inaccurate. + // liteos the accuracy of the obtained time is too large and inaccurate. if (test == NULL) { return HDF_FAILURE; } @@ -350,7 +350,7 @@ static int32_t TimerIfPerformanceTest(struct TimerTest *test) uint64_t startMs; uint64_t endMs; - uint64_t useTime; /*ms*/ + uint64_t useTime; // ms uint32_t uSecond; bool isPeriod; @@ -359,8 +359,8 @@ static int32_t TimerIfPerformanceTest(struct TimerTest *test) endMs = OsalGetSysTimeMs(); useTime = endMs - startMs; - HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", - startMs, endMs, useTime, useTime < 1 ? true : false ); + HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", + startMs, endMs, useTime, useTime < 1 ? true : false); return HDF_SUCCESS; } @@ -392,7 +392,7 @@ int32_t TimerTestExecute(int cmd) } if (cmd != TIMER_MULTI_THREAD_TEST) { - test->handle = HwTimerOpen(test->number); + test->handle = HwTimerOpen(test->number); if (test->handle == NULL) { HDF_LOGE("%s: timer test get handle fail", __func__); return HDF_FAILURE; diff --git a/test/unittest/platform/common/uart_test.c b/test/unittest/platform/common/uart_test.c index 69061c37..2407e5b2 100644 --- a/test/unittest/platform/common/uart_test.c +++ b/test/unittest/platform/common/uart_test.c @@ -135,7 +135,7 @@ static int32_t UartWriteTest(struct UartTester *tester) } static int32_t UartReadTest(struct UartTester *tester) -{ +{ int32_t ret; ret = UartSetTransMode(tester->handle, UART_MODE_RD_NONBLOCK); @@ -269,15 +269,15 @@ static int32_t UartIfPerformanceTest(struct UartTester *tester) uint32_t baudRate; uint64_t startMs; uint64_t endMs; - uint64_t useTime; /* ms */ + uint64_t useTime; // ms startMs = OsalGetSysTimeMs(); UartGetBaud(tester->handle, &baudRate); endMs = OsalGetSysTimeMs(); useTime = endMs - startMs; - HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", - startMs, endMs, useTime, useTime < 1 ? true : false ); + HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", + startMs, endMs, useTime, useTime < 1 ? true : false); return HDF_SUCCESS; } @@ -314,7 +314,9 @@ int32_t UartTestExecute(int cmd) if (cmd > UART_TEST_CMD_MAX) { HDF_LOGE("%s: invalid cmd:%d", __func__, cmd); ret = HDF_ERR_NOT_SUPPORT; - goto __EXIT__; + HDF_LOGE("[%s][======cmd:%d====ret:%d======]", __func__, cmd, ret); + UartTesterPut(tester); + return ret; } for (i = 0; i < sizeof(g_entry) / sizeof(g_entry[0]); i++) { @@ -325,8 +327,7 @@ int32_t UartTestExecute(int cmd) break; } -__EXIT__: HDF_LOGE("[%s][======cmd:%d====ret:%d======]", __func__, cmd, ret); UartTesterPut(tester); - return ret; + return ret; } diff --git a/test/unittest/platform/common/watchdog_driver_test.c b/test/unittest/platform/common/watchdog_driver_test.c index 6e34d033..780584e0 100755 --- a/test/unittest/platform/common/watchdog_driver_test.c +++ b/test/unittest/platform/common/watchdog_driver_test.c @@ -16,7 +16,8 @@ static struct WatchdogTestConfig g_config; -static int32_t WatchdogTestDispatch(struct HdfDeviceIoClient *client, int cmd, struct HdfSBuf *data, struct HdfSBuf *reply) +static int32_t WatchdogTestDispatch(struct HdfDeviceIoClient *client, int cmd, + struct HdfSBuf *data, struct HdfSBuf *reply) { if (cmd == 0) { if (reply == NULL) { diff --git a/test/unittest/platform/common/watchdog_test.c b/test/unittest/platform/common/watchdog_test.c index 4bbe380c..b9289261 100644 --- a/test/unittest/platform/common/watchdog_test.c +++ b/test/unittest/platform/common/watchdog_test.c @@ -260,7 +260,7 @@ static int32_t TestCaseWatchdogReliability(struct WatchdogTester *tester) static int32_t TestCaseWatchdogIfPerformanceTest(struct WatchdogTester *tester) { #ifdef __LITEOS__ - // liteos the accuracy of the obtained time is too large and inaccurate. + // liteos the accuracy of the obtained time is too large and inaccurate. if (tester == NULL) { return HDF_FAILURE; } @@ -270,15 +270,15 @@ static int32_t TestCaseWatchdogIfPerformanceTest(struct WatchdogTester *tester) uint32_t timeoutGet = 0; uint64_t startMs; uint64_t endMs; - uint64_t useTime; /*ms*/ + uint64_t useTime; // ms startMs = OsalGetSysTimeMs(); WatchdogGetTimeout(tester->handle, &timeoutGet); endMs = OsalGetSysTimeMs(); useTime = endMs - startMs; - HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", - startMs, endMs, useTime, useTime < 1 ? true : false ); + HDF_LOGI("----->interface performance test:[start:%lld(ms) - end:%lld(ms) = %lld (ms)] < 1ms[%d]\r\n", + startMs, endMs, useTime, useTime < 1 ? true : false); return HDF_SUCCESS; } @@ -310,7 +310,9 @@ int32_t WatchdogTestExecute(int cmd) if (cmd > WATCHDOG_TEST_MAX) { HDF_LOGE("%s: invalid cmd:%d", __func__, cmd); ret = HDF_ERR_NOT_SUPPORT; - goto __EXIT__; + HDF_LOGI("[%s][======cmd:%d====ret:%d======]", __func__, cmd, ret); + WatchdogTesterPut(tester); + return ret; } for (i = 0; i < sizeof(g_entry) / sizeof(g_entry[0]); i++) { @@ -322,8 +324,7 @@ int32_t WatchdogTestExecute(int cmd) break; } -__EXIT__: HDF_LOGI("[%s][======cmd:%d====ret:%d======]", __func__, cmd, ret); WatchdogTesterPut(tester); - return ret; + return ret; } diff --git a/test/unittest/platform/entry/hdf_spi_entry_test.c b/test/unittest/platform/entry/hdf_spi_entry_test.c index 810d2a75..55a1f1f6 100644 --- a/test/unittest/platform/entry/hdf_spi_entry_test.c +++ b/test/unittest/platform/entry/hdf_spi_entry_test.c @@ -13,7 +13,6 @@ int32_t HdfSpiUnitTestEntry(HdfTestMsg *msg) { - if (msg == NULL) { return HDF_FAILURE; } diff --git a/test/unittest/platform/virtual/dac_virtual.c b/test/unittest/platform/virtual/dac_virtual.c index 8d258d37..a37a31e4 100644 --- a/test/unittest/platform/virtual/dac_virtual.c +++ b/test/unittest/platform/virtual/dac_virtual.c @@ -99,7 +99,9 @@ static int32_t VirtualDacParseAndInit(struct HdfDeviceObject *device, const stru ret = VirtualDacReadDrs(virtual, node); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Read drs fail! ret:%d", __func__, ret); - goto __ERR__; + OsalMemFree(virtual); + virtual = NULL; + return ret; } VirtualDacDeviceInit(virtual); @@ -109,17 +111,12 @@ static int32_t VirtualDacParseAndInit(struct HdfDeviceObject *device, const stru ret = DacDeviceAdd(&virtual->device); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: add Dac controller failed! ret = %d", __func__, ret); - goto __ERR__; + OsalMemFree(virtual); + virtual = NULL; + return ret; } return HDF_SUCCESS; -__ERR__: - if (virtual != NULL) { - OsalMemFree(virtual); - virtual = NULL; - } - - return ret; } static int32_t VirtualDacInit(struct HdfDeviceObject *device) diff --git a/test/unittest/platform/virtual/i3c_virtual.c b/test/unittest/platform/virtual/i3c_virtual.c index 51d2c5d7..5184349e 100644 --- a/test/unittest/platform/virtual/i3c_virtual.c +++ b/test/unittest/platform/virtual/i3c_virtual.c @@ -216,8 +216,8 @@ static int32_t VirtualI3cReservedAddrWorker(struct VirtualI3cCntlr *virtual, uin case I3C_RESERVED_ADDR_7H7A: case I3C_RESERVED_ADDR_7H7C: case I3C_RESERVED_ADDR_7H7F: - /* All cases of broadcast address single bit error detect */ - HDF_LOGW("%s: broadcast Address single bit error!", __func__); + /* All cases of broadcast address single bit error detect */ + HDF_LOGW("%s: broadcast Address single bit error!", __func__); break; default: HDF_LOGD("%s: Reserved address which is not supported!", __func__); @@ -241,7 +241,7 @@ static int32_t I3cIbiHandle(uint32_t irq, void *data) } virtual = (struct VirtualI3cCntlr *)data; ibiAddr = VirtualI3cGetIbiAddr(); - if (CHECK_RESERVED_ADDR(ibiAddr) == I3C_ADDR_RESERVED) { + if (I3cCheckReservedAddr(ibiAddr) == I3C_ADDR_RESERVED) { HDF_LOGD("%s: Calling VirtualI3cResAddrWorker...", __func__); return VirtualI3cReservedAddrWorker(virtual, ibiAddr); } else { @@ -349,7 +349,9 @@ static int32_t VirtualI3cParseAndInit(struct HdfDeviceObject *device, const stru ret = VirtualI3cReadDrs(virtual, node); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: Read drs fail! ret:%d", __func__, ret); - goto __ERR__; + OsalMemFree(virtual); + virtual = NULL; + return ret; } VirtualI3cCntlrInit(virtual); @@ -361,17 +363,12 @@ static int32_t VirtualI3cParseAndInit(struct HdfDeviceObject *device, const stru if (ret != HDF_SUCCESS) { HDF_LOGE("%s: add i3c controller failed! ret = %d", __func__, ret); (void)OsalSpinDestroy(&virtual->spin); - goto __ERR__; + OsalMemFree(virtual); + virtual = NULL; + return ret; } return HDF_SUCCESS; -__ERR__: - if (virtual != NULL) { - OsalMemFree(virtual); - virtual = NULL; - } - - return ret; } static int32_t VirtualI3cInit(struct HdfDeviceObject *device) diff --git a/test/unittest/platform/virtual/regulator_virtual.c b/test/unittest/platform/virtual/regulator_virtual.c index 847f0993..2ff0bca5 100755 --- a/test/unittest/platform/virtual/regulator_virtual.c +++ b/test/unittest/platform/virtual/regulator_virtual.c @@ -8,7 +8,7 @@ /* hcs topology for example dev ---+-> Regulator-1(voltage) -+-> Regulator-2(voltage) -+-> Regulator-3(voltage) -+-> Regulator-4(voltage) - | | + | | | | -+-> Regulator-5(voltage) -+-> Regulator-6(voltage) -+-> Regulator-7(voltage) -+-> Regulator-8(voltage) | | | | -+-> Regulator-9 @@ -61,7 +61,7 @@ static int32_t VirtualRegulatorSetVoltage(struct RegulatorNode *node, uint32_t m return HDF_ERR_INVALID_OBJECT; } - HDF_LOGD("VirtualRegulatorSetVoltage %s [%d, %d] success!\n", + HDF_LOGD("VirtualRegulatorSetVoltage %s [%d, %d] success!\n", node->regulatorInfo.name, minUv, maxUv); return HDF_SUCCESS; } @@ -85,7 +85,7 @@ static int32_t VirtualRegulatorSetCurrent(struct RegulatorNode *node, uint32_t m return HDF_ERR_INVALID_OBJECT; } - HDF_LOGD("VirtualRegulatorSetCurrent %s [%d, %d] success!\n", + HDF_LOGD("VirtualRegulatorSetCurrent %s [%d, %d] success!\n", node->regulatorInfo.name, minUa, maxUa); return HDF_SUCCESS; } @@ -237,7 +237,11 @@ static int32_t VirtualRegulatorParseAndInit(struct HdfDeviceObject *device, cons ret = VirtualRegulatorReadHcs(regNode, node); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: read drs fail! ret:%d", __func__, ret); - goto __ERR__; + if (regNode != NULL) { + OsalMemFree(regNode); + regNode = NULL; + } + return ret; } regNode->priv = (void *)node; @@ -246,17 +250,13 @@ static int32_t VirtualRegulatorParseAndInit(struct HdfDeviceObject *device, cons ret = RegulatorNodeAdd(regNode); if (ret != HDF_SUCCESS) { HDF_LOGE("%s: add regulator controller fail:%d!", __func__, ret); - goto __ERR__; + if (regNode != NULL) { + OsalMemFree(regNode); + regNode = NULL; + } + return ret; } return HDF_SUCCESS; - -__ERR__: - HDF_LOGE("%s:fail ret:%d", __func__, ret); - if (regNode != NULL) { - OsalMemFree(regNode); - regNode = NULL; - } - return ret; } static int32_t VirtualRegulatorInit(struct HdfDeviceObject *device)