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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id B4E7CC433EF for ; Wed, 24 Nov 2021 22:24:56 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 994288377E; Wed, 24 Nov 2021 23:24:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="bogAFHJ3"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EDD3183711; Wed, 24 Nov 2021 23:23:21 +0100 (CET) Received: from mail-ua1-x92b.google.com (mail-ua1-x92b.google.com [IPv6:2607:f8b0:4864:20::92b]) (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 13F398371F for ; Wed, 24 Nov 2021 23:23:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-ua1-x92b.google.com with SMTP id i6so8258645uae.6 for ; Wed, 24 Nov 2021 14:23:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=y7x/Qv3YIHvvCVawOQSZoNxWOpZxt4yIgHAT7jVp3CM=; b=bogAFHJ33CuzGRNilXy/3s/mZi2SHC2fWs5QciyBsCJ6lDV9QZElmo+Lzt/Jx6ezSb /Q4wR8kx2t8u3/zOhfs9Xkd/PGwQHPaSA8fy3IWUZicJHvRTpZLV1XookZiNSg1GnU3N 0jjDFVoXL89k5URir/wginYyTKLgIHILInLPo= 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=y7x/Qv3YIHvvCVawOQSZoNxWOpZxt4yIgHAT7jVp3CM=; b=40gK3n5yIEqEzY5giEptbXpgH4bP9ITH/NgKfzEuZe5BIXfv5EXaF+1sXyMD1af63v 1KflduOa2+t4DHhDBp1ltjjDzZdIQCpw7h5RI448xrXrINDEt6dYI2KRT4k+cOTWbqBA ul/x7feq8ALrp7GW2ASA6xiF7CBWvV3t91vbChkBSyqQkuLK87ihkxoEuyRX/P9rpsJJ NQxKidTTFGiIR2kO91rdYCVIHT4hktonYFcVSScicDtBPc+p4osnsOO0Eb3rAV8ztxlh Kd+WlJBYoxs+PrbYGe23DPjnuqQtTNCLaWBtbHKknjDARMktZ3ibTAJuNUAga3t/ll9/ Jx2w== X-Gm-Message-State: AOAM532CGsXqI3tXlr1NUDz6TBtru3sic6iL13Gxh9iArela/U0X/yqq dJa8OJT25NdZDM+Ot6/Cc/hTkvNHBpgV+BMPNF7On9ClEMI= X-Google-Smtp-Source: ABdhPJwJRnUmtsapHJcnnFGV5jpr3mylcaRLfllfZ6gv4mZg2W+x2vDtJY5J8ue7Dj2xYlhaEl/xnxLsYiygWADLiT0= X-Received: by 2002:a67:e109:: with SMTP id d9mr751753vsl.19.1637792595659; Wed, 24 Nov 2021 14:23:15 -0800 (PST) MIME-Version: 1.0 References: <20211023232635.9195-1-sjg@chromium.org> <20211023232635.9195-12-sjg@chromium.org> In-Reply-To: From: Simon Glass Date: Wed, 24 Nov 2021 15:23:04 -0700 Message-ID: Subject: Re: [PATCH v2 13/41] dm: core: Add a way to obtain a string list To: Ilias Apalodimas 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.37 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 Hi Ilias, On Tue, 26 Oct 2021 at 13:21, Ilias Apalodimas wrote: > > 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; Yes, but I prefer to deal with errors separately. The first case is an error. > > > + > > + prop = calloc(count + 1, sizeof(char *)); > [...] Regards, Simon