From 6744252279bce2c74a0b63b9334a9d79ba965287 Mon Sep 17 00:00:00 2001 From: zhangyalei Date: Thu, 24 Mar 2022 07:42:47 -0700 Subject: [PATCH] fix:Code alert cleanup Signed-off-by: zhangyalei --- platform/mipi_csi/mipi_csi_dev.c | 4 ++-- platform/mipi_csi/mipi_v4l2_adapter.c | 1 + platform/mipi_dsi/mipi_tx_dev.c | 12 ++++++------ platform/mipi_dsi/mipi_tx_hi35xx.c | 11 +++++++++-- platform/pwm/pwm_hi35xx_linux.c | 2 +- platform/watchdog/watchdog_adapter.c | 2 +- 6 files changed, 20 insertions(+), 12 deletions(-) mode change 100755 => 100644 platform/mipi_csi/mipi_csi_dev.c mode change 100755 => 100644 platform/mipi_csi/mipi_v4l2_adapter.c diff --git a/platform/mipi_csi/mipi_csi_dev.c b/platform/mipi_csi/mipi_csi_dev.c old mode 100755 new mode 100644 index f3b0ca3..6b0c985 --- a/platform/mipi_csi/mipi_csi_dev.c +++ b/platform/mipi_csi/mipi_csi_dev.c @@ -296,7 +296,7 @@ static long MipiRxCompatIoctl(struct file *filep, unsigned int cmd, unsigned lon #endif #ifdef CONFIG_HI_PROC_SHOW_SUPPORT -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) static int32_t ProcRegister(const char *name, uint8_t id, unsigned short mode, const struct proc_ops *ops) #else static int32_t ProcRegister(const char *name, uint8_t id, unsigned short mode, const struct file_operations *ops) @@ -1110,7 +1110,7 @@ static int MipiCsiDevProcOpen(struct inode *inode, struct file *file) } // ProcFileOperations and file_operations are used in different os. -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) static const struct proc_ops g_procMipiCsiDevOps = { .proc_open = MipiCsiDevProcOpen, .proc_read = seq_read, diff --git a/platform/mipi_csi/mipi_v4l2_adapter.c b/platform/mipi_csi/mipi_v4l2_adapter.c old mode 100755 new mode 100644 index 1c79c55..d3eb584 --- a/platform/mipi_csi/mipi_v4l2_adapter.c +++ b/platform/mipi_csi/mipi_v4l2_adapter.c @@ -512,3 +512,4 @@ struct HdfDriverEntry g_mipiCsiLinuxDriverEntry = { .moduleName = "linux_mipi_csi_adapter", }; HDF_INIT(g_mipiCsiLinuxDriverEntry); + diff --git a/platform/mipi_dsi/mipi_tx_dev.c b/platform/mipi_dsi/mipi_tx_dev.c index 200e995..3a173eb 100644 --- a/platform/mipi_dsi/mipi_tx_dev.c +++ b/platform/mipi_dsi/mipi_tx_dev.c @@ -118,7 +118,7 @@ static int32_t RegisterDevice(const char *name, uint8_t id, unsigned short mode, return HDF_SUCCESS; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) static int32_t ProcRegister(const char *name, uint8_t id, unsigned short mode, const struct proc_ops *ops) #else static int32_t ProcRegister(const char *name, uint8_t id, unsigned short mode, const struct file_operations *ops) @@ -326,7 +326,7 @@ static int32_t MipiDsiDevSetCfg(struct MipiDsiCntlr *cntlr, struct MipiCfg *arg) } if (access_ok( -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) VERIFY_READ, #endif arg, size)) { /* user space */ @@ -377,7 +377,7 @@ int32_t MipiDsiDevSetCmd(struct MipiDsiCntlr *cntlr, struct DsiCmdDesc *arg) } if (access_ok( -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) VERIFY_READ, #endif arg, size)) { /* user space */ @@ -406,7 +406,7 @@ int32_t MipiDsiDevSetCmd(struct MipiDsiCntlr *cntlr, struct DsiCmdDesc *arg) int32_t MipiDsiDevCmdCopyFromUser(GetDsiCmdDescTag *arg, GetDsiCmdDescTag *temp, uint32_t *size) { if (access_ok( -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) VERIFY_READ, #endif arg, *size)) { /* user space */ @@ -426,7 +426,7 @@ int32_t MipiDsiDevCmdCopyFromUser(GetDsiCmdDescTag *arg, GetDsiCmdDescTag *temp, int32_t MipiDsiDevCmdCopyToUser(GetDsiCmdDescTag *arg, GetDsiCmdDescTag *temp, uint32_t *size) { if (access_ok( -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) VERIFY_WRITE, #endif arg, *size)) { /* user space */ @@ -622,7 +622,7 @@ static int MipiDsiDevProcOpen(struct inode *inode, struct file *file) return single_open(file, MipiDsiDevProcShow, NULL); } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) static struct proc_ops g_procMipiDsiDevOps = { .proc_open = MipiDsiDevProcOpen, .proc_read = seq_read, diff --git a/platform/mipi_dsi/mipi_tx_hi35xx.c b/platform/mipi_dsi/mipi_tx_hi35xx.c index b72caf0..066be10 100644 --- a/platform/mipi_dsi/mipi_tx_hi35xx.c +++ b/platform/mipi_dsi/mipi_tx_hi35xx.c @@ -37,6 +37,7 @@ extern "C" { #endif /* End of #ifdef __cplusplus */ #define HDF_LOG_TAG mipi_tx_hi35xx +#define INT_MAX_VALUE 0x7fffffff volatile MipiTxRegsTypeTag *g_mipiTxRegsVa = NULL; unsigned int g_mipiTxIrqNum = MIPI_TX_IRQ; @@ -128,6 +129,7 @@ static void MipiTxDrvGetPhyPllSet1Set5(unsigned int phyDataRate, { int dataRateClk; int pllRef; + uint64_t int_multiplication; dataRateClk = (phyDataRate + MIPI_TX_REF_CLK - 1) / MIPI_TX_REF_CLK; @@ -143,6 +145,11 @@ static void MipiTxDrvGetPhyPllSet1Set5(unsigned int phyDataRate, } else { pllRef = 1; } + int_multiplication = dataRateClk * pllRef; + if (int_multiplication > INT_MAX_VALUE) { + HDF_LOGE("%s: exceeds the maximum value of type int32_t.", __func__); + return; + } if ((dataRateClk * pllRef) % 2) { /* 2: pll */ *pllSet1 = 0x10; *pllSet5 = (dataRateClk * pllRef - 1) / 2; /* 2: pllRef sel */ @@ -699,7 +706,7 @@ static int32_t LinuxCopyToKernel(void *dest, uint32_t max, const void *src, uint int32_t ret; if (access_ok( -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) VERIFY_READ, #endif src, count)) { /* user space */ @@ -906,7 +913,7 @@ static int MipiTxDrvGetCmdInfo(GetCmdInfoTag *getCmdInfo) goto fail0; } if (access_ok( -#if LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0) VERIFY_WRITE, #endif getCmdInfo->getData, getCmdInfo->getDataSize)) { /* user space */ diff --git a/platform/pwm/pwm_hi35xx_linux.c b/platform/pwm/pwm_hi35xx_linux.c index 68f1e7e..e028571 100644 --- a/platform/pwm/pwm_hi35xx_linux.c +++ b/platform/pwm/pwm_hi35xx_linux.c @@ -35,7 +35,7 @@ struct Hi35xxPwmChip { struct clk *clk; }; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0) static int Hi35xxPwmApply(struct pwm_chip *chip, struct pwm_device *pwm, const struct pwm_state *state) #else static int Hi35xxPwmApply(struct pwm_chip *chip, struct pwm_device *pwm, struct pwm_state *state) diff --git a/platform/watchdog/watchdog_adapter.c b/platform/watchdog/watchdog_adapter.c index 447df2b..507475b 100644 --- a/platform/watchdog/watchdog_adapter.c +++ b/platform/watchdog/watchdog_adapter.c @@ -152,7 +152,7 @@ static struct watchdog_device *WdtCoreDataToWdd(void *wdCoreData) * } */ struct WdtCoreDataHead { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,14,182) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 182) struct device dev; #else struct kref kref; -- Gitee