hdmirx: fix coverity errors
authoryicheng shen <yicheng.shen@amlogic.com>
Wed, 6 Jun 2018 05:39:31 +0000 (13:39 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Tue, 12 Jun 2018 02:37:09 +0000 (19:37 -0700)
PD#167692: hdmirx: fix coverity errors

Change-Id: I044b9e84f090e1f7b1652891522eeb1adb1ed0ac
Signed-off-by: yicheng shen <yicheng.shen@amlogic.com>
drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_drv.c
drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_eq.c
drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_pktinfo.c
drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_pktinfo.h
drivers/amlogic/media/vin/tvin/hdmirx/hdmi_rx_repeater.c

index 48076b5e3a308daac8439ad51c465918908c48d3..551eccbc47de2d8c5197a389c1c79440cd54e8c0 100644 (file)
@@ -1001,7 +1001,7 @@ static long hdmirx_ioctl(struct file *file, unsigned int cmd,
                memset(&pkt_info, 0, sizeof(pkt_info));
                srcbuff = &pkt_info;
                size = sizeof(struct pd_infoframe_s);
-               rx_get_pd_fifo_param(param, &pkt_info, size);
+               rx_get_pd_fifo_param(param, &pkt_info);
 
                /*return pkt info*/
                if ((size > 0) && (srcbuff != NULL) && (argp != NULL)) {
@@ -1137,7 +1137,7 @@ int rx_pr(const char *fmt, ...)
                        else
                                break;
 
-               strcpy(buf + 5, fmt + pos);
+               strncpy(buf + 5, fmt + pos, (sizeof(buf) - 5));
        } else
                strcpy(buf, fmt);
        /* if (fmt[strlen(fmt) - 1] == '\n') */
@@ -1468,19 +1468,19 @@ static void hdmirx_get_base_addr(struct device_node *node)
        }
 }
 
-static int hdmirx_switch_pinmux(struct device  dev)
+static int hdmirx_switch_pinmux(struct device *dev)
 {
        struct pinctrl *pin;
        const char *pin_name;
        int ret = 0;
 
        /* pinmux set */
-       if (dev.of_node) {
-               ret = of_property_read_string_index(dev.of_node,
+       if (dev->of_node) {
+               ret = of_property_read_string_index(dev->of_node,
                                            "pinctrl-names",
                                            0, &pin_name);
                if (!ret)
-                       pin = devm_pinctrl_get_select(&dev, pin_name);
+                       pin = devm_pinctrl_get_select(dev, pin_name);
                        /* rx_pr("hdmirx: pinmux:%p, name:%s\n", */
                        /* pin, pin_name); */
        }
@@ -1523,6 +1523,12 @@ static int hdmirx_probe(struct platform_device *pdev)
        log_init(DEF_LOG_BUF_SIZE);
        pEdid_buffer = (unsigned char *) pdev->dev.platform_data;
        hdmirx_dev = &pdev->dev;
+       /*get compatible matched device, to get chip related data*/
+       of_id = of_match_device(hdmirx_dt_match, &pdev->dev);
+       if (!of_id) {
+               rx_pr("unable to get matched device\n");
+               return -1;
+       }
        /* allocate memory for the per-device structure */
        hdevp = kmalloc(sizeof(struct hdmirx_dev_s), GFP_KERNEL);
        if (!hdevp) {
@@ -1531,10 +1537,6 @@ static int hdmirx_probe(struct platform_device *pdev)
                goto fail_kmalloc_hdev;
        }
        memset(hdevp, 0, sizeof(struct hdmirx_dev_s));
-       /*get compatible matched device, to get chip related data*/
-       of_id = of_match_device(hdmirx_dt_match, &pdev->dev);
-       if (!of_id)
-               rx_pr("unable to get matched device\n");
        hdevp->data = of_id->data;
        if (hdevp->data)
                rx.chip_id = hdevp->data->chip_id;
@@ -1780,7 +1782,7 @@ static int hdmirx_probe(struct platform_device *pdev)
                en_4k_timing = 1;
 
        hdmirx_hw_probe();
-       hdmirx_switch_pinmux(pdev->dev);
+       hdmirx_switch_pinmux(&(pdev->dev));
 #ifdef CONFIG_HAS_EARLYSUSPEND
        register_early_suspend(&hdmirx_early_suspend_handler);
 #endif
index fa79e8d7fc19e8d41ce15eddd5233205b3e856ca..7b130b3106d50832cc4aab04fcb2f5c47d5d1011 100644 (file)
@@ -49,7 +49,10 @@ struct st_eq_data eq_ch2;
 enum eq_sts_e eq_sts = E_EQ_START;
 /* variable define*/
 int long_cable_best_setting = 6;
-int delay_ms_cnt = 10; /* 5 */
+int delay_ms_cnt = 5; /* 5 */
+MODULE_PARM_DESC(delay_ms_cnt, "\n delay_ms_cnt\n");
+module_param(delay_ms_cnt, int, 0664);
+
 int eq_max_setting = 7;
 int eq_dbg_ch0;
 int eq_dbg_ch1;
@@ -325,7 +328,7 @@ uint8_t testType(uint16_t setting, struct st_eq_data *ch_data)
 uint8_t aquireEarlyCnt(uint16_t setting)
 {
        uint16_t lockVector = 0x0001;
-       int timeout_cnt = 20;
+       int timeout_cnt = 10;
 
        lockVector = lockVector << setting;
        hdmi_rx_phy_ConfEqualSetting(lockVector);
index c895d9a531cc5c43ec78a95c7d60c405f6123f2a..e1d9ebf42524c989acd4fe8ea35de5b8229ac53d 100644 (file)
@@ -186,8 +186,7 @@ void rx_pkt_debug(void)
 
 
 void rx_get_pd_fifo_param(enum pkt_type_e pkt_type,
-               struct pd_infoframe_s *pkt_info,
-               unsigned int size)
+               struct pd_infoframe_s *pkt_info)
 {
        switch (pkt_type) {
        case PKT_TYPE_INFOFRAME_VSI:
@@ -288,15 +287,12 @@ void rx_get_pd_fifo_param(enum pkt_type_e pkt_type,
                        rx_pkt_get_amp_ex(&pkt_info);
                break;
        default:
-               size = PFIFO_SIZE * sizeof(uint32_t);
                if (pd_fifo_buf != NULL)
                        /* srcbuff = pd_fifo_buf; */
                        memcpy(&pkt_info, &pd_fifo_buf,
                                sizeof(struct pd_infoframe_s));
-               else {
-                       size = 0;
+               else
                        pr_err("err:pd_fifo_buf is empty\n");
-               }
                break;
                }
 }
@@ -1351,7 +1347,7 @@ void rx_get_vsi_info(void)
                /*3d VSI*/
                if (pkt->sbpkt.vsi_3Dext.vdfmt == VSI_FORMAT_3D_FORMAT) {
                        rx.vs_info_details._3d_structure =
-                               rx.vs_info_details._3d_structure;
+                               pkt->sbpkt.vsi_3Dext.threeD_st;
                        rx.vs_info_details._3d_ext_data =
                                pkt->sbpkt.vsi_3Dext.threeD_ex;
                        if (log_level & VSI_LOG)
index 679cd1e741d39760c7e23ab354c4e0f71c4cf196..68f79d970baad56450b9ad651f4e1ca14da4970a 100644 (file)
@@ -971,8 +971,7 @@ extern void rx_pkt_clr_attach_drm(void);
 extern uint32_t rx_pkt_chk_busy_vsi(void);
 extern uint32_t rx_pkt_chk_busy_drm(void);
 extern void rx_get_pd_fifo_param(enum pkt_type_e pkt_type,
-               struct pd_infoframe_s *pkt_info,
-               unsigned int size);
+               struct pd_infoframe_s *pkt_info);
 
 #endif
 
index 1531e70fc8fcc86f0eb08c1040fbd223bca0af68..451aed28d640096d437cf386889cb9c939bde7e9 100644 (file)
@@ -355,7 +355,7 @@ void rx_modify_edid(unsigned char *buffer,
                        addition_size = (*addition & 0x1f) + 1;
                        cur_data = kmalloc(
                                addition_size + cur_size, GFP_KERNEL);
-                       if (cur_data != 0) {
+                       if (!cur_data) {
                                rx_pr("allocate cur_data memory failed\n");
                                return;
                        }