* [PATCH 1/3] media: v4l2-subdev: Make media_entity_to_v4l2_subdev() const-aware
2025-10-02 10:32 [PATCH 0/3] Switch to container_of_const() in macros Sakari Ailus
@ 2025-10-02 10:32 ` Sakari Ailus
2025-10-02 10:32 ` [PATCH 2/3] media: v4l2-dev: Make macros to obtain containers const-aware Sakari Ailus
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Sakari Ailus @ 2025-10-02 10:32 UTC (permalink / raw)
To: linux-media; +Cc: Laurent Pinchart, hans
Retain the constness of the object in media_entity_to_v4l2_subdev(), by
switching to container_of_const().
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
include/media/v4l2-subdev.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h
index e0bb58cb6d04..a37d9a847196 100644
--- a/include/media/v4l2-subdev.h
+++ b/include/media/v4l2-subdev.h
@@ -1103,7 +1103,7 @@ struct v4l2_subdev {
typeof(ent) __me_sd_ent = (ent); \
\
__me_sd_ent ? \
- container_of(__me_sd_ent, struct v4l2_subdev, entity) : \
+ container_of_const(__me_sd_ent, struct v4l2_subdev, entity) : \
NULL; \
})
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 2/3] media: v4l2-dev: Make macros to obtain containers const-aware
2025-10-02 10:32 [PATCH 0/3] Switch to container_of_const() in macros Sakari Ailus
2025-10-02 10:32 ` [PATCH 1/3] media: v4l2-subdev: Make media_entity_to_v4l2_subdev() const-aware Sakari Ailus
@ 2025-10-02 10:32 ` Sakari Ailus
2025-10-02 10:32 ` [PATCH 3/3] media: mc: " Sakari Ailus
2025-10-02 10:32 ` [PATCH 3/3] media: v4l2-dev: " Sakari Ailus
3 siblings, 0 replies; 6+ messages in thread
From: Sakari Ailus @ 2025-10-02 10:32 UTC (permalink / raw)
To: linux-media; +Cc: Laurent Pinchart, hans
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>
---
include/media/v4l2-dev.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
index a213c3398dcf..2e0f6d2e6a78 100644
--- a/include/media/v4l2-dev.h
+++ b/include/media/v4l2-dev.h
@@ -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
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/3] media: mc: Make macros to obtain containers const-aware
2025-10-02 10:32 [PATCH 0/3] Switch to container_of_const() in macros Sakari Ailus
2025-10-02 10:32 ` [PATCH 1/3] media: v4l2-subdev: Make media_entity_to_v4l2_subdev() const-aware Sakari Ailus
2025-10-02 10:32 ` [PATCH 2/3] media: v4l2-dev: Make macros to obtain containers const-aware Sakari Ailus
@ 2025-10-02 10:32 ` Sakari Ailus
2025-10-02 10:32 ` [PATCH 3/3] media: v4l2-dev: " Sakari Ailus
3 siblings, 0 replies; 6+ messages in thread
From: Sakari Ailus @ 2025-10-02 10:32 UTC (permalink / raw)
To: linux-media; +Cc: Laurent Pinchart, hans
Retain the constness of the graph objects and interfaces in macros to
obtain their containers, by switching to container_of_const().
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
include/media/media-entity.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 64cf590b1134..b91ff6f8c3bb 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -627,7 +627,7 @@ static inline bool media_entity_enum_intersects(
* @gobj: Pointer to the struct &media_gobj graph object
*/
#define gobj_to_entity(gobj) \
- container_of(gobj, struct media_entity, graph_obj)
+ container_of_const(gobj, struct media_entity, graph_obj)
/**
* gobj_to_pad - returns the struct &media_pad pointer from the
@@ -636,7 +636,7 @@ static inline bool media_entity_enum_intersects(
* @gobj: Pointer to the struct &media_gobj graph object
*/
#define gobj_to_pad(gobj) \
- container_of(gobj, struct media_pad, graph_obj)
+ container_of_const(gobj, struct media_pad, graph_obj)
/**
* gobj_to_link - returns the struct &media_link pointer from the
@@ -645,7 +645,7 @@ static inline bool media_entity_enum_intersects(
* @gobj: Pointer to the struct &media_gobj graph object
*/
#define gobj_to_link(gobj) \
- container_of(gobj, struct media_link, graph_obj)
+ container_of_const(gobj, struct media_link, graph_obj)
/**
* gobj_to_intf - returns the struct &media_interface pointer from the
@@ -654,7 +654,7 @@ static inline bool media_entity_enum_intersects(
* @gobj: Pointer to the struct &media_gobj graph object
*/
#define gobj_to_intf(gobj) \
- container_of(gobj, struct media_interface, graph_obj)
+ container_of_const(gobj, struct media_interface, graph_obj)
/**
* intf_to_devnode - returns the struct media_intf_devnode pointer from the
@@ -663,7 +663,7 @@ static inline bool media_entity_enum_intersects(
* @intf: Pointer to struct &media_intf_devnode
*/
#define intf_to_devnode(intf) \
- container_of(intf, struct media_intf_devnode, intf)
+ container_of_const(intf, struct media_intf_devnode, intf)
/**
* media_gobj_create - Initialize a graph object
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] media: v4l2-dev: Make macros to obtain containers const-aware
2025-10-02 10:32 [PATCH 0/3] Switch to container_of_const() in macros Sakari Ailus
` (2 preceding siblings ...)
2025-10-02 10:32 ` [PATCH 3/3] media: mc: " Sakari Ailus
@ 2025-10-02 10:32 ` Sakari Ailus
2025-10-02 10:45 ` Sakari Ailus
3 siblings, 1 reply; 6+ messages in thread
From: Sakari Ailus @ 2025-10-02 10:32 UTC (permalink / raw)
To: linux-media; +Cc: Laurent Pinchart, hans
Retain the constness of the graph objects and interfaces in macros to
obtain their containers, by switching to container_of_const().
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
include/media/media-entity.h | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index 64cf590b1134..b91ff6f8c3bb 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -627,7 +627,7 @@ static inline bool media_entity_enum_intersects(
* @gobj: Pointer to the struct &media_gobj graph object
*/
#define gobj_to_entity(gobj) \
- container_of(gobj, struct media_entity, graph_obj)
+ container_of_const(gobj, struct media_entity, graph_obj)
/**
* gobj_to_pad - returns the struct &media_pad pointer from the
@@ -636,7 +636,7 @@ static inline bool media_entity_enum_intersects(
* @gobj: Pointer to the struct &media_gobj graph object
*/
#define gobj_to_pad(gobj) \
- container_of(gobj, struct media_pad, graph_obj)
+ container_of_const(gobj, struct media_pad, graph_obj)
/**
* gobj_to_link - returns the struct &media_link pointer from the
@@ -645,7 +645,7 @@ static inline bool media_entity_enum_intersects(
* @gobj: Pointer to the struct &media_gobj graph object
*/
#define gobj_to_link(gobj) \
- container_of(gobj, struct media_link, graph_obj)
+ container_of_const(gobj, struct media_link, graph_obj)
/**
* gobj_to_intf - returns the struct &media_interface pointer from the
@@ -654,7 +654,7 @@ static inline bool media_entity_enum_intersects(
* @gobj: Pointer to the struct &media_gobj graph object
*/
#define gobj_to_intf(gobj) \
- container_of(gobj, struct media_interface, graph_obj)
+ container_of_const(gobj, struct media_interface, graph_obj)
/**
* intf_to_devnode - returns the struct media_intf_devnode pointer from the
@@ -663,7 +663,7 @@ static inline bool media_entity_enum_intersects(
* @intf: Pointer to struct &media_intf_devnode
*/
#define intf_to_devnode(intf) \
- container_of(intf, struct media_intf_devnode, intf)
+ container_of_const(intf, struct media_intf_devnode, intf)
/**
* media_gobj_create - Initialize a graph object
--
2.47.3
^ permalink raw reply related [flat|nested] 6+ messages in thread