From patchwork Fri Mar 25 11:31:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= X-Patchwork-Id: 12791502 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AD08C43217 for ; Fri, 25 Mar 2022 11:34:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355971AbiCYLfl (ORCPT ); Fri, 25 Mar 2022 07:35:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232143AbiCYLfk (ORCPT ); Fri, 25 Mar 2022 07:35:40 -0400 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06998A995C; Fri, 25 Mar 2022 04:34:05 -0700 (PDT) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id CD46820012; Fri, 25 Mar 2022 11:34:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1648208044; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7h5U+Wv/MCPvlMQZC9RddFjnnGvegr7ExkBEVjPAZkg=; b=oUisZjuRnZzAKfKfHS3IZA9SPvSHB+yh+uf4+RJ97ZHAowKVOSJ0hubxoeLZB177rqgqtJ 3AIHilOvwZEFzWDXX6IFKmLhGoX5qdlQ07raXrZN6wJTL/R9o5S5coNj7/rZ8tdtITlAQf kZWjmyBB+xoqe3030lR5tMhQGA5/ZkXOTUhbDpGLuqZBdlTedzhdua5Hlt6b7DDM71LjDo pAGggGuXsZWc+3FSJEzws13t4D0r71RBAUn6BakSWIpwvou3TCP3yXieLqhXQLlieS0cP6 /jqqJc8yU2M75s5Z5WjmYypBsdjKJ3TjFD7q+UUzMJwal/WetMDeHyFbbc061A== From: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= To: Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , Greg Kroah-Hartman , "Rafael J . Wysocki" , Wolfram Sang , Peter Rosin , Rob Herring , Frank Rowand , Len Brown Cc: Hans de Goede , Thomas Petazzoni , Alexandre Belloni , Allan Nielsen , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, =?utf-8?b?Q2zDqW1lbnQgTMOpZ2Vy?= Subject: [PATCH v3 1/9] of: add of_property_read_string_array_index() Date: Fri, 25 Mar 2022 12:31:40 +0100 Message-Id: <20220325113148.588163-2-clement.leger@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220325113148.588163-1-clement.leger@bootlin.com> References: <20220325113148.588163-1-clement.leger@bootlin.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Add of_property_read_string_array_index() which allows to read a string array starting at a specific index. Signed-off-by: Clément Léger Reviewed-by: Rob Herring --- include/linux/of.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/linux/of.h b/include/linux/of.h index 2dc77430a91a..93f04c530bd1 100644 --- a/include/linux/of.h +++ b/include/linux/of.h @@ -1115,6 +1115,28 @@ static inline int of_property_read_string_array(const struct device_node *np, return of_property_read_string_helper(np, propname, out_strs, sz, 0); } +/** + * of_property_read_string_array_index() - Read an array of strings from a + * multiple strings property starting at a specified index + * @np: device node from which the property value is to be read. + * @propname: name of the property to be searched. + * @out_strs: output array of string pointers. + * @sz: number of array elements to read. + * @index: index to start reading from + * + * Search for a property in a device tree node and retrieve a list of + * terminated string values (pointer to data, not a copy) in that property + * starting at specified index. + * + * Return: If @out_strs is NULL, the number of strings in the property is returned. + */ +static inline int of_property_read_string_array_index(const struct device_node *np, + const char *propname, + const char **out_strs, + size_t sz, int index) +{ + return of_property_read_string_helper(np, propname, out_strs, sz, index); +} /** * of_property_count_strings() - Find and return the number of strings from a * multiple strings property.