Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp320984rdb; Fri, 6 Oct 2023 04:49:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEkd09taITjM4CD+PfLAgHVNO7AYITnEo1sSeMeoLoz8483mnnnjy5FB4PkxyAzkM51OOm3 X-Received: by 2002:a17:903:41c1:b0:1c6:30d1:7214 with SMTP id u1-20020a17090341c100b001c630d17214mr8501996ple.55.1696592965264; Fri, 06 Oct 2023 04:49:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696592965; cv=none; d=google.com; s=arc-20160816; b=yBfAqEEIIayAQ8mmRoIhaIxbjdwZ70f1xb3wB2CBsXgljF4pmtsIj5dD/IsIBwwueA 6tOO/rbe7121QHHMKI0PXH66x8fW6hr90uDljq92Y4G9S2xKwVdNNDBRdVEmn8GORr/G L1D6yKQhrQNFoPxmq7V5YpH6/6nw7FzfFFOOMqukZsHMvtp+n0KH6Go21lkTc57Zgtub 4LJbMrZYsYWgmEwoANlPszIdJ7ELP6rMl8lJEEy42IAfzVJU4FDQefr9Q7GHHBV67vbG nHmLWbtNwUTKL5t+GNsHmuM6l4V508tcWyPqoK81I/bzF7gEZFjooJ+wnRuj20pApR8z IkbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:message-id:user-agent :references:in-reply-to:subject:cc:to:from:date:mime-version; bh=C42ubWhziMIXoKYZCVLes95QSGDWPrjbHHwhLWZ3J/w=; fh=XLEdng55uEX8WXP17XyDtpFUsiJQ1vCFJ8oTq/S3wF4=; b=L1m2nffL+N2q1i8dZunB334rnW4D/T4vk3g3xaUyM2wjuhVUc5DZO5QGepCJT6LBM2 Atv0h/huMiF/C0yFTZ4kaNFJeHH6oUoroPG3gFEzBQ58W/g4rBTuTr42gJWS9tvlZSJ3 5pGW16Zqi+iv18lYb5iSxvssboO6m7nO9Gv1h4CrxwkF7NUZfsmt3Kz/6Ns3TAAKZCsb j1oODldv8lj/SFRsqmf9fHtIo85jMTE0ZX4TUjWbhV3t6rs9NuAXRKUjaFMhgMMQJuep pRTvjfaC7t99HdMFkB5EnNzYvJuWPilB4sWUIO1dBALDG/mO6iO//mY1yOB7GPdu/bL1 2hwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id kn13-20020a170903078d00b001bbd81eaabasi3469372plb.57.2023.10.06.04.49.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 04:49:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id C4B2282589B6; Fri, 6 Oct 2023 04:49:20 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231693AbjJFLtB (ORCPT + 99 others); Fri, 6 Oct 2023 07:49:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232125AbjJFLs7 (ORCPT ); Fri, 6 Oct 2023 07:48:59 -0400 Received: from 10.mo575.mail-out.ovh.net (10.mo575.mail-out.ovh.net [46.105.79.203]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75071CE for ; Fri, 6 Oct 2023 04:48:57 -0700 (PDT) Received: from director5.ghost.mail-out.ovh.net (unknown [10.109.146.20]) by mo575.mail-out.ovh.net (Postfix) with ESMTP id A61CC2A376 for ; Fri, 6 Oct 2023 11:41:54 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-9dvr6 (unknown [10.110.115.40]) by director5.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 895271FE57; Fri, 6 Oct 2023 11:41:52 +0000 (UTC) Received: from RCM-web7.webmail.mail.ovh.net ([151.80.29.19]) by ghost-submission-6684bf9d7b-9dvr6 with ESMTPSA id oZtWH4DyH2Xt2T8A6QqK6A (envelope-from ); Fri, 06 Oct 2023 11:41:52 +0000 MIME-Version: 1.0 Date: Fri, 06 Oct 2023 13:41:52 +0200 From: =?UTF-8?Q?Rafa=C5=82_Mi=C5=82ecki?= To: Miquel Raynal Cc: Srinivas Kandagatla , Greg Kroah-Hartman , Michael Walle , Rob Herring , Frank Rowand , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Robert Marko , Thomas Petazzoni , Luka Perkov , Randy Dunlap , Chen-Yu Tsai , Daniel Golle Subject: Re: [PATCH v12 2/7] nvmem: Clarify the situation when there is no DT node available In-Reply-To: <20231005155907.2701706-3-miquel.raynal@bootlin.com> References: <20231005155907.2701706-1-miquel.raynal@bootlin.com> <20231005155907.2701706-3-miquel.raynal@bootlin.com> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <05cd4592d0cfe0fb86aeb24db01de547@milecki.pl> X-Sender: rafal@milecki.pl X-Originating-IP: 31.11.218.106 X-Webmail-UserID: rafal@milecki.pl Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Ovh-Tracer-Id: 17474529506700995485 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvkedrgeeigdegvdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemucehtddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpeggfffhvfevufgjfhgfkfigihgtgfesthekjhdttderjeenucfhrhhomheptfgrfhgrlhcuofhilhgvtghkihcuoehrrghfrghlsehmihhlvggtkhhirdhplheqnecuggftrfgrthhtvghrnhepgffhueeihfeitdettdehfefhieefffevkedvgeetteekteejtdeivddvhffgffffnecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucfkphepuddvjedrtddrtddruddpfedurdduuddrvddukedruddtiedpudehuddrkedtrddvledrudelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeorhgrfhgrlhesmhhilhgvtghkihdrphhlqedpnhgspghrtghpthhtohepuddprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdpoffvtefjohhsthepmhhoheejhedpmhhouggvpehsmhhtphhouhht X-Spam-Status: No, score=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 06 Oct 2023 04:49:20 -0700 (PDT) X-Spam-Level: ** On 2023-10-05 17:59, Miquel Raynal wrote: > At a first look it might seem that the presence of the of_node pointer > in the nvmem device does not matter much, but in practice, after > looking > deep into the DT core, nvmem_add_cells_from_dt() will simply and always > return NULL if this field is not provided. As most mtd devices don't > populate this field (this could evolve later), it means none of their > children cells will be populated unless no_of_node is explicitly set to > false. In order to clarify the logic, let's add clear check at the > beginning of this helper. I'm somehow confused by above explanation and code too. I read it carefully 5 times but I can't see what exactly this change helps with. At first look at nvmem_add_cells_from_legacy_of() I can see it uses "of_node" so I don't really agree with "it might seem that the presence of the of_node pointer in the nvmem device does not matter much". You really don't need to look deep into DT core (actually you don't have to look into it at all) to understand that nvmem_add_cells_from_dt() will return 0 (nitpicking: not NULL) for a NULL pointer. It's all made of for_each_child_of_node(). Obviously it does nothing if there is nothing to loop over. Given that for_each_child_of_node() is NULL-safe I think code from this patch is redundant. Later you mention "no_of_node" which I agree to be a very non-intuitive config option. As pointed in another thread I already sent: [PATCH] Revert "nvmem: add new config option" https://lore.kernel.org/lkml/ba3c419a-6511-480a-b5f2-6c418f9c02e7@gmail.com/t/ Maybe with above patch finally things will get more clear and we don't need this PATCH after all? > Signed-off-by: Miquel Raynal > --- > drivers/nvmem/core.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c > index eaf6a3fe8ca6..286efd3f5a31 100644 > --- a/drivers/nvmem/core.c > +++ b/drivers/nvmem/core.c > @@ -743,6 +743,9 @@ static int nvmem_add_cells_from_dt(struct > nvmem_device *nvmem, struct device_nod > > static int nvmem_add_cells_from_legacy_of(struct nvmem_device *nvmem) > { > + if (!nvmem->dev.of_node) > + return 0; > + > return nvmem_add_cells_from_dt(nvmem, nvmem->dev.of_node); > } -- Rafał Miłecki