Hi Mauro,
On Tue, Oct 13, 2015 at 08:04:27AM -0300, Mauro Carvalho Chehab wrote:
Em Tue, 13 Oct 2015 01:33:03 +0300 Sakari Ailus sakari.ailus@iki.fi escreveu:
Hi Mauro,
On Mon, Oct 12, 2015 at 01:43:17PM -0300, Mauro Carvalho Chehab wrote:
Now that we have a new graph object called "interfaces", we need to be able to link them to the entities.
Add a linked list to the interfaces to allow them to be linked to the entities.
Change-Id: I3f46789a764b113c8acca7f0c87ef0eb6a0f265d Signed-off-by: Mauro Carvalho Chehab mchehab@osg.samsung.com Acked-by: Hans Verkuil hans.verkuil@cisco.com
drivers/media/media-entity.c | 38 ++++++++++++++++++++++++++++++++++++++ include/media/media-entity.h | 9 +++++++++ 2 files changed, 47 insertions(+)
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c index f9c6c2a81903..8e17272936c9 100644 --- a/drivers/media/media-entity.c +++ b/drivers/media/media-entity.c @@ -869,6 +869,7 @@ struct media_intf_devnode *media_devnode_create(struct media_device *mdev,
intf->type = type; intf->flags = flags;
INIT_LIST_HEAD(&intf->links);
devnode->major = major; devnode->minor = minor;
@@ -886,3 +887,40 @@ void media_devnode_remove(struct media_intf_devnode *devnode) kfree(devnode); } EXPORT_SYMBOL_GPL(media_devnode_remove);
+struct media_link *media_create_intf_link(struct media_entity *entity,
struct media_interface *intf,
u32 flags)
+{
- struct media_link *link;
- link = media_add_link(&intf->links);
- if (link == NULL)
return NULL;
- link->intf = intf;
- link->entity = entity;
- link->flags = flags;
- /* Initialize graph object embedded at the new link */
- media_gobj_init(intf->graph_obj.mdev, MEDIA_GRAPH_LINK,
&link->graph_obj);
- return link;
+} +EXPORT_SYMBOL_GPL(media_create_intf_link);
+static void __media_remove_intf_link(struct media_link *link) +{
- media_gobj_remove(&link->graph_obj);
- kfree(link);
+}
+void media_remove_intf_link(struct media_link *link) +{
- mutex_lock(&link->graph_obj.mdev->graph_mutex);
- __media_remove_intf_link(link);
- mutex_unlock(&link->graph_obj.mdev->graph_mutex);
+}
I think create and remove do not match well as a function pair performing the opposite operations. Instead, I'd use one of these:
- create / destroy
I always used remove as the opposite of create. Yet, a grep at include tells something:
$ git grep _create include|wc -l 810 $ git grep _remove include|wc -l 509 $ git grep _destroy include|wc -l 432
That doesn't yet tell whether they're even in the same files, or even then, related at all. They could be comments as well.
$ git grep add include |wc -l 12803
Looking at files that have functions endign with the suggested pairs of names:
$ git grep -l remove( include |xargs grep add( |wc -l 61 $ git grep -l create( include |xargs grep destroy( |wc -l 69 $ git grep -l init( include |xargs grep cleanup( |wc -l 87 $ git grep -l register( include |xargs grep unregister( |wc -l 294 $ git grep -l create( include |xargs grep remove( |wc -l 33
Of the last, I can find only these function pairs. Others are clearly unrelated.
pm_clk_create and pm_clk_remove, wakeup_source_create and wakeup_source_remove, proc_create and proc_remove, p9_client_create and p9_client_remove, cfcnfg_create and cfcnfg_remove, ore_create and ore_remove and snd_ctl_create and snd_ctl_remove
A closer look reveals that wakeup_source_remove() isn't actually related to wakeup_source_create() but wakeup_source_add() instead. Same for p9_client_create(): the opposite operation is p9_client_destroy(), not p9_client_remove(). pm_clk_create() is also related to pm_clk_destroy(), not pm_clk_remove(). Same for snd_ctl_create() and snd_ctl_remove(): they're not each others counter-operations.
So that leaves us with cfcnfg_create() and ore_create(). These are not exactly core kernel APIs. On the other hand, counterexamples are plentiful: I came up with more of those even when not looking for them.
It seems that most of the places use create/remove, yet, some places prefer create/destroy. So, I guess it is more a matter of personal taste.
Yet, at least on media, create/remove seems to be a lot more frequent:
$ git grep _remove drivers/media/|wc -l 732 $ git grep _destroy drivers/media/|wc -l 107
(this was measured without the MC next gen patches)
So, I prefer using create/remove on media, since it is used more than destroy.
- init / cleanup
- register / unregister
etc.
Interface is often shortened as "iface", I think I'd favour that instead. Up to you.
Intf is also used as a shortcut. Several drivers use it. I opted to use "intf". Actually, there are more occurrences of "intf" than "iface" at the media subsystem ;)
Ok.