]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: v4l2-dev: Make macros to obtain containers const-aware
authorSakari Ailus <sakari.ailus@linux.intel.com>
Thu, 2 Oct 2025 10:32:54 +0000 (13:32 +0300)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Mon, 3 Nov 2025 14:58:41 +0000 (15:58 +0100)
Retain the constness of the object in media_entity_to_video_device() and
to_video_device(), by switching to container_of_const().

Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
include/media/v4l2-dev.h

index a213c3398dcf60be8c531df87bf40c56b4ad772d..2e0f6d2e6a786e99231ebaafacf8ade2ee626b36 100644 (file)
@@ -320,8 +320,8 @@ struct video_device {
        typeof(__entity) __me_vdev_ent = __entity;                      \
                                                                        \
        __me_vdev_ent ?                                                 \
-               container_of(__me_vdev_ent,  struct video_device, entity) : \
-               NULL;                                                   \
+               container_of_const(__me_vdev_ent,  struct video_device, \
+                                  entity) : NULL;                      \
 })
 
 /**
@@ -330,7 +330,7 @@ struct video_device {
  *
  * @cd: pointer to &struct device
  */
-#define to_video_device(cd) container_of(cd, struct video_device, dev)
+#define to_video_device(cd) container_of_const(cd, struct video_device, dev)
 
 /**
  * __video_register_device - register video4linux devices