diff mbox series

[v3,2/5] media: v4l2_ctrl: Add const pointer to ctrl_ptr

Message ID 20191101112358.29538-2-ribalda@kernel.org (mailing list archive)
State New, archived
Headers show
Series [v3,1/5] media: v4l2_ctrl: Add p_def to v4l2_ctrl_config | expand

Commit Message

Ricardo Ribalda Delgado Nov. 1, 2019, 11:23 a.m. UTC
This pointer is used to point to data that is constant. Thanks to this
we can avoid a lot of casting and we make more clear when the data is
constant or variable.

Suggested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Ricardo Ribalda Delgado <ribalda@kernel.org>
---
 include/media/v4l2-ctrls.h | 2 ++
 1 file changed, 2 insertions(+)

Comments

Hans Verkuil Nov. 4, 2019, 9:48 a.m. UTC | #1
Hi Ricardo,

On 11/1/19 12:23 PM, Ricardo Ribalda Delgado wrote:
> This pointer is used to point to data that is constant. Thanks to this
> we can avoid a lot of casting and we make more clear when the data is
> constant or variable.
> 
> Suggested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Signed-off-by: Ricardo Ribalda Delgado <ribalda@kernel.org>
> ---
>  include/media/v4l2-ctrls.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
> index 78a97b10c89e..7db9e719a583 100644
> --- a/include/media/v4l2-ctrls.h
> +++ b/include/media/v4l2-ctrls.h
> @@ -56,6 +56,7 @@ struct poll_table_struct;
>   * @p_hevc_slice_params:	Pointer to an HEVC slice parameters structure.
>   * @p_area:			Pointer to an area.
>   * @p:				Pointer to a compound value.
> + * @p_const:			Pointer to a constant compound value.
>   */
>  union v4l2_ctrl_ptr {
>  	s32 *p_s32;
> @@ -78,6 +79,7 @@ union v4l2_ctrl_ptr {
>  	struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
>  	struct v4l2_area *p_area;
>  	void *p;
> +	const void *p_const;
>  };
>  
>  /**
> 

This addition makes it possible to use const void pointers elsewhere in
the control framework.

E.g. in std_equal you can use p_const in the memcmp at the end.

Can you go through the v4l2-ctrls.c source and replace .p by .p_const
where it makes sense?

Obviously this would be a separate patch.

Regards,

	Hans
diff mbox series

Patch

diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h
index 78a97b10c89e..7db9e719a583 100644
--- a/include/media/v4l2-ctrls.h
+++ b/include/media/v4l2-ctrls.h
@@ -56,6 +56,7 @@  struct poll_table_struct;
  * @p_hevc_slice_params:	Pointer to an HEVC slice parameters structure.
  * @p_area:			Pointer to an area.
  * @p:				Pointer to a compound value.
+ * @p_const:			Pointer to a constant compound value.
  */
 union v4l2_ctrl_ptr {
 	s32 *p_s32;
@@ -78,6 +79,7 @@  union v4l2_ctrl_ptr {
 	struct v4l2_ctrl_hevc_slice_params *p_hevc_slice_params;
 	struct v4l2_area *p_area;
 	void *p;
+	const void *p_const;
 };
 
 /**