summaryrefslogtreecommitdiff
path: root/drivers/media/media-entity.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@osg.samsung.com>2015-08-28 15:43:36 -0300
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-01-11 12:18:48 -0200
commit1283f849dce2e64690e610216cd8dc3df9789bae (patch)
tree3af8df932c326dea3ee88c4e7a588a64b161bd43 /drivers/media/media-entity.c
parent86e2662071d6f26704bb290317746149ce07be7a (diff)
[media] media-entity: add a helper function to create interface
As we'll be adding other interface types in the future, put the common interface create code on a separate function. Suggested-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/media-entity.c')
-rw-r--r--drivers/media/media-entity.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index 55cafb016fe8..d15797e8a142 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -839,6 +839,18 @@ struct media_pad *media_entity_remote_pad(struct media_pad *pad)
EXPORT_SYMBOL_GPL(media_entity_remote_pad);
+static void media_interface_init(struct media_device *mdev,
+ struct media_interface *intf,
+ u32 gobj_type,
+ u32 intf_type, u32 flags)
+{
+ intf->type = intf_type;
+ intf->flags = flags;
+ INIT_LIST_HEAD(&intf->links);
+
+ media_gobj_init(mdev, gobj_type, &intf->graph_obj);
+}
+
/* Functions related to the media interface via device nodes */
struct media_intf_devnode *media_devnode_create(struct media_device *mdev,
@@ -847,23 +859,16 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev,
gfp_t gfp_flags)
{
struct media_intf_devnode *devnode;
- struct media_interface *intf;
devnode = kzalloc(sizeof(*devnode), gfp_flags);
if (!devnode)
return NULL;
- intf = &devnode->intf;
-
- intf->type = type;
- intf->flags = flags;
- INIT_LIST_HEAD(&intf->links);
-
devnode->major = major;
devnode->minor = minor;
- media_gobj_init(mdev, MEDIA_GRAPH_INTF_DEVNODE,
- &devnode->intf.graph_obj);
+ media_interface_init(mdev, &devnode->intf, MEDIA_GRAPH_INTF_DEVNODE,
+ type, flags);
return devnode;
}