media: v4l2-ctrl: Add new helper v4l2_ctrl_ptr_create
authorRicardo Ribalda Delgado <ribalda@kernel.org>
Mon, 7 Oct 2019 15:06:35 +0000 (12:06 -0300)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Thu, 10 Oct 2019 14:38:21 +0000 (11:38 -0300)
This helper function simplifies the code by not needing a union
v4l2_ctrl_ptr and an assignment every time we need to use
a ctrl_ptr.

Suggested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Ricardo Ribalda Delgado <ribalda@kernel.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
include/media/v4l2-ctrls.h

index c9ca867ef32b9895a11a8f55f2c76e06396a34d9..26205ba3a0a03666053db23d9d70002314e05388 100644 (file)
@@ -73,6 +73,18 @@ union v4l2_ctrl_ptr {
        void *p;
 };
 
+/**
+ * v4l2_ctrl_ptr_create() - Helper function to return a v4l2_ctrl_ptr from a
+ * void pointer
+ * @ptr:       The void pointer
+ */
+static inline union v4l2_ctrl_ptr v4l2_ctrl_ptr_create(void *ptr)
+{
+       union v4l2_ctrl_ptr p = { .p = ptr };
+
+       return p;
+}
+
 /**
  * struct v4l2_ctrl_ops - The control operations that the driver has to provide.
  *