From patchwork Thu Nov 6 10:11:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacek Anaszewski X-Patchwork-Id: 5240671 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 CD207C11AC for ; Thu, 6 Nov 2014 10:12:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D918E2010C for ; Thu, 6 Nov 2014 10:12:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A5BF920107 for ; Thu, 6 Nov 2014 10:12:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751692AbaKFKMH (ORCPT ); Thu, 6 Nov 2014 05:12:07 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:40304 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751249AbaKFKMG (ORCPT ); Thu, 6 Nov 2014 05:12:06 -0500 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NEM00G404BYWSC0@mailout2.samsung.com> for linux-media@vger.kernel.org; Thu, 06 Nov 2014 19:11:58 +0900 (KST) X-AuditID: cbfee61b-f79d76d0000024d6-d2-545b496dfe9f Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id AE.A1.09430.D694B545; Thu, 06 Nov 2014 19:11:58 +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 <0NEM00DZ94BK47N0@mmp2.samsung.com>; Thu, 06 Nov 2014 19:11:57 +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, sakari.ailus@linux.intel.com, kyungmin.park@samsung.com Subject: [v4l-utils RFC v3 02/11] mediactl: Separate entity and pad parsing Date: Thu, 06 Nov 2014 11:11:33 +0100 Message-id: <1415268702-23685-3-git-send-email-j.anaszewski@samsung.com> X-Mailer: git-send-email 1.7.9.5 In-reply-to: <1415268702-23685-1-git-send-email-j.anaszewski@samsung.com> References: <1415268702-23685-1-git-send-email-j.anaszewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprJLMWRmVeSWpSXmKPExsVy+t9jQd08z+gQg4aJrBYbZ6xntZg+ZRaj xZKfu5gs3hyfzmRxtukNu0XPhq2sFhfXyVt82vKNyYHDY8rvjaweTydMZveYdzLQ4/2+q2we fVtWMXp83iQXwBbFZZOSmpNZllqkb5fAlXFj4wnGglaRist7FBsYZwl0MXJwSAiYSPStMupi 5AQyxSQu3FvP1sXIxSEkMJ1R4uD/fnYIp51J4t2nv6wgVWwChhI/X7xmArFFBOQlnvTeYAOx mQU2M0qsO1UCYgsLeEucblrEDmKzCKhK9D/6zgJi8wp4SCzaO5sFYrGCxJxJNiBhTgFPidlH T4CVCwGVzPhwgm0CI+8CRoZVjKKpBckFxUnpuUZ6xYm5xaV56XrJ+bmbGMEB9kx6B+OqBotD jAIcjEo8vDuORoUIsSaWFVfmHmKU4GBWEuFVcIwOEeJNSaysSi3Kjy8qzUktPsQozcGiJM57 sNU6UEggPbEkNTs1tSC1CCbLxMEp1cDo/ODgv4SUF3tmZc7ReuQyjX17CPcc3UZ297/8O1Wm H7zza/nUT5mdGpEXLuZe8Pty8k/WxkuC3s2y3vkdAlyhV1xyT5huOXnqdKh3FnfbsZLC048N 7Bx8bt2c/fZo5acDveH95ue9UyfJLP6clFi+bH+G7ImbgafWL484cDKV5RvbHTuNSHEhJZbi jERDLeai4kQADj/K+ywCAAA= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.5 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 795aaad..b549a90 100644 --- a/utils/media-ctl/libmediactl.c +++ b/utils/media-ctl/libmediactl.c @@ -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); diff --git a/utils/media-ctl/mediactl.h b/utils/media-ctl/mediactl.h index e358242..5246978 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