Re: [PATCH RFC v3 10/16] media: rename link source/sink to pad0_source/pad1_sink

2015-08-13 Thread Hans Verkuil
On 08/12/15 22:14, Mauro Carvalho Chehab wrote:
 Change the internal namespace for links between two pads to
 have the pad there.
 
 We're also numbering it, as a common constructor is to do
 things like:
 
   if (link-port1.type != MEDIA_GRAPH_PAD)
   continue;
   if (link-pad1_sink-entity == entity)
   /* do something */
 
 by preserving the number, we keep consistency between
 port1 and pad1_sink, and port0 and pad0_source.

I would really leave this patch out. As long as sink and source are consistently
used for pads (and they are), then I see no benefit at all to this change.

Another reason why I don't like this is that pad0_ and pad1_ are actually
confusing since they suggested to me when I first read it that pad0_ referred to
the pad with index 0 and pad1_ referred to the pad with index 1.

That's obviously not the case, but it does mean that the prefix doesn't really
make things clearer.

I would just stick with source and sink.

Regards,

Hans
--
To unsubscribe from this list: send the line unsubscribe linux-samsung-soc in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH RFC v3 10/16] media: rename link source/sink to pad0_source/pad1_sink

2015-08-12 Thread Mauro Carvalho Chehab
Change the internal namespace for links between two pads to
have the pad there.

We're also numbering it, as a common constructor is to do
things like:

if (link-port1.type != MEDIA_GRAPH_PAD)
continue;
if (link-pad1_sink-entity == entity)
/* do something */

by preserving the number, we keep consistency between
port1 and pad1_sink, and port0 and pad0_source.

This was generated via this script:
for i in $(find drivers/media -name '*.[ch]' -type f) $(find 
drivers/staging/media -name '*.[ch]' -type f) $(find include/ -name '*.h' -type 
f) ; do sed s,link-sink,link-pad1_sink,g; 
s,link-source,link-pad0_source,g; $i a  mv a $i; done

Signed-off-by: Mauro Carvalho Chehab mche...@osg.samsung.com

diff --git a/drivers/media/dvb-core/dvb_frontend.c 
b/drivers/media/dvb-core/dvb_frontend.c
index 3c97ebdf9f2a..e673f6f7c398 100644
--- a/drivers/media/dvb-core/dvb_frontend.c
+++ b/drivers/media/dvb-core/dvb_frontend.c
@@ -637,7 +637,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
link = entity-links[i];
if (link-port1.type != MEDIA_GRAPH_PAD)
continue;
-   if (link-sink-entity == entity) {
+   if (link-pad1_sink-entity == entity) {
found_link = link;
n_links++;
if (link-flags  MEDIA_LNK_FL_ENABLED)
@@ -660,7 +660,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
return -EINVAL;
}
 
-   source = found_link-source-entity;
+   source = found_link-pad0_source-entity;
fepriv-pipe_start_entity = source;
for (i = 0; i  source-num_links; i++) {
struct media_entity *sink;
@@ -669,7 +669,7 @@ static int dvb_enable_media_tuner(struct dvb_frontend *fe)
link = source-links[i];
if (link-port1.type != MEDIA_GRAPH_PAD)
continue;
-   sink = link-sink-entity;
+   sink = link-pad1_sink-entity;
 
if (sink == entity)
flags = MEDIA_LNK_FL_ENABLED;
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c
index b4bd718ad736..2c29c4600c3a 100644
--- a/drivers/media/media-device.c
+++ b/drivers/media/media-device.c
@@ -160,13 +160,13 @@ static long __media_device_enum_links(struct media_device 
*mdev,
ent_link-port1-type != MEDIA_GRAPH_PAD)
continue;
/* Ignore backlinks. */
-   if (ent_link-source-entity != entity)
+   if (ent_link-pad0_source-entity != entity)
continue;
 
memset(link, 0, sizeof(link));
-   media_device_kpad_to_upad(ent_link-source,
+   media_device_kpad_to_upad(ent_link-pad0_source,
  link.source);
-   media_device_kpad_to_upad(ent_link-sink,
+   media_device_kpad_to_upad(ent_link-pad1_sink,
  link.sink);
link.flags = ent_link-flags;
if (copy_to_user(ulink, link, sizeof(*ulink)))
diff --git a/drivers/media/media-entity.c b/drivers/media/media-entity.c
index fc2e4886c830..aafa1119fba7 100644
--- a/drivers/media/media-entity.c
+++ b/drivers/media/media-entity.c
@@ -125,10 +125,10 @@ media_entity_other(struct media_entity *entity, struct 
media_link *link)
if (link-port0-type != MEDIA_GRAPH_PAD ||
link-port1-type != MEDIA_GRAPH_PAD)
return NULL;
-   if (link-source-entity == entity)
-   return link-sink-entity;
+   if (link-pad0_source-entity == entity)
+   return link-pad1_sink-entity;
else
-   return link-source-entity;
+   return link-pad0_source-entity;
 }
 
 /* push an entity to traversal stack */
@@ -299,8 +299,8 @@ __must_check int media_entity_pipeline_start(struct 
media_entity *entity,
if (link-port0-type != MEDIA_GRAPH_PAD)
continue;
 
-   pad = link-sink-entity == entity
-   ? link-sink : link-source;
+   pad = link-pad1_sink-entity == entity
+   ? link-pad1_sink : link-pad0_source;
 
/* Mark that a pad is connected by a link. */
bitmap_clear(has_no_links, pad-index, 1);
@@ -318,7 +318,7 @@ __must_check int media_entity_pipeline_start(struct 
media_entity *entity,
 * Link validation will only take place for
 * sink ends of the link that are enabled.
 */
-   if (link-sink != pad ||
+