diff --git a/drivers/amlogic/media/vin/tvin/tvin_frontend.c b/drivers/amlogic/media/vin/tvin/tvin_frontend.c index ba5dd61b79a5bc..40c99f31ebcc5f 100644 --- a/drivers/amlogic/media/vin/tvin/tvin_frontend.c +++ b/drivers/amlogic/media/vin/tvin/tvin_frontend.c @@ -55,7 +55,8 @@ int tvin_reg_frontend(struct tvin_frontend_s *fe) ulong flags; struct tvin_frontend_s *f, *t; - if (!fe->name || !fe->dec_ops || !fe->dec_ops->support || !fe->sm_ops) + if (!strlen(fe->name) || !fe->dec_ops || + !fe->dec_ops->support || !fe->sm_ops) return -1; /* check whether the frontend is registered already */ diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c b/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c index 6393d15f1b4cef..5b00247e4a4bc3 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c @@ -162,7 +162,7 @@ static void vdin_dump_mem(char *path, struct vdin_dev_s *devp) struct file *filp = NULL; loff_t pos = 0; void *buf = NULL; - int i = 0; + loff_t i = 0; unsigned int canvas_real_size = devp->canvas_h * devp->canvas_w; mm_segment_t old_fs = get_fs(); @@ -174,7 +174,7 @@ static void vdin_dump_mem(char *path, struct vdin_dev_s *devp) return; } if ((devp->cma_config_flag == 1) && - (devp->cma_mem_alloc[devp->index] == 0)) { + (devp->cma_mem_alloc == 0)) { pr_info("%s:no cma alloc mem!!!\n", __func__); return; } @@ -188,7 +188,7 @@ static void vdin_dump_mem(char *path, struct vdin_dev_s *devp) buf = phys_to_virt(devp->mem_start + devp->canvas_max_size*i); vfs_write(filp, buf, canvas_real_size, &pos); - pr_info("write buffer %2d of %2u to %s.\n", + pr_info("write buffer %lld of %2u to %s.\n", i, devp->canvas_max_num, path); } vfs_fsync(filp, 0); @@ -427,11 +427,15 @@ static ssize_t vdin_attr_store(struct device *dev, /* start = simple_strtol(parm[2], NULL, 16); */ /* offset = simple_strtol(parm[3], NULL, 16); */ - if (kstrtol(parm[2], 16, &val) < 0) + if (kstrtol(parm[2], 16, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } start = val; - if (kstrtol(parm[3], 16, &val) < 0) + if (kstrtol(parm[3], 16, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } offset = val; dump_other_mem(parm[1], start, offset); } else if (parm[1] != NULL) { @@ -480,8 +484,10 @@ static ssize_t vdin_attr_store(struct device *dev, break; } /* fmt = simple_strtol(parm[2], NULL, 16); */ - if (kstrtol(parm[2], 16, &val) < 0) + if (kstrtol(parm[2], 16, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } fmt = val; /* devp->flags |= VDIN_FLAG_FS_OPENED; */ @@ -563,6 +569,7 @@ static ssize_t vdin_attr_store(struct device *dev, pr_err("fps cfmt > /sys/class/vdin/vdinx/attr.\n"); pr_err("port mybe bt656 or viuin,"); pr_err("fps the frame rate of input.\n"); + kfree(buf_orig); return len; } memset(¶m, 0, sizeof(struct vdin_parm_s)); @@ -584,14 +591,20 @@ static ssize_t vdin_attr_store(struct device *dev, /* param.h_active = simple_strtol(parm[2], NULL, 10); */ /* param.v_active = simple_strtol(parm[3], NULL, 10); */ /* param.frame_rate = simple_strtol(parm[4], NULL, 10); */ - if (kstrtol(parm[2], 10, &val) < 0) + if (kstrtol(parm[2], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } param.h_active = val; - if (kstrtol(parm[3], 10, &val) < 0) + if (kstrtol(parm[3], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } param.v_active = val; - if (kstrtol(parm[4], 10, &val) < 0) + if (kstrtol(parm[4], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } param.frame_rate = val; pr_info(" hactive:%d,vactive:%d, rate:%d\n", param.h_active, @@ -601,8 +614,10 @@ static ssize_t vdin_attr_store(struct device *dev, param.cfmt = TVIN_YUV422; else { /* param.cfmt = simple_strtol(parm[5], NULL, 10); */ - if (kstrtol(parm[5], 10, &val) < 0) + if (kstrtol(parm[5], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } param.cfmt = val; } pr_info(" cfmt:%d\n", param.cfmt); @@ -610,8 +625,10 @@ static ssize_t vdin_attr_store(struct device *dev, param.dfmt = TVIN_YUV422; else { /* param.dfmt = simple_strtol(parm[6], NULL, 10); */ - if (kstrtol(parm[6], 10, &val) < 0) + if (kstrtol(parm[6], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } param.dfmt = val; } pr_info(" dfmt:%d\n", param.dfmt); @@ -621,8 +638,10 @@ static ssize_t vdin_attr_store(struct device *dev, /* param.scan_mode = * simple_strtol(parm[7], NULL, 10); */ - if (kstrtol(parm[7], 10, &val) < 0) + if (kstrtol(parm[7], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } param.scan_mode = val; } pr_info(" scan_mode:%d\n", param.scan_mode); @@ -634,16 +653,20 @@ static ssize_t vdin_attr_store(struct device *dev, } else if (!strcmp(parm[0], "disablesm")) del_timer_sync(&devp->timer); else if (!strcmp(parm[0], "freeze")) { - if (!(devp->flags & VDIN_FLAG_DEC_STARTED)) + if (!(devp->flags & VDIN_FLAG_DEC_STARTED)) { + kfree(buf_orig); return len; + } if (devp->fmt_info_p->scan_mode == TVIN_SCAN_MODE_PROGRESSIVE) vdin_vf_freeze(devp->vfp, 1); else vdin_vf_freeze(devp->vfp, 2); } else if (!strcmp(parm[0], "unfreeze")) { - if (!(devp->flags & VDIN_FLAG_DEC_STARTED)) + if (!(devp->flags & VDIN_FLAG_DEC_STARTED)) { + kfree(buf_orig); return len; + } vdin_vf_unfreeze(devp->vfp); } else if (!strcmp(parm[0], "conversion")) { if (parm[1] && @@ -655,14 +678,20 @@ static ssize_t vdin_attr_store(struct device *dev, /* simple_strtoul(parm[2], NULL, 10); */ /* devp->debug.dest_cfmt = */ /* simple_strtoul(parm[3], NULL, 10); */ - if (kstrtoul(parm[1], 10, &val) < 0) + if (kstrtoul(parm[1], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } devp->debug.scaler4w = val; - if (kstrtoul(parm[2], 10, &val) < 0) + if (kstrtoul(parm[2], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } devp->debug.scaler4h = val; - if (kstrtoul(parm[3], 10, &val) < 0) + if (kstrtoul(parm[3], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } devp->debug.dest_cfmt = val; devp->flags |= VDIN_FLAG_MANUAL_CONVERSION; @@ -715,11 +744,15 @@ static ssize_t vdin_attr_store(struct device *dev, } else if (!strcmp(parm[0], "rgb_xy")) { unsigned int x, y; - if (kstrtoul(parm[1], 10, &val) < 0) + if (kstrtoul(parm[1], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } x = val; - if (kstrtoul(parm[2], 10, &val) < 0) + if (kstrtoul(parm[2], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } y = val; vdin_set_prob_xy(devp->addr_offset, x, y, devp); } else if (!strcmp(parm[0], "rgb_info")) { @@ -728,11 +761,15 @@ static ssize_t vdin_attr_store(struct device *dev, vdin_get_prob_rgb(devp->addr_offset, &r, &g, &b); pr_info("rgb_info-->r:%d,g:%d,b:%d\n", r, g, b); } else if (!strcmp(parm[0], "mpeg2vdin")) { - if (kstrtoul(parm[1], 10, &val) < 0) + if (kstrtoul(parm[1], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } devp->h_active = val; - if (kstrtoul(parm[2], 10, &val) < 0) + if (kstrtoul(parm[2], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } devp->v_active = val; vdin_set_mpegin(devp); pr_info("mpeg2vdin:h_active:%d,v_active:%d\n", @@ -747,19 +784,24 @@ static ssize_t vdin_attr_store(struct device *dev, } else if (!strcmp(parm[0], "mat0_xy")) { unsigned int x, y; - if (kstrtoul(parm[1], 10, &val) < 0) + if (kstrtoul(parm[1], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } x = val; - if (kstrtoul(parm[2], 10, &val) < 0) + if (kstrtoul(parm[2], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } y = val; pr_info("pos x :%d, pos y :%d\n", x, y); vdin_set_prob_matrix0_xy(devp->addr_offset, x, y, devp); } else if (!strcmp(parm[0], "mat0_set")) { unsigned int x; - - if (kstrtoul(parm[1], 10, &val) < 0) + if (kstrtoul(parm[1], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } x = val; pr_info("matrix set : %d\n", x); vdin_set_before_after_mat0(devp->addr_offset, x, devp); @@ -862,14 +904,18 @@ static ssize_t vdin_attr_store(struct device *dev, vdin_resume_dec(devp); pr_info("resume_dec(%d) ok\n\n", devp->index); } else if (!strcmp(parm[0], "color_depth")) { - if (kstrtoul(parm[1], 10, &val) < 0) + if (kstrtoul(parm[1], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } devp->color_depth_config = val; pr_info("color_depth(%d):%d\n\n", devp->index, devp->color_depth_config); } else if (!strcmp(parm[0], "color_depth_mode")) { - if (kstrtoul(parm[1], 10, &val) < 0) + if (kstrtoul(parm[1], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } devp->color_depth_mode = val; pr_info("color_depth_mode(%d):%d\n\n", devp->index, devp->color_depth_mode); @@ -1033,21 +1079,29 @@ struct device_attribute *attr, const char *buf, size_t count) /* crop->vs = simple_strtol(parm[2], NULL, 10); */ /* crop->ve = simple_strtol(parm[3], NULL, 10); */ - if (kstrtol(parm[0], 10, &val) < 0) + if (kstrtol(parm[0], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } crop->hs = val; - if (kstrtol(parm[1], 10, &val) < 0) + if (kstrtol(parm[1], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } crop->he = val; - if (kstrtol(parm[2], 10, &val) < 0) + if (kstrtol(parm[2], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } crop->vs = val; - if (kstrtol(parm[3], 10, &val) < 0) + if (kstrtol(parm[3], 10, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } crop->ve = val; - pr_info("hs_offset %u, he_offset %u, vs_offset %u, ve_offset %u.\n", crop->hs, crop->he, crop->vs, crop->ve); + kfree(buf_orig); return count; } @@ -1111,7 +1165,11 @@ static ssize_t vdin_cm2_store(struct device *dev, continue; parm[n++] = token; } - + if (n == 0) { + pr_info("parm[] not initialized.\n"); + kfree(buf_orig); + return count; + } if ((parm[0][0] == 'w') && parm[0][1] == 'm') { if (n != 7) { pr_info("read : invalid parameter\n"); @@ -1120,8 +1178,10 @@ static ssize_t vdin_cm2_store(struct device *dev, return count; } /* addr = simple_strtol(parm[1], NULL, 16); */ - if (kstrtol(parm[1], 16, &val) < 0) + if (kstrtol(parm[1], 16, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } addr = val; addr = addr - addr%8; /* data[0] = simple_strtol(parm[2], NULL, 16); */ @@ -1129,20 +1189,30 @@ static ssize_t vdin_cm2_store(struct device *dev, /* data[2] = simple_strtol(parm[4], NULL, 16); */ /* data[3] = simple_strtol(parm[5], NULL, 16); */ /* data[4] = simple_strtol(parm[6], NULL, 16); */ - if (kstrtol(parm[2], 16, &val) < 0) + if (kstrtol(parm[2], 16, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } data[0] = val; - if (kstrtol(parm[3], 16, &val) < 0) + if (kstrtol(parm[3], 16, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } data[1] = val; - if (kstrtol(parm[4], 16, &val) < 0) + if (kstrtol(parm[4], 16, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } data[2] = val; - if (kstrtol(parm[5], 16, &val) < 0) + if (kstrtol(parm[5], 16, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } data[3] = val; - if (kstrtol(parm[6], 16, &val) < 0) + if (kstrtol(parm[6], 16, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } data[4] = val; aml_write_vcbus(addr_port, addr); aml_write_vcbus(data_port, data[0]); @@ -1164,8 +1234,10 @@ static ssize_t vdin_cm2_store(struct device *dev, return count; } /* addr = simple_strtol(parm[1], NULL, 16); */ - if (kstrtol(parm[1], 16, &val) < 0) + if (kstrtol(parm[1], 16, &val) < 0) { + kfree(buf_orig); return -EINVAL; + } addr = val; addr = addr - addr%8; aml_write_vcbus(addr_port, addr); diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c b/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c index 4cbce525d77afd..e311342f828248 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c @@ -292,7 +292,7 @@ static const struct vframe_operations_s vdin_vf_ops = { #ifdef CONFIG_CMA void vdin_cma_alloc(struct vdin_dev_s *devp) { - char vdin_name[5]; + char vdin_name[6]; unsigned int mem_size, h_size; int flags = CODEC_MM_FLAGS_CMA_FIRST|CODEC_MM_FLAGS_CMA_CLEAR| CODEC_MM_FLAGS_CPU; @@ -324,13 +324,13 @@ void vdin_cma_alloc(struct vdin_dev_s *devp) mem_size = h_size * devp->v_active; mem_size = PAGE_ALIGN(mem_size)*max_buf_num; mem_size = (mem_size/PAGE_SIZE + 1)*PAGE_SIZE; - if (mem_size > devp->cma_mem_size[devp->index]) - mem_size = devp->cma_mem_size[devp->index]; + if (mem_size > devp->cma_mem_size) + mem_size = devp->cma_mem_size; if (devp->cma_config_en == 0) return; - if (devp->cma_mem_alloc[devp->index] == 1) + if (devp->cma_mem_alloc == 1) return; - devp->cma_mem_alloc[devp->index] = 1; + devp->cma_mem_alloc = 1; if (devp->cma_config_flag == 1) { if (devp->index == 0) strcpy(vdin_name, "vdin0"); @@ -348,12 +348,12 @@ void vdin_cma_alloc(struct vdin_dev_s *devp) pr_info("vdin%d codec cma alloc ok!\n", devp->index); } } else if (devp->cma_config_flag == 0) { - devp->venc_pages[devp->index] = dma_alloc_from_contiguous( - &(devp->this_pdev[devp->index]->dev), - devp->cma_mem_size[devp->index] >> PAGE_SHIFT, 0); + devp->venc_pages = dma_alloc_from_contiguous( + &(devp->this_pdev->dev), + devp->cma_mem_size >> PAGE_SHIFT, 0); if (devp->venc_pages) { devp->mem_start = - page_to_phys(devp->venc_pages[devp->index]); + page_to_phys(devp->venc_pages); devp->mem_size = mem_size; pr_info("vdin%d mem_start = 0x%x, mem_size = 0x%x\n", devp->index, devp->mem_start, devp->mem_size); @@ -367,12 +367,12 @@ void vdin_cma_alloc(struct vdin_dev_s *devp) void vdin_cma_release(struct vdin_dev_s *devp) { - char vdin_name[5]; + char vdin_name[6]; if (devp->cma_config_en == 0) return; if ((devp->cma_config_flag == 1) && devp->mem_start - && (devp->cma_mem_alloc[devp->index] == 1)) { + && (devp->cma_mem_alloc == 1)) { if (devp->index == 0) strcpy(vdin_name, "vdin0"); else if (devp->index == 1) @@ -380,17 +380,17 @@ void vdin_cma_release(struct vdin_dev_s *devp) codec_mm_free_for_dma(vdin_name, devp->mem_start); devp->mem_start = 0; devp->mem_size = 0; - devp->cma_mem_alloc[devp->index] = 0; + devp->cma_mem_alloc = 0; pr_info("vdin%d codec cma release ok!\n", devp->index); - } else if (devp->venc_pages[devp->index] - && devp->cma_mem_size[devp->index] - && (devp->cma_mem_alloc[devp->index] == 1) + } else if (devp->venc_pages + && devp->cma_mem_size + && (devp->cma_mem_alloc == 1) && (devp->cma_config_flag == 0)) { - devp->cma_mem_alloc[devp->index] = 0; + devp->cma_mem_alloc = 0; dma_release_from_contiguous( - &(devp->this_pdev[devp->index]->dev), - devp->venc_pages[devp->index], - devp->cma_mem_size[devp->index] >> PAGE_SHIFT); + &(devp->this_pdev->dev), + devp->venc_pages, + devp->cma_mem_size >> PAGE_SHIFT); pr_info("vdin%d cma release ok!\n", devp->index); } } @@ -901,6 +901,7 @@ void vdin_start_dec(struct vdin_dev_s *devp) vdin_set_all_regs(devp); if (!(devp->parm.flag & TVIN_PARM_FLAG_CAP) && + (devp->frontend) && devp->frontend->dec_ops && devp->frontend->dec_ops->start && (devp->parm.port != TVIN_PORT_CVBS3)) @@ -1502,8 +1503,6 @@ irqreturn_t vdin_isr(int irq, void *dev_id) /* char provider_name[] = "deinterlace"; */ /* char provider_vdin0[] = "vdin0"; */ - isr_log(devp->vfp); - irq_cnt++; /* debug interrupt interval time * * this code about system time must be outside of spinlock. @@ -2289,7 +2288,7 @@ static long vdin_ioctl(struct file *file, unsigned int cmd, unsigned long arg) } case TVIN_IOC_G_BUF_INFO: { struct tvin_buf_info_s buf_info; - + memset(&buf_info, 0, sizeof(buf_info)); buf_info.buf_count = devp->canvas_max_num; buf_info.buf_width = devp->canvas_w; buf_info.buf_height = devp->canvas_h; @@ -2306,7 +2305,7 @@ static long vdin_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case TVIN_IOC_GET_BUF: { struct tvin_video_buf_s tvbuf; struct vf_entry *vfe; - + memset(&tvbuf, 0, sizeof(tvbuf)); vfe = list_entry(devp->vfp->wr_next, struct vf_entry, list); devp->vfp->wr_next = devp->vfp->wr_next->next; if (devp->vfp->wr_next != &devp->vfp->wr_list) @@ -2612,19 +2611,19 @@ static int vdin_drv_probe(struct platform_device *pdev) if (vdevp->cma_config_flag == 1) { ret = of_property_read_u32(pdev->dev.of_node, "cma_size", - &(vdevp->cma_mem_size[vdevp->index])); + &(vdevp->cma_mem_size)); if (ret) pr_err("don't find match cma_size\n"); else - vdevp->cma_mem_size[vdevp->index] *= SZ_1M; + vdevp->cma_mem_size *= SZ_1M; } else if (vdevp->cma_config_flag == 0) - vdevp->cma_mem_size[vdevp->index] = + vdevp->cma_mem_size = dma_get_cma_size_int_byte(&pdev->dev); - vdevp->this_pdev[vdevp->index] = pdev; - vdevp->cma_mem_alloc[vdevp->index] = 0; + vdevp->this_pdev = pdev; + vdevp->cma_mem_alloc = 0; vdevp->cma_config_en = 1; pr_info("vdin%d cma_mem_size = %d MB\n", vdevp->index, - (u32)vdevp->cma_mem_size[vdevp->index]/SZ_1M); + (u32)vdevp->cma_mem_size/SZ_1M); } #endif use_reserved_mem = 0; @@ -2821,12 +2820,12 @@ static int vdin_drv_remove(struct platform_device *pdev) vdin_delete_device(vdevp->index); cdev_del(&vdevp->cdev); vdin_devp[vdevp->index] = NULL; - kfree(vdevp); /* free drvdata */ dev_set_drvdata(vdevp->dev, NULL); platform_set_drvdata(pdev, NULL); + kfree(vdevp); pr_info("%s: driver removed ok\n", __func__); return 0; } diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h b/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h index a1f72bf36208e5..b236cd565bea89 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h @@ -233,10 +233,10 @@ struct vdin_dev_s { /*cma_config_flag:1:share with codec_mm;0:cma alone*/ unsigned int cma_config_flag; #ifdef CONFIG_CMA - struct platform_device *this_pdev[2]; - struct page *venc_pages[2]; - unsigned int cma_mem_size[2];/*BYTE*/ - unsigned int cma_mem_alloc[2]; + struct platform_device *this_pdev; + struct page *venc_pages; + unsigned int cma_mem_size;/*BYTE*/ + unsigned int cma_mem_alloc; #endif /* bit0: enable/disable; bit4: luma range info */ unsigned int csc_cfg; diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_sm.c b/drivers/amlogic/media/vin/tvin/vdin/vdin_sm.c index 02b614f7d40335..f6e9a6de88bc61 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_sm.c +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_sm.c @@ -176,7 +176,9 @@ static void hdmirx_color_fmt_handler(struct vdin_dev_s *devp) unsigned int vdin_hdr_flag, pre_vdin_hdr_flag; unsigned int vdin_fmt_range, pre_vdin_fmt_range; - if (!devp || !devp->frontend) { + if (!devp) { + return; + } else if (!devp->frontend) { sm_dev[devp->index].state = TVIN_SM_STATUS_NULL; return; } @@ -240,13 +242,15 @@ void tvin_smr(struct vdin_dev_s *devp) struct tvin_frontend_s *fe; struct tvin_sig_property_s *prop, *pre_prop; - if (devp->flags & VDIN_FLAG_SM_DISABLE) + if (!devp) { return; - if (!devp || !devp->frontend) { + } else if (!devp->frontend) { sm_dev[devp->index].state = TVIN_SM_STATUS_NULL; return; } + if (devp->flags & VDIN_FLAG_SM_DISABLE) + return; sm_p = &sm_dev[devp->index]; fe = devp->frontend; sm_ops = devp->frontend->sm_ops;