From patchwork Fri Nov 21 16:14:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 5356021 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D0E45C11AC for ; Fri, 21 Nov 2014 16:15:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0A266201B4 for ; Fri, 21 Nov 2014 16:15:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7178C20172 for ; Fri, 21 Nov 2014 16:15:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758568AbaKUQPE (ORCPT ); Fri, 21 Nov 2014 11:15:04 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:9520 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758534AbaKUQPC (ORCPT ); Fri, 21 Nov 2014 11:15:02 -0500 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NFE00F2DD51CU40@mailout3.samsung.com> for linux-media@vger.kernel.org; Sat, 22 Nov 2014 01:15:01 +0900 (KST) X-AuditID: cbfee61b-f79d76d0000024d6-e0-546f6504cdc5 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 9B.CE.09430.4056F645; Sat, 22 Nov 2014 01:15:01 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NFE00IXRD4IRL40@mmp1.samsung.com>; Sat, 22 Nov 2014 01:15:00 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: m.chehab@samsung.com, gjasny@googlemail.com, hdegoede@redhat.com, hans.verkuil@cisco.com, b.zolnierkie@samsung.com, kyungmin.park@samsung.com, sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, Jacek Anaszewski Subject: [PATCH/RFC v4 03/11] mediactl: Separate entity and pad parsing Date: Fri, 21 Nov 2014 17:14:32 +0100 Message-id: <1416586480-19982-4-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1416586480-19982-1-git-send-email-j.anaszewski@samsung.com> References: <1416586480-19982-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJLMWRmVeSWpSXmKPExsVy+t9jAV3W1PwQg7NP2Cw2zljPajF9yixG iyU/dzFZvDk+ncmi9+pzRouzTW/YLTonLmG36NmwldXi4jp5i09bvjE5cHlM+b2R1ePphMns HrM7ZrJ6zDsZ6PF+31U2j74tqxg9Pm+SC2CP4rJJSc3JLEst0rdL4MrY2DuTqeCCcMWMNy3s DYxv+LsYOTgkBEwkzkwFMjmBTDGJC/fWs3UxcnEICSxilNhxdB0LSEJIoJ1J4s++ChCbTcBQ 4ueL10wgtoiAvMST3htgDcwCrUwS05oesIMkhAXcJd4d62QDsVkEVCXaHmxiBbF5BTwkjl99 wwKxWEFiziQbkDCngKfE5mv32CF2eUjcm7OdbQIj7wJGhlWMoqkFyQXFSem5RnrFibnFpXnp esn5uZsYwQH4THoH46oGi0OMAhyMSjy8H6bnhQixJpYVV+YeYpTgYFYS4S0Xzg8R4k1JrKxK LcqPLyrNSS0+xCjNwaIkznvjZm6IkEB6YklqdmpqQWoRTJaJg1OqgVGv9cvn1tCjH5yPSrHP r1vCe9/iAcsFrzdCHPcXv957X31SaMZy2TBVgeK1SjzXej3iYo2N4sMvxjxiko/2unpo3e8T 347s29ftWzKj9Orx/6cZtvzku52YsGu+q1jgD6v4sx57pf4prNg2QV/Xa9di7Y1V3zZrzugx mVL/rPnUpbJbW3ZcveqlxFKckWioxVxUnAgA3zXGlzwCAAA= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Sometimes it's useful to be able to parse the entity independent of the pad. Separate entity parsing into media_parse_entity(). Signed-off-by: Sakari Ailus --- utils/media-ctl/libmediactl.c | 28 ++++++++++++++++++++++++---- utils/media-ctl/mediactl.h | 14 ++++++++++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/utils/media-ctl/libmediactl.c b/utils/media-ctl/libmediactl.c index 4c4ddbe..af7dd43 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -787,10 +787,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; @@ -827,7 +827,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); diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h index b8cefe8..7309b16 100644 --- a/utils/media-ctl/mediactl.h +++ b/utils/media-ctl/mediactl.h @@ -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