From mboxrd@z Thu Jan 1 00:00:00 1970 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C371DC433F5 for ; Tue, 26 Oct 2021 19:21:18 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E2E83601FF for ; Tue, 26 Oct 2021 19:21:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E2E83601FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 16A8983395; Tue, 26 Oct 2021 21:21:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="XlIcSVQr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3FBE7833CB; Tue, 26 Oct 2021 21:21:13 +0200 (CEST) Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8FE1E83323 for ; Tue, 26 Oct 2021 21:21:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ilias.apalodimas@linaro.org Received: by mail-yb1-xb34.google.com with SMTP id r184so177890ybc.10 for ; Tue, 26 Oct 2021 12:21:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PjeEReYaceZ75PqGJN3k8jYzNgl4qvVE8CDfyS56DTA=; b=XlIcSVQr5979iYgyz1C84/kwtzBUSfezMxikbYsLPukG7PYzcH02Q5Oy1RoeI79Bjc K0zhAsYoouHUB7C2rOhKgkME5sTdTg4lYceBc6+aYZna81pPOf1hNbfE49U96ZV0uJr+ G8TlWY27qBkyo51PNtmvjMXyEuWN3l2Ng5nFqFflDRtb8IoTh8NngaEAC0a/hjzbZ8kO oAacU0Ddim6EC5fL4ZjMjumd/fy96qNDO0a8+wo/1CWQvKTjExWg1waoH9dvfv7xVPcI jQJEHQ+3y7XbrWS8yHeSWNPpHGxNcJp3mh1Hd3HDl3ysg6jRxJXD5lrOI2+OPpzJXvtW Nlfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PjeEReYaceZ75PqGJN3k8jYzNgl4qvVE8CDfyS56DTA=; b=xEKEX/DK0bAvwCPccUufkbaQ8XDhDPbnBITsUm+Lmp0WNyujb8yEOZellvppQT44lo 0ISndYyPzZlm6vZQcUxS08s1ux8bGYFHa/xYUB0Ewu+VezWeqRdKSO28mU0x2lqiN/VQ aOBA4XB4xIVL1Jt/B89km/vsrmdxuBBwebVrCXcqIym4imUKE44n0DKfFSEWbd08W08f pKxUpJHYWF7Q1whRoK4OqBveflmNXQNNUg4H/rpLkuFhNtwMGxmPfDapKUCmRKYH8tGb XC6ylUuJukwENG5kTTEQvkeX006agYCpLqvTG80jrBWOKIfcr+d7hxSQZUy9e6Kjr4e8 r5nw== X-Gm-Message-State: AOAM530csNo6pZB6Dp8k2x1iDEwxteKvYUzyDkxg8+EG6s/QPPgS5KIB hj3cuI2nqceNUCHtpP63E0BLj/eia20wrIqQ386KuA== X-Google-Smtp-Source: ABdhPJyjTMiI2MrfgS1zrGvyRiZKCla7H3cf8CGJYoPgTPsoVDgWH0NHAGnZ5hTcwnPfdxacUc5e2SVdfaODIiO8L+M= X-Received: by 2002:a25:4210:: with SMTP id p16mr27107928yba.242.1635276068284; Tue, 26 Oct 2021 12:21:08 -0700 (PDT) MIME-Version: 1.0 References: <20211023232635.9195-1-sjg@chromium.org> <20211023232635.9195-12-sjg@chromium.org> In-Reply-To: <20211023232635.9195-12-sjg@chromium.org> From: Ilias Apalodimas Date: Tue, 26 Oct 2021 22:20:32 +0300 Message-ID: Subject: Re: [PATCH v2 13/41] dm: core: Add a way to obtain a string list To: Simon Glass Cc: U-Boot Mailing List , Michal Simek , Heinrich Schuchardt , Tom Rini , Daniel Schwierzeck , Steffen Jaeckel , =?UTF-8?B?TWFyZWsgQmVow7pu?= , Lukas Auer , Dennis Gilmore , Marek Vasut , Pavel Herrmann Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean On Sun, 24 Oct 2021 at 02:26, Simon Glass wrote: > > At present we support reading a string list a string at a time. Apart > from being inefficient, this makes it impossible to separate reading of > the devicetree into the of_to_plat() method where it belongs, since any > code which needs access to the string must read it from the devicetree. > > Add a function which returns the string property as an array of pointers > to the strings, which is easily used by clients. > > Signed-off-by: Simon Glass > --- > > (no changes since v1) > > drivers/core/ofnode.c | 26 ++++++++++++++++++++++++++ > drivers/core/read.c | 6 ++++++ > include/dm/ofnode.h | 20 ++++++++++++++++++++ > include/dm/read.h | 28 ++++++++++++++++++++++++++++ > test/dm/ofnode.c | 20 ++++++++++++++++++++ > 5 files changed, 100 insertions(+) > > diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c > index 08705ef8d99..709bea272a6 100644 > --- a/drivers/core/ofnode.c > +++ b/drivers/core/ofnode.c > @@ -456,6 +456,32 @@ int ofnode_read_string_count(ofnode node, const char *property) > } > } > > +int ofnode_read_string_list(ofnode node, const char *property, > + const char ***listp) > +{ > + const char **prop; > + int count; > + int i; > + > + *listp = NULL; > + count = ofnode_read_string_count(node, property); > + if (count < 0) > + return count; > + if (!count) > + return 0; Those can fold into a single if and always return 'count'. if (count <= 0) return count; > + > + prop = calloc(count + 1, sizeof(char *)); [...] Regards /Ilias