media: subdev: rename subdev-state alloc & free
authorTomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Tue, 12 Apr 2022 09:42:42 +0000 (10:42 +0100)
committerMauro Carvalho Chehab <mchehab@kernel.org>
Sun, 24 Apr 2022 07:16:20 +0000 (08:16 +0100)
v4l2_subdev_alloc_state() and v4l2_subdev_free_state() are not supposed
to be used by the drivers. However, we do have a few drivers that use
those at the moment, so we need to expose these functions for the time
being.

Prefix the functions with __ to mark the functions as internal.

At the same time, rename them to v4l2_subdev_state_alloc and
v4l2_subdev_state_free to match the style used for other functions like
video_device_alloc() and media_request_alloc().

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
drivers/media/platform/renesas/rcar-vin/rcar-v4l2.c
drivers/media/platform/renesas/vsp1/vsp1_entity.c
drivers/media/v4l2-core/v4l2-subdev.c
drivers/staging/media/tegra-video/vi.c
include/media/v4l2-subdev.h

index 287fbf2e52b3edc1f40ea4a66fdbdcb321e713c8..87c76d439b122f10bd147da1d7f2b4bca3972e6f 100644 (file)
@@ -263,7 +263,11 @@ static int rvin_try_format(struct rvin_dev *vin, u32 which,
        u32 width, height;
        int ret;
 
-       sd_state = v4l2_subdev_alloc_state(sd);
+       /*
+        * FIXME: Drop this call, drivers are not supposed to use
+        * __v4l2_subdev_state_alloc().
+        */
+       sd_state = __v4l2_subdev_state_alloc(sd);
        if (IS_ERR(sd_state))
                return PTR_ERR(sd_state);
 
@@ -299,7 +303,7 @@ static int rvin_try_format(struct rvin_dev *vin, u32 which,
 
        rvin_format_align(vin, pix);
 done:
-       v4l2_subdev_free_state(sd_state);
+       __v4l2_subdev_state_free(sd_state);
 
        return ret;
 }
index 823c15facd1b4dd24d8c203d63e74c29dfe29634..c82b3fb7b89ab22106a53058291525c50466d32f 100644 (file)
@@ -675,7 +675,11 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
         * Allocate the pad configuration to store formats and selection
         * rectangles.
         */
-       entity->config = v4l2_subdev_alloc_state(&entity->subdev);
+       /*
+        * FIXME: Drop this call, drivers are not supposed to use
+        * __v4l2_subdev_state_alloc().
+        */
+       entity->config = __v4l2_subdev_state_alloc(&entity->subdev);
        if (IS_ERR(entity->config)) {
                media_entity_cleanup(&entity->subdev.entity);
                return PTR_ERR(entity->config);
@@ -690,6 +694,6 @@ void vsp1_entity_destroy(struct vsp1_entity *entity)
                entity->ops->destroy(entity);
        if (entity->subdev.ctrl_handler)
                v4l2_ctrl_handler_free(entity->subdev.ctrl_handler);
-       v4l2_subdev_free_state(entity->config);
+       __v4l2_subdev_state_free(entity->config);
        media_entity_cleanup(&entity->subdev.entity);
 }
index 2f24ef75872b3cfa407df6396de2f94b2c22e661..a1494999352b8ed123b4f7d522094d48339c765f 100644 (file)
@@ -28,7 +28,7 @@ static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
 {
        struct v4l2_subdev_state *state;
 
-       state = v4l2_subdev_alloc_state(sd);
+       state = __v4l2_subdev_state_alloc(sd);
        if (IS_ERR(state))
                return PTR_ERR(state);
 
@@ -39,7 +39,7 @@ static int subdev_fh_init(struct v4l2_subdev_fh *fh, struct v4l2_subdev *sd)
 
 static void subdev_fh_free(struct v4l2_subdev_fh *fh)
 {
-       v4l2_subdev_free_state(fh->state);
+       __v4l2_subdev_state_free(fh->state);
        fh->state = NULL;
 }
 
@@ -861,7 +861,7 @@ int v4l2_subdev_link_validate(struct media_link *link)
 }
 EXPORT_SYMBOL_GPL(v4l2_subdev_link_validate);
 
-struct v4l2_subdev_state *v4l2_subdev_alloc_state(struct v4l2_subdev *sd)
+struct v4l2_subdev_state *__v4l2_subdev_state_alloc(struct v4l2_subdev *sd)
 {
        struct v4l2_subdev_state *state;
        int ret;
@@ -894,9 +894,9 @@ err:
 
        return ERR_PTR(ret);
 }
-EXPORT_SYMBOL_GPL(v4l2_subdev_alloc_state);
+EXPORT_SYMBOL_GPL(__v4l2_subdev_state_alloc);
 
-void v4l2_subdev_free_state(struct v4l2_subdev_state *state)
+void __v4l2_subdev_state_free(struct v4l2_subdev_state *state)
 {
        if (!state)
                return;
@@ -904,7 +904,7 @@ void v4l2_subdev_free_state(struct v4l2_subdev_state *state)
        kvfree(state->pads);
        kfree(state);
 }
-EXPORT_SYMBOL_GPL(v4l2_subdev_free_state);
+EXPORT_SYMBOL_GPL(__v4l2_subdev_state_free);
 
 #endif /* CONFIG_MEDIA_CONTROLLER */
 
index d1f43f465c2243ffb3d6edd6cdc7d021472bcd02..07d368f345cde7734c847748cf3e5673d5523f1d 100644 (file)
@@ -507,7 +507,11 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan,
        if (!subdev)
                return -ENODEV;
 
-       sd_state = v4l2_subdev_alloc_state(subdev);
+       /*
+        * FIXME: Drop this call, drivers are not supposed to use
+        * __v4l2_subdev_state_alloc().
+        */
+       sd_state = __v4l2_subdev_state_alloc(subdev);
        if (IS_ERR(sd_state))
                return PTR_ERR(sd_state);
        /*
@@ -558,7 +562,7 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan,
        v4l2_fill_pix_format(pix, &fmt.format);
        tegra_channel_fmt_align(chan, pix, fmtinfo->bpp);
 
-       v4l2_subdev_free_state(sd_state);
+       __v4l2_subdev_state_free(sd_state);
 
        return 0;
 }
index a986fdd652e68e7c3ec3f4b1ccc198031d82ee05..ac3bcc54ea0701bd1305cd58aeb5415c13d69eef 100644 (file)
@@ -1122,20 +1122,24 @@ int v4l2_subdev_link_validate_default(struct v4l2_subdev *sd,
 int v4l2_subdev_link_validate(struct media_link *link);
 
 /**
- * v4l2_subdev_alloc_state - allocate v4l2_subdev_state
+ * __v4l2_subdev_state_alloc - allocate v4l2_subdev_state
  *
  * @sd: pointer to &struct v4l2_subdev for which the state is being allocated.
  *
- * Must call v4l2_subdev_free_state() when state is no longer needed.
+ * Must call __v4l2_subdev_state_free() when state is no longer needed.
+ *
+ * Not to be called directly by the drivers.
  */
-struct v4l2_subdev_state *v4l2_subdev_alloc_state(struct v4l2_subdev *sd);
+struct v4l2_subdev_state *__v4l2_subdev_state_alloc(struct v4l2_subdev *sd);
 
 /**
- * v4l2_subdev_free_state - free a v4l2_subdev_state
+ * __v4l2_subdev_state_free - free a v4l2_subdev_state
  *
  * @state: v4l2_subdev_state to be freed.
+ *
+ * Not to be called directly by the drivers.
  */
-void v4l2_subdev_free_state(struct v4l2_subdev_state *state);
+void __v4l2_subdev_state_free(struct v4l2_subdev_state *state);
 
 #endif /* CONFIG_MEDIA_CONTROLLER */