@@ -779,10 +779,10 @@ int media_device_add_entity(struct media_device *media,
return 0;
}
-struct media_pad *media_parse_pad(struct media_device *media,
- const char *p, char **endp)
+struct media_entity *media_parse_entity(struct media_device *media,
+ const char *p, char **endp)
{
- unsigned int entity_id, pad;
+ unsigned int entity_id;
struct media_entity *entity;
char *end;
@@ -819,7 +819,27 @@ struct media_pad *media_parse_pad(struct media_device *media,
return NULL;
}
}
- for (; isspace(*end); ++end);
+ for (p = end; isspace(*p); ++p);
+
+ *endp = (char *)p;
+
+ return entity;
+}
+
+struct media_pad *media_parse_pad(struct media_device *media,
+ const char *p, char **endp)
+{
+ unsigned int pad;
+ struct media_entity *entity;
+ char *end;
+
+ if (endp == NULL)
+ endp = &end;
+
+ entity = media_parse_entity(media, p, &end);
+ if (!entity)
+ return NULL;
+ *endp = end;
if (*end != ':') {
media_dbg(media, "Expected ':'\n", *end);
@@ -368,6 +368,20 @@ int media_setup_link(struct media_device *media,
int media_reset_links(struct media_device *media);
/**
+ * @brief Parse string to an entity on the media device.
+ * @param media - media device.
+ * @param p - input string
+ * @param endp - pointer to string where parsing ended
+ *
+ * Parse NULL terminated string describing an entity and return its
+ * struct media_entity instance.
+ *
+ * @return Pointer to struct media_entity on success, NULL on failure.
+ */
+struct media_entity *media_parse_entity(struct media_device *media,
+ const char *p, char **endp);
+
+/**
* @brief Parse string to a pad on the media device.
* @param media - media device.
* @param p - input string