Re: [PATCH v4 21/29] media: mc: Don't care about unsettable flags in MEDIA_IOC_LINK_SETUP

Hans Verkuil
2026-05-05T06:36:51Z

On 08/04/2026 17:39, Sakari Ailus wrote:
> The implementation of MEDIA_IOC_LINK_SETUP currently requires that all
> flags that are set by the driver are correctly set as the driver expects.
> This poses a problem for adding new flags as programs could not work with
> links that have unknown flags even when the use of these flags wouldn't
> affect the program.
>
> Ignore the non-settable link flags.

Doesn't this require an uAPI documentation change as well, clarifying how
flags are handled?

Regards,

Hans

>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
> drivers/media/mc/mc-entity.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/mc/mc-entity.c b/drivers/media/mc/mc-entity.c
> index 717569bd1a8c..287eded356bb 100644
> --- a/drivers/media/mc/mc-entity.c
> +++ b/drivers/media/mc/mc-entity.c
> @@ -1319,7 +1319,7 @@ static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
>
> int __media_entity_setup_link(struct media_link *link, u32 flags)
> {
> - const u32 mask = MEDIA_LNK_FL_ENABLED;
> + const u32 settable_flags = MEDIA_LNK_FL_ENABLED;
> struct media_device *mdev;
> struct media_pad *source, *sink;
> int ret = -EBUSY;
> @@ -1327,9 +1327,9 @@ int __media_entity_setup_link(struct media_link *link, u32 flags)
> if (link == NULL)
> return -EINVAL;
>
> - /* The non-modifiable link flags must not be modified. */
> - if ((link->flags & ~mask) != (flags & ~mask))
> - return -EINVAL;
> + /* Only allow changing user-settable flags. */
> + flags &= settable_flags;
> + flags |= link->flags & ~settable_flags;
>
> if (link->flags & MEDIA_LNK_FL_IMMUTABLE)
> return link->flags == flags ? 0 : -EINVAL;