Skip to content

Commit

Permalink
[media] media: Properly handle link flags in link setup, link notify …
Browse files Browse the repository at this point in the history
…callback

The link flags were not properly handled in __media_entity_setup_link
which could lead to link_notify callback to be called when the flags are
not modified. Fix this.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Laurent Pinchart authored and Mauro Carvalho Chehab committed Apr 17, 2011
1 parent 2d4e9d1 commit 7a6f0b2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/media/media-entity.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,6 @@ EXPORT_SYMBOL_GPL(media_entity_create_link);

static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
{
const u32 mask = MEDIA_LNK_FL_ENABLED;
int ret;

/* Notify both entities. */
Expand All @@ -395,7 +394,7 @@ static int __media_entity_setup_link_notify(struct media_link *link, u32 flags)
return ret;
}

link->flags = (link->flags & ~mask) | (flags & mask);
link->flags = flags;
link->reverse->flags = link->flags;

return 0;
Expand All @@ -417,13 +416,18 @@ 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;
struct media_device *mdev;
struct media_entity *source, *sink;
int ret = -EBUSY;

if (link == NULL)
return -EINVAL;

/* The non-modifiable link flags must not be modified. */
if ((link->flags & ~mask) != (flags & ~mask))
return -EINVAL;

if (link->flags & MEDIA_LNK_FL_IMMUTABLE)
return link->flags == flags ? 0 : -EINVAL;

Expand Down

0 comments on commit 7a6f0b2

Please sign in to comment.