Skip to content

Commit

Permalink
vdin: clean up dead code and bad compare
Browse files Browse the repository at this point in the history
PD#151225: driver defect clean up:
torvalds#228
torvalds#262
torvalds#354
torvalds#407
torvalds#442
torvalds#445
torvalds#461
torvalds#576
torvalds#580
torvalds#598
torvalds#599
torvalds#615
torvalds#616
torvalds#671
torvalds#756
torvalds#760
torvalds#874

Change-Id: I1bc47c3e30ecfa1ca44e53f91201aa4e09ff19f5
Signed-off-by: Bencheng Jing <bencheng.jing@amlogic.com>
  • Loading branch information
Bencheng Jing authored and akiernan committed Nov 3, 2022
1 parent 07c4889 commit 1060602
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 78 deletions.
3 changes: 2 additions & 1 deletion drivers/amlogic/media/vin/tvin/tvin_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
152 changes: 112 additions & 40 deletions drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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; */
Expand Down Expand Up @@ -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(&param, 0, sizeof(struct vdin_parm_s));
Expand All @@ -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,
Expand All @@ -601,17 +614,21 @@ 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);
if (!parm[6])
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);
Expand All @@ -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);
Expand All @@ -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] &&
Expand All @@ -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;
Expand Down Expand Up @@ -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")) {
Expand All @@ -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",
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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");
Expand All @@ -1120,29 +1178,41 @@ 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); */
/* data[1] = simple_strtol(parm[3], NULL, 16); */
/* 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]);
Expand All @@ -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);
Expand Down
Loading

0 comments on commit 1060602

Please sign in to comment.