From patchwork Mon Jan 18 16:17:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 8055951 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 A1293BEEE5 for ; Mon, 18 Jan 2016 16:18:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C83CE204A9 for ; Mon, 18 Jan 2016 16:18:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D40D3204AE for ; Mon, 18 Jan 2016 16:18:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755839AbcARQSK (ORCPT ); Mon, 18 Jan 2016 11:18:10 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:34447 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755832AbcARQSI (ORCPT ); Mon, 18 Jan 2016 11:18:08 -0500 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O1500V03PA7N320@mailout3.samsung.com> for linux-media@vger.kernel.org; Tue, 19 Jan 2016 01:18:07 +0900 (KST) X-AuditID: cbfee61a-f79266d000003652-f7-569d103fa28e Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id D4.31.13906.F301D965; Tue, 19 Jan 2016 01:18:07 +0900 (KST) Received: from AMDC2362.DIGITAL.local ([106.120.53.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O15003TLP9I9Y00@mmp2.samsung.com>; Tue, 19 Jan 2016 01:18:07 +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, hverkuil@xs4all.nl Subject: [PATCH 03/15] mediactl: Separate entity and pad parsing Date: Mon, 18 Jan 2016 17:17:28 +0100 Message-id: <1453133860-21571-4-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1453133860-21571-1-git-send-email-j.anaszewski@samsung.com> References: <1453133860-21571-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKLMWRmVeSWpSXmKPExsVy+t9jQV17gblhBquvGFtMnzKL0eLN8elM FqcmP2Oy6Jy4hN2iZ8NWVotPW74xObB5PJ0wmd1jdsdMVo95JwM93u+7yubxeZOcx6mvn9kD 2KK4bFJSczLLUov07RK4MtrvHmAvaBWpOPdQoIFxlkAXIyeHhICJxJR7/WwQtpjEhXvrgWwu DiGBWYwSSzdfZ4ZwfjJKXGydywJSxSZgKPHzxWsmEFtEQF7iSe8NsA5mgVZGiTPHrzGDJIQF HCQm7/zPDmKzCKhKnDn8FszmFfCQmHRiE9AgDqB1ChJzJtmAhDkFPCXe3NwPdoUQUMmBu1uZ JzDyLmBkWMUokVqQXFCclJ5rmJdarlecmFtcmpeul5yfu4kRHFjPpHYwHtzlfohRgINRiYfX 4ezsMCHWxLLiytxDjBIczEoivIc45oYJ8aYkVlalFuXHF5XmpBYfYpTmYFES5629FBkmJJCe WJKanZpakFoEk2Xi4JRqYIwpXnhmk9jtMPvimL1XE63f6DgeOHn3yrRTJ15esj2u2KXNL33f gOEJe1Ts8rw3c5vKNuy+Z9s06TKzhexpo3lFU84z/zh+tEX8delc6TmsD5X3L+bnDZWtrXCe 6jrtmdIRvnLGYH2edd3Fi15q9r4/lbXty0S3dIayWefOHgyd/HRya8GnlFlKLMUZiYZazEXF iQAI0MISKAIAAA== 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, 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 7e98440..61b5f50 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -781,10 +781,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; @@ -821,7 +821,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