diff options
| author | Tomi Valkeinen <[email protected]> | 2022-04-12 09:42:43 +0000 |
|---|---|---|
| committer | Mauro Carvalho Chehab <[email protected]> | 2022-04-24 07:17:24 +0000 |
| commit | f69952a4dc1ef13b69497408fedbd12c7ceb294d (patch) | |
| tree | 88ec3dbd63f2e26353c655a917d26f7ad561507c /drivers/media/v4l2-core/v4l2-subdev.c | |
| parent | media: subdev: rename subdev-state alloc & free (diff) | |
| download | kernel-f69952a4dc1ef13b69497408fedbd12c7ceb294d.tar.gz kernel-f69952a4dc1ef13b69497408fedbd12c7ceb294d.zip | |
media: subdev: add active state to struct v4l2_subdev
Add a new 'active_state' field to struct v4l2_subdev to which we can
store the active state of a subdev. This will place the subdev
configuration into a known place, allowing us to use the state directly
from the v4l2 framework, thus simplifying the drivers.
Also add functions v4l2_subdev_init_finalize() and
v4l2_subdev_cleanup(), which will allocate and free the active state.
The functions are named in a generic way so that they can be also used
for other subdev initialization work.
Signed-off-by: Tomi Valkeinen <[email protected]>
Reviewed-by: Hans Verkuil <[email protected]>
Reviewed-by: Jacopo Mondi <[email protected]>
Reviewed-by: Laurent Pinchart <[email protected]>
Signed-off-by: Sakari Ailus <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>
Diffstat (limited to 'drivers/media/v4l2-core/v4l2-subdev.c')
| -rw-r--r-- | drivers/media/v4l2-core/v4l2-subdev.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index a1494999352b..5ac447b3038c 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -906,6 +906,27 @@ void __v4l2_subdev_state_free(struct v4l2_subdev_state *state) } EXPORT_SYMBOL_GPL(__v4l2_subdev_state_free); +int v4l2_subdev_init_finalize(struct v4l2_subdev *sd) +{ + struct v4l2_subdev_state *state; + + state = __v4l2_subdev_state_alloc(sd); + if (IS_ERR(state)) + return PTR_ERR(state); + + sd->active_state = state; + + return 0; +} +EXPORT_SYMBOL_GPL(v4l2_subdev_init_finalize); + +void v4l2_subdev_cleanup(struct v4l2_subdev *sd) +{ + __v4l2_subdev_state_free(sd->active_state); + sd->active_state = NULL; +} +EXPORT_SYMBOL_GPL(v4l2_subdev_cleanup); + #endif /* CONFIG_MEDIA_CONTROLLER */ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops) |
