From patchwork Mon Aug 22 18:22:22 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benoit Cousson X-Patchwork-Id: 1086082 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7MIMglE005437 for ; Mon, 22 Aug 2011 18:22:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752626Ab1HVSWm (ORCPT ); Mon, 22 Aug 2011 14:22:42 -0400 Received: from arroyo.ext.ti.com ([192.94.94.40]:47487 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751174Ab1HVSWk (ORCPT ); Mon, 22 Aug 2011 14:22:40 -0400 Received: from dlep34.itg.ti.com ([157.170.170.115]) by arroyo.ext.ti.com (8.13.7/8.13.7) with ESMTP id p7MIMaZZ023970 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 22 Aug 2011 13:22:36 -0500 Received: from dlep26.itg.ti.com (smtp-le.itg.ti.com [157.170.170.27]) by dlep34.itg.ti.com (8.13.7/8.13.8) with ESMTP id p7MIMafM028740; Mon, 22 Aug 2011 13:22:36 -0500 (CDT) Received: from DFLE71.ent.ti.com (localhost [127.0.0.1]) by dlep26.itg.ti.com (8.13.8/8.13.8) with ESMTP id p7MIMard000796; Mon, 22 Aug 2011 13:22:36 -0500 (CDT) Received: from dlelxv22.itg.ti.com (172.17.1.197) by dfle71.ent.ti.com (128.247.5.62) with Microsoft SMTP Server id 14.1.323.3; Mon, 22 Aug 2011 13:22:36 -0500 Received: from localhost.localdomain (lncpu04.tif.ti.com [137.167.102.15]) by dlelxv22.itg.ti.com (8.13.8/8.13.8) with ESMTP id p7MIMVue016901; Mon, 22 Aug 2011 13:22:34 -0500 From: Benoit Cousson To: CC: , , , , Benoit Cousson Subject: [RFC PATCH 2/3] OMAP: omap_device: Add a DT parser for multiple strings Date: Mon, 22 Aug 2011 20:22:22 +0200 Message-ID: <1314037343-19783-3-git-send-email-b-cousson@ti.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1314037343-19783-1-git-send-email-b-cousson@ti.com> References: <1314037343-19783-1-git-send-email-b-cousson@ti.com> MIME-Version: 1.0 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 22 Aug 2011 18:22:43 +0000 (UTC) Add two helpers function to parse a property that contains multiple strings. These functions might be exported and moved to a common place if they can to be useful elsewhere. Signed-off-by: Benoit Cousson Cc: Kevin Hilman --- arch/arm/plat-omap/omap_device.c | 39 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) diff --git a/arch/arm/plat-omap/omap_device.c b/arch/arm/plat-omap/omap_device.c index 752d72a..70361f8 100644 --- a/arch/arm/plat-omap/omap_device.c +++ b/arch/arm/plat-omap/omap_device.c @@ -315,6 +315,45 @@ static void _add_hwmod_clocks_clkdev(struct omap_device *od, _add_clkdev(od, oh->opt_clks[i].role, oh->opt_clks[i].clk); } +/* + * XXX: DT helper functions that should probably move elsewhere if + * they become usefull for other needs. + */ +static int _dt_count_property_string(const char *prop, int len) +{ + int i = 0; + size_t l = 0, total = 0; + + if (!prop || !len) + return -EINVAL; + + for (i = 0; len >= total; total += l, prop += l) { + l = strlen(prop) + 1; + if (*prop != 0) + i++; + } + return i; +} + +static int _dt_get_property(const char *prop, int len, int index, char *output, + int size) +{ + int i = 0; + size_t l = 0, total = 0; + + if (!prop || !len) + return -EINVAL; + + for (i = 0; len >= total; total += l, prop += l) { + l = strlcpy(output, prop, size) + 1; + if (*prop != 0) { + if (i++ == index) + return 0; + } + } + return -ENODEV; +} + /* Public functions for use by core code */