From patchwork Thu Feb 26 15:59:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 5894421 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3A6A4BF440 for ; Thu, 26 Feb 2015 16:00:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 710C9203A4 for ; Thu, 26 Feb 2015 16:00:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 33BD120274 for ; Thu, 26 Feb 2015 16:00:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754048AbbBZQAO (ORCPT ); Thu, 26 Feb 2015 11:00:14 -0500 Received: from mailout1.samsung.com ([203.254.224.24]:32180 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754526AbbBZQAL (ORCPT ); Thu, 26 Feb 2015 11:00:11 -0500 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NKD00A60Z4A5I40@mailout1.samsung.com> for linux-media@vger.kernel.org; Fri, 27 Feb 2015 01:00:10 +0900 (KST) X-AuditID: cbfee61a-f79c06d000004e71-ea-54ef43093d8f Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 2A.D0.20081.9034FE45; Fri, 27 Feb 2015 01:00:10 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NKD00448Z32VO60@mmp2.samsung.com>; Fri, 27 Feb 2015 01:00:09 +0900 (KST) From: Jacek Anaszewski To: linux-media@vger.kernel.org Cc: sakari.ailus@linux.intel.com, laurent.pinchart@ideasonboard.com, gjasny@googlemail.com, hdegoede@redhat.com, kyungmin.park@samsung.com Subject: [v4l-utils PATCH/RFC v5 03/14] mediactl: Separate entity and pad parsing Date: Thu, 26 Feb 2015 16:59:13 +0100 Message-id: <1424966364-3647-4-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1424966364-3647-1-git-send-email-j.anaszewski@samsung.com> References: <1424966364-3647-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprELMWRmVeSWpSXmKPExsVy+t9jQV0u5/chBmt2sFpMnzKL0eLN8elM Fmeb3rBbdE5cwm7Rs2Erq8WnLd+YHNg8nk6YzO4xu2Mmq8e8k4Ee7/ddZfPo27KK0ePzJrkA tigum5TUnMyy1CJ9uwSujJbJH9kLWkUqDu5rZ21gnCXQxcjJISFgItG3+jQLhC0mceHeerYu Ri4OIYHpjBKnlr9ngnDamSRuv/vHBlLFJmAo8fPFayYQW0RAXuJJ7w2wOLNAD6PEzRsBILaw QLDE+te7WEFsFgFViT3vjrOD2LwC7hKXDzcBxTmAtilIzJlkAxLmFPCQmPrlEyOILQRU8vXd crYJjLwLGBlWMYqmFiQXFCel5xrqFSfmFpfmpesl5+duYgSH1DOpHYwrGywOMQpwMCrx8CZk vwsRYk0sK67MPcQowcGsJMKrb/0+RIg3JbGyKrUoP76oNCe1+BCjNAeLkjivkn1biJBAemJJ anZqakFqEUyWiYNTqoFxqffiDVteO3z0Oph1WvTPF8ZfKQ8Oni9z+LZg2dGyfRM/niln1f9j drBhionLpNvl/huri3T7Fs2YFVfGVbzgoUvetRec2xk+txu8mxeveXv/rI+fq6/5f2ifM+Gd z95JJ1z3/RBIDSraK/X0sdI9u9V9Vgv6/h+afv5whJlr3LMpyZ85Ks2f1yqxFGckGmoxFxUn AgC2HfpgJQIAAA== 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 From: Sakari Ailus 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 4bb955f..bbaf387 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -766,10 +766,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; @@ -806,7 +806,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 77ac182..3faee71 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