media: media-entity: make media_entity_cleanup() a no-op macro without MC
Subsystems (2)
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.
---
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
@@ -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
Sakari Ailus
maintainerHi Zixin,
Thanks for the patch.
Quoted 38 lines · Zixin Wang
Without
CONFIG_MEDIA_CONTROLLER, structv4l2_subdevhas no entity member. Calls such asmedia_entity_cleanup(&sd->entity)therefore fail to compile even though the function does nothing:
drivers/media/i2c/cx25840/cx25840-core.c:3964:41: error:
'structv4l2_subdev' has no member named 'entity'Turn
media_entity_cleanup()into a macro that discards its argument whenCONFIG_MEDIA_CONTROLLERis disabled. This fixes the cx25840 build and any other caller passing a member that only exists with the media controller API enabled.Suggested-by Sakari Ailus <[email protected]>Fixes 634be628b5cc ("media: i2c: cx25840-core: Add missing media_entity_cleanup()")Signed-off-by Zixin Wang <[email protected]>---
Notes:
Hi Sakari, thanks for the review and the suggestion.v2:
- Makemedia_entity_cleanup()a no-op macro withoutCONFIG_MEDIA_CONTROLLERinstead 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=nand =y.include/media/media-entity.h | 4 ++++ 1 file changed, 4 insertions(+)include/media/media-entity.h +0
-0
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
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