mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] media: media-entity: make media_entity_cleanup() a no-op macro without MC
@ 2026-11-13  2:18 Zixin Wang
  2026-11-13  7:47 ` Sakari Ailus
  0 siblings, 1 reply; 2+ messages in thread
From: Zixin Wang @ 2026-11-13  2:18 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Hans Verkuil, Sakari Ailus, Biren Pandya, linux-media,
	linux-kernel, 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.

Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Fixes: 634be628b5cc ("media: i2c: cx25840-core: Add missing media_entity_cleanup()")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=222245
Signed-off-by: Zixin Wang <w1355457260@gmail.com>
---

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(+)

diff --git a/include/media/media-entity.h b/include/media/media-entity.h
index fa393e840669..400e08598dd6 100644
--- a/include/media/media-entity.h
+++ b/include/media/media-entity.h
@@ -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
-- 
2.56.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] media: media-entity: make media_entity_cleanup() a no-op macro without MC
  2026-11-13  2:18 [PATCH v2] media: media-entity: make media_entity_cleanup() a no-op macro without MC Zixin Wang
@ 2026-11-13  7:47 ` Sakari Ailus
  0 siblings, 0 replies; 2+ messages in thread
From: Sakari Ailus @ 2026-11-13  7:47 UTC (permalink / raw)
  To: Zixin Wang
  Cc: Mauro Carvalho Chehab, Hans Verkuil, Biren Pandya, linux-media,
	linux-kernel

Hi Zixin,

Thanks for the patch.

On Fri, Nov 13, 2026 at 10:18:45AM +0800, Zixin Wang wrote:
> 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.
> 
> Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> Fixes: 634be628b5cc ("media: i2c: cx25840-core: Add missing media_entity_cleanup()")
> Link: https://bugzilla.kernel.org/show_bug.cgi?id=222245
> Signed-off-by: Zixin Wang <w1355457260@gmail.com>
> ---
> 
> 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(+)
> 
> diff --git a/include/media/media-entity.h b/include/media/media-entity.h
> index fa393e840669..400e08598dd6 100644
> --- a/include/media/media-entity.h
> +++ b/include/media/media-entity.h
> @@ -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.

> +#endif
>  
>  /**
>   * media_get_pad_index() - retrieves a pad index from an entity

-- 
Regards,

Sakari Ailus

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-13  7:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-13  2:18 [PATCH v2] media: media-entity: make media_entity_cleanup() a no-op macro without MC Zixin Wang
2026-11-13  7:47 ` Sakari Ailus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®