media-ctl: subdev: add Y8 format.
[media-ctl.git] / media.c
diff --git a/media.c b/media.c
index 813a38f..d5d98de 100644 (file)
--- a/media.c
+++ b/media.c
@@ -82,12 +82,12 @@ static const char *media_entity_subtype_to_string(unsigned type)
 
        switch (type & MEDIA_ENTITY_TYPE_MASK) {
        case MEDIA_ENTITY_TYPE_NODE:
-               if (subtype > ARRAY_SIZE(node_types))
+               if (subtype >= ARRAY_SIZE(node_types))
                        subtype = 0;
                return node_types[subtype];
 
        case MEDIA_ENTITY_TYPE_SUBDEV:
-               if (subtype > ARRAY_SIZE(subdev_types))
+               if (subtype >= ARRAY_SIZE(subdev_types))
                        subtype = 0;
                return subdev_types[subtype];
        default:
@@ -424,11 +424,11 @@ static int media_enum_links(struct media_device *media)
                                        id, i, link->source.entity, link->source.index,
                                        link->sink.entity, link->sink.index);
                                ret = -EINVAL;
+                       } else {
+                               entity->links[i].source = &source->pads[link->source.index];
+                               entity->links[i].sink = &sink->pads[link->sink.index];
+                               entity->links[i].flags = links.links[i].flags;
                        }
-
-                       entity->links[i].source = &source->pads[link->source.index];
-                       entity->links[i].sink = &sink->pads[link->sink.index];
-                       entity->links[i].flags = links.links[i].flags;
                }
 
                free(links.pads);