Commit 57d024f8 authored by Ricardo Ribalda Delgado's avatar Ricardo Ribalda Delgado Committed by Mauro Carvalho Chehab

media: v4l2-ctrl: Use p_const when possible

After adding a const pointer to ctrl_ptr, lets use it where it make
sense.
Suggested-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarRicardo Ribalda Delgado <ribalda@kernel.org>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 8508a2d5
...@@ -1556,7 +1556,8 @@ static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx, ...@@ -1556,7 +1556,8 @@ static bool std_equal(const struct v4l2_ctrl *ctrl, u32 idx,
if (ctrl->is_int) if (ctrl->is_int)
return ptr1.p_s32[idx] == ptr2.p_s32[idx]; return ptr1.p_s32[idx] == ptr2.p_s32[idx];
idx *= ctrl->elem_size; idx *= ctrl->elem_size;
return !memcmp(ptr1.p + idx, ptr2.p + idx, ctrl->elem_size); return !memcmp(ptr1.p_const + idx, ptr2.p_const + idx,
ctrl->elem_size);
} }
} }
...@@ -1566,8 +1567,8 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx, ...@@ -1566,8 +1567,8 @@ static void std_init_compound(const struct v4l2_ctrl *ctrl, u32 idx,
struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params; struct v4l2_ctrl_mpeg2_slice_params *p_mpeg2_slice_params;
void *p = ptr.p + idx * ctrl->elem_size; void *p = ptr.p + idx * ctrl->elem_size;
if (ctrl->p_def.p) if (ctrl->p_def.p_const)
memcpy(p, ctrl->p_def.p, ctrl->elem_size); memcpy(p, ctrl->p_def.p_const, ctrl->elem_size);
else else
memset(p, 0, ctrl->elem_size); memset(p, 0, ctrl->elem_size);
...@@ -1954,7 +1955,7 @@ static int ptr_to_user(struct v4l2_ext_control *c, ...@@ -1954,7 +1955,7 @@ static int ptr_to_user(struct v4l2_ext_control *c,
u32 len; u32 len;
if (ctrl->is_ptr && !ctrl->is_string) if (ctrl->is_ptr && !ctrl->is_string)
return copy_to_user(c->ptr, ptr.p, c->size) ? return copy_to_user(c->ptr, ptr.p_const, c->size) ?
-EFAULT : 0; -EFAULT : 0;
switch (ctrl->type) { switch (ctrl->type) {
...@@ -2069,7 +2070,7 @@ static void ptr_to_ptr(struct v4l2_ctrl *ctrl, ...@@ -2069,7 +2070,7 @@ static void ptr_to_ptr(struct v4l2_ctrl *ctrl,
{ {
if (ctrl == NULL) if (ctrl == NULL)
return; return;
memcpy(to.p, from.p, ctrl->elems * ctrl->elem_size); memcpy(to.p, from.p_const, ctrl->elems * ctrl->elem_size);
} }
/* Copy the new value to the current value. */ /* Copy the new value to the current value. */
...@@ -2587,7 +2588,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, ...@@ -2587,7 +2588,7 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
is_array) is_array)
sz_extra += 2 * tot_ctrl_size; sz_extra += 2 * tot_ctrl_size;
if (type >= V4L2_CTRL_COMPOUND_TYPES && p_def.p) if (type >= V4L2_CTRL_COMPOUND_TYPES && p_def.p_const)
sz_extra += elem_size; sz_extra += elem_size;
ctrl = kvzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL); ctrl = kvzalloc(sizeof(*ctrl) + sz_extra, GFP_KERNEL);
...@@ -2634,9 +2635,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl, ...@@ -2634,9 +2635,9 @@ static struct v4l2_ctrl *v4l2_ctrl_new(struct v4l2_ctrl_handler *hdl,
ctrl->p_cur.p = &ctrl->cur.val; ctrl->p_cur.p = &ctrl->cur.val;
} }
if (type >= V4L2_CTRL_COMPOUND_TYPES && p_def.p) { if (type >= V4L2_CTRL_COMPOUND_TYPES && p_def.p_const) {
ctrl->p_def.p = ctrl->p_cur.p + tot_ctrl_size; ctrl->p_def.p = ctrl->p_cur.p + tot_ctrl_size;
memcpy(ctrl->p_def.p, p_def.p, elem_size); memcpy(ctrl->p_def.p, p_def.p_const, elem_size);
} }
for (idx = 0; idx < elems; idx++) { for (idx = 0; idx < elems; idx++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment