Skip to contentSkip to conversation

media: media-entity: make media_entity_cleanup() a no-op macro without MC

PATCH In review Zixin Wang 2 participants 3 messages Nov 13

Subsystems (2)
lore
Share & tools
lore

Zixin Wang

author
#0 lore raw

PATCH v2 1/1 media: media-entity: make media_entity_cleanup() a no-op macro without MC

Without CONFIG_MEDIA_CONTROLLER, struct v4l2_subdev has no entity member. Calls such as media_entity_cleanup(&sd->entity) therefore fail to compile even though the function does nothing:

drivers/media/i2c/cx25840/cx25840-core.c:3964:41: error:
'struct v4l2_subdev' has no member named 'entity'

Turn media_entity_cleanup() into a macro that discards its argument when CONFIG_MEDIA_CONTROLLER is disabled. This fixes the cx25840 build and any other caller passing a member that only exists with the media controller API enabled.

Fixes 634be628b5cc ("media: i2c: cx25840-core: Add missing media_entity_cleanup()")

---

Notes:
Hi Sakari, thanks for the review and the suggestion.

v2:
- Make media_entity_cleanup() a no-op macro without CONFIG_MEDIA_CONTROLLER instead of guarding each caller (suggested by Sakari).

AI assistance: the change and this changelog were drafted with the Qoder coding assistant; the sender reviewed it and ran the builds with CONFIG_MEDIA_CONTROLLER=n and =y.

 include/media/media-entity.h | 4 ++++
 1 file changed, 4 insertions(+)
include/media/media-entity.h +4 -0
index fa393e840669..400e08598dd6 100644
@@ -729,9 +729,13 @@ int media_entity_pads_init(struct media_entity *entity, u16 num_pads,
  * zeroed but that has not been initialized with media_entity_pads_init() is
  * valid and is a no-op.
  */
+#ifdef CONFIG_MEDIA_CONTROLLER
 static inline void media_entity_cleanup(struct media_entity *entity)
 {
 }
+#else
+#define media_entity_cleanup(...)	do { } while (0)
+#endif
 
 /**
  * media_get_pad_index() - retrieves a pad index from an entity
Signature · 1 line
2.56.1
maintainer
#1 lore raw

Hi Zixin,

Thanks for the patch.

Quoted 38 lines · Zixin Wang

Without CONFIG_MEDIA_CONTROLLER, struct v4l2_subdev has no entity member. Calls such as media_entity_cleanup(&sd->entity) therefore fail to compile even though the function does nothing:

drivers/media/i2c/cx25840/cx25840-core.c:3964:41: error:
'struct v4l2_subdev' has no member named 'entity'

Turn media_entity_cleanup() into a macro that discards its argument when CONFIG_MEDIA_CONTROLLER is disabled. This fixes the cx25840 build and any other caller passing a member that only exists with the media controller API enabled.

Fixes 634be628b5cc ("media: i2c: cx25840-core: Add missing media_entity_cleanup()")

---

Notes:
Hi Sakari, thanks for the review and the suggestion.

v2:
- Make media_entity_cleanup() a no-op macro without CONFIG_MEDIA_CONTROLLER instead of guarding each caller (suggested by Sakari).

AI assistance: the change and this changelog were drafted with the Qoder coding assistant; the sender reviewed it and ran the builds with CONFIG_MEDIA_CONTROLLER=n and =y.

 include/media/media-entity.h | 4 ++++
 1 file changed, 4 insertions(+)
include/media/media-entity.h +0 -0
index fa393e840669..400e08598dd6 100644

include/media/media-entity.h int media_entity_pads_init(struct media_entity *entity, u16 num_pads, · line 737

Quoted 9 lines
include/media/media-entity.h +3 -0
@@ -729,9 +729,13 @@ int media_entity_pads_init(struct media_entity *entity, u16 num_pads,
  * zeroed but that has not been initialized with media_entity_pads_init() is
  * valid and is a no-op.
  */
+#ifdef CONFIG_MEDIA_CONTROLLER
 static inline void media_entity_cleanup(struct media_entity *entity)
 {
 }
+#else
+#define media_entity_cleanup(...)	do { } while (0)

I'd still call the argument "entity". Without MC, you can e.g. pass the macro multiple arguments otherwise. I can make the change while applying.

Quoted 4 lines
include/media/media-entity.h +1 -0
+#endif
 
 /**
  * media_get_pad_index() - retrieves a pad index from an entity
Signature · 3 lines
Regards,

Sakari Ailus
author
#2 lore raw
Quoted 2 lines

I'd still call the argument "entity". Without MC, you can e.g. pass the macro multiple arguments otherwise. I can make the change while applying.

Agreed, naming it entity is better. I used a variadic macro only to avoid checkpatch's MACRO_ARG_UNUSED warning; please feel free to change it while applying.

Thanks,
Zixin