Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp503460rdb; Fri, 6 Oct 2023 09:32:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvYvAgnkg4NP5y1UIG95DqgMTqfwHXCPR6faVAQE2YcfQD/Fexll8RVGHmagmzwq7PAWgM X-Received: by 2002:a17:903:32c3:b0:1c6:1d3d:b412 with SMTP id i3-20020a17090332c300b001c61d3db412mr9557979plr.30.1696609962366; Fri, 06 Oct 2023 09:32:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696609962; cv=none; d=google.com; s=arc-20160816; b=XpxftWAr5Vw4+GfGkqmk+Nh2SvNHUoTizZZn2m8T/b21ze4nQi1aIaZAAvSOu2uM0J e8jxpGQ673pd6aTeiXZzNr52NiBy/eqfq25rvcFL2xguRvUV1UFAMsqChjz7OElInvG3 XbNSLkIoNYJuxucZjQUscW8S7QbU9UUS6C6tFSpzUIKR+/pVv8a0YQ/FLNDTO3SpADPj d2BmcsXdEgZ4K7BLFxBgsErVGT6dhFP8g2FE0uXVWD2+eUJkBMhEhcxhgEA21OhjDAJc MrEMliKfd/fasuKTPam+UFatCmKez1y5LEn6jJRl6zrSe551J6w3+TGh4EYP/eSD8UHJ Zo7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=0ttf6wkaFsFlxhmC0+pUMWKDP9EjjF8Omo60fPoYTBA=; fh=e+QVSRLHJFZOJden4SsPYiQ/aNDYGD0MdcUxARBoEIg=; b=Y4yAfWT7yvBKVNolm24tAHsBU8iqZ/xNm8IKvggCOR5z6YAxBTNxZ6P6kq3gXXLuhs 11pE0D/CPr4+Oviz4wlCwAx3l/trT1IAa7xqIYRZyLtkt3KfgoUsh7/Nt91ahp12/nvD 85BgLNuo8diFIRBRPhpoTCn1uOGgHErutuwOOICdn/6eLk7JDcXgzeSpG/6jRhYI4z+n pDxAHXWfIZ5ShTjr4GQB7ai6VEUcOTWEyuYiIcKJ/6XjPIxH0USM51zJb/NMOROShElg slQww4HdOpZIGi5Z4xn90yO3KCmBttAACV3xy7JCMoztkMWzjRL4Lr2AQfHTvBYcuyov tvzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LBhGuP6h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id v12-20020a170902b7cc00b001c5bcddc7aesi3757537plz.126.2023.10.06.09.32.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 09:32:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LBhGuP6h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 453E9801D144; Fri, 6 Oct 2023 09:32:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232788AbjJFQci (ORCPT + 99 others); Fri, 6 Oct 2023 12:32:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232762AbjJFQch (ORCPT ); Fri, 6 Oct 2023 12:32:37 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E8D0C6; Fri, 6 Oct 2023 09:32:35 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id F0360E0002; Fri, 6 Oct 2023 16:32:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1696609953; 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=0ttf6wkaFsFlxhmC0+pUMWKDP9EjjF8Omo60fPoYTBA=; b=LBhGuP6h8C7MbjZLCHnlJaBRcSAcqASBfIimdsaHAlR7ueGjO6eKSGmV7fs0KbgEv/bXRF 72BgRQVk4Rvgn437fHLbpO9CRvVqz2dFWfUhgdvt/2x3vpwd2nJw8+h0WpWbzQU4+H+dpH lmCl7p6NvMbDslUCSyWw5/Grfq5A1/Mb9iODQbYPPPsUkcEuqdmj8eLwf52riEvqJsa/2D 2sJnL05oPFNlCBbazjaDYwSDpljSq5mJf7zXgqP1YqVmelTdg/Hfb9F6rNShiGVrEKfsyr hMUbCK77GK6mcsTCdJ7TTesDX3Aes9ZN9qsx0+w3D4hDl6HJneviDfODH4WVGQ== Date: Fri, 6 Oct 2023 18:32:29 +0200 From: Miquel Raynal To: =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= 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 Message-ID: <20231006183229.51cd8e60@xps-13> In-Reply-To: <05cd4592d0cfe0fb86aeb24db01de547@milecki.pl> References: <20231005155907.2701706-1-miquel.raynal@bootlin.com> <20231005155907.2701706-3-miquel.raynal@bootlin.com> <05cd4592d0cfe0fb86aeb24db01de547@milecki.pl> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: miquel.raynal@bootlin.com X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Fri, 06 Oct 2023 09:32:41 -0700 (PDT) Hi Rafa=C5=82, rafal@milecki.pl wrote on Fri, 06 Oct 2023 13:41:52 +0200: > 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 > look= ing > > 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. =20 >=20 > 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. >=20 > 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". >=20 > 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. That was not obvious to me as I thought it would start from /, which I think some other function do when you don't provide a start node. > Given that for_each_child_of_node() is NULL-safe I think code from this > patch is redundant. I didn't say it was not safe, just not explicit. > 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.c= om/t/ I actually wanted to find again that patch and could not get my hands on it, but it is probably a much better fix than my other mtd patch, I agree with you. > Maybe with above patch finally things will get more clear and we don't > need this PATCH after all? Yes. Srinivas, what are your plans for the above patch? Thanks, Miqu=C3=A8l