diff mbox series

[v3,1/8] media: v4l: subdev: Store the sub-device in the sub-device state

Message ID 20231023174408.803874-2-sakari.ailus@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series Unify sub-device state access functions | expand

Commit Message

Sakari Ailus Oct. 23, 2023, 5:44 p.m. UTC
Store the sub-device in the sub-device state. This will be needed in e.g.
validating pad number when retrieving information for non-stream-aware
users. There are expected to be more needs for this in the future.

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/v4l2-core/v4l2-subdev.c | 2 ++
 include/media/v4l2-subdev.h           | 2 ++
 2 files changed, 4 insertions(+)

Comments

Laurent Pinchart Oct. 23, 2023, 10:04 p.m. UTC | #1
Hi Sakari,

Thank you for the patch.

On Mon, Oct 23, 2023 at 08:44:01PM +0300, Sakari Ailus wrote:
> Store the sub-device in the sub-device state. This will be needed in e.g.
> validating pad number when retrieving information for non-stream-aware
> users. There are expected to be more needs for this in the future.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> ---
>  drivers/media/v4l2-core/v4l2-subdev.c | 2 ++
>  include/media/v4l2-subdev.h           | 2 ++
>  2 files changed, 4 insertions(+)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index d295a4e87b66..ee4fe8f33a41 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -1441,6 +1441,8 @@ __v4l2_subdev_state_alloc(struct v4l2_subdev *sd, const char *lock_name,
>  	else
>  		state->lock = &state->_lock;
>  
> +	state->sd = sd;
> +
>  	/* Drivers that support streams do not need the legacy pad config */
>  	if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS) && sd->entity.num_pads) {
>  		state->pads = kvcalloc(sd->entity.num_pads,
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index c1f90c1223a7..6a02a565035c 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -756,6 +756,7 @@ struct v4l2_subdev_krouting {
>   *
>   * @_lock: default for 'lock'
>   * @lock: mutex for the state. May be replaced by the user.
> + * @sd: the sub-device which the state is related to
>   * @pads: &struct v4l2_subdev_pad_config array
>   * @routing: routing table for the subdev
>   * @stream_configs: stream configurations (only for V4L2_SUBDEV_FL_STREAMS)
> @@ -768,6 +769,7 @@ struct v4l2_subdev_state {
>  	/* lock for the struct v4l2_subdev_state fields */
>  	struct mutex _lock;
>  	struct mutex *lock;
> +	struct v4l2_subdev *sd;
>  	struct v4l2_subdev_pad_config *pads;
>  	struct v4l2_subdev_krouting routing;
>  	struct v4l2_subdev_stream_configs stream_configs;
Tomi Valkeinen Oct. 24, 2023, 7:35 a.m. UTC | #2
On 23/10/2023 20:44, Sakari Ailus wrote:
> Store the sub-device in the sub-device state. This will be needed in e.g.
> validating pad number when retrieving information for non-stream-aware
> users. There are expected to be more needs for this in the future.
> 
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
>   drivers/media/v4l2-core/v4l2-subdev.c | 2 ++
>   include/media/v4l2-subdev.h           | 2 ++
>   2 files changed, 4 insertions(+)
> 
> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
> index d295a4e87b66..ee4fe8f33a41 100644
> --- a/drivers/media/v4l2-core/v4l2-subdev.c
> +++ b/drivers/media/v4l2-core/v4l2-subdev.c
> @@ -1441,6 +1441,8 @@ __v4l2_subdev_state_alloc(struct v4l2_subdev *sd, const char *lock_name,
>   	else
>   		state->lock = &state->_lock;
>   
> +	state->sd = sd;
> +
>   	/* Drivers that support streams do not need the legacy pad config */
>   	if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS) && sd->entity.num_pads) {
>   		state->pads = kvcalloc(sd->entity.num_pads,
> diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
> index c1f90c1223a7..6a02a565035c 100644
> --- a/include/media/v4l2-subdev.h
> +++ b/include/media/v4l2-subdev.h
> @@ -756,6 +756,7 @@ struct v4l2_subdev_krouting {
>    *
>    * @_lock: default for 'lock'
>    * @lock: mutex for the state. May be replaced by the user.
> + * @sd: the sub-device which the state is related to
>    * @pads: &struct v4l2_subdev_pad_config array
>    * @routing: routing table for the subdev
>    * @stream_configs: stream configurations (only for V4L2_SUBDEV_FL_STREAMS)
> @@ -768,6 +769,7 @@ struct v4l2_subdev_state {
>   	/* lock for the struct v4l2_subdev_state fields */
>   	struct mutex _lock;
>   	struct mutex *lock;
> +	struct v4l2_subdev *sd;
>   	struct v4l2_subdev_pad_config *pads;
>   	struct v4l2_subdev_krouting routing;
>   	struct v4l2_subdev_stream_configs stream_configs;

Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>

(I still like 'num_pads' better, as we don't have any other use for the sd).

  Tomi
diff mbox series

Patch

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index d295a4e87b66..ee4fe8f33a41 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -1441,6 +1441,8 @@  __v4l2_subdev_state_alloc(struct v4l2_subdev *sd, const char *lock_name,
 	else
 		state->lock = &state->_lock;
 
+	state->sd = sd;
+
 	/* Drivers that support streams do not need the legacy pad config */
 	if (!(sd->flags & V4L2_SUBDEV_FL_STREAMS) && sd->entity.num_pads) {
 		state->pads = kvcalloc(sd->entity.num_pads,
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index c1f90c1223a7..6a02a565035c 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -756,6 +756,7 @@  struct v4l2_subdev_krouting {
  *
  * @_lock: default for 'lock'
  * @lock: mutex for the state. May be replaced by the user.
+ * @sd: the sub-device which the state is related to
  * @pads: &struct v4l2_subdev_pad_config array
  * @routing: routing table for the subdev
  * @stream_configs: stream configurations (only for V4L2_SUBDEV_FL_STREAMS)
@@ -768,6 +769,7 @@  struct v4l2_subdev_state {
 	/* lock for the struct v4l2_subdev_state fields */
 	struct mutex _lock;
 	struct mutex *lock;
+	struct v4l2_subdev *sd;
 	struct v4l2_subdev_pad_config *pads;
 	struct v4l2_subdev_krouting routing;
 	struct v4l2_subdev_stream_configs stream_configs;