From: "Rafał Miłecki" <rafal@milecki.pl>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Michael Walle <michael@walle.cc>,
Rob Herring <robh+dt@kernel.org>,
Frank Rowand <frowand.list@gmail.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Robert Marko <robert.marko@sartura.hr>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Luka Perkov <luka.perkov@sartura.hr>,
Randy Dunlap <rdunlap@infradead.org>,
Chen-Yu Tsai <wenst@chromium.org>,
Daniel Golle <daniel@makrotopia.org>
Subject: Re: [PATCH v12 2/7] nvmem: Clarify the situation when there is no DT node available
Date: Fri, 06 Oct 2023 13:41:52 +0200 [thread overview]
Message-ID: <05cd4592d0cfe0fb86aeb24db01de547@milecki.pl> (raw)
In-Reply-To: <20231005155907.2701706-3-miquel.raynal@bootlin.com>
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 <miquel.raynal@bootlin.com>
> ---
> 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
next prev parent reply other threads:[~2023-10-06 14:10 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-05 15:59 [PATCH v12 0/7] NVMEM cells in sysfs Miquel Raynal
2023-10-05 15:59 ` [PATCH v12 1/7] of: device: Export of_device_make_bus_id() Miquel Raynal
2023-10-06 17:02 ` Rob Herring
2023-10-05 15:59 ` [PATCH v12 2/7] nvmem: Clarify the situation when there is no DT node available Miquel Raynal
2023-10-06 11:41 ` Rafał Miłecki [this message]
2023-10-06 16:32 ` Miquel Raynal
2023-10-07 16:09 ` Rafał Miłecki
2023-10-08 13:39 ` Miquel Raynal
2023-10-09 9:44 ` Srinivas Kandagatla
2023-10-05 15:59 ` [PATCH v12 3/7] nvmem: Move of_nvmem_layout_get_container() in another header Miquel Raynal
2023-10-05 15:59 ` [PATCH v12 4/7] nvmem: Create a header for internal sharing Miquel Raynal
2023-10-05 15:59 ` [PATCH v12 5/7] nvmem: core: Rework layouts to become regular devices Miquel Raynal
2023-10-06 11:49 ` Rafał Miłecki
2023-10-06 16:33 ` Miquel Raynal
2023-10-07 16:31 ` Greg Kroah-Hartman
2023-10-11 10:33 ` Miquel Raynal
2023-10-08 13:42 ` kernel test robot
2023-10-09 9:44 ` Srinivas Kandagatla
2023-10-11 7:38 ` Miquel Raynal
2023-10-11 10:02 ` Srinivas Kandagatla
2023-10-11 10:58 ` Miquel Raynal
2023-10-05 15:59 ` [PATCH v12 6/7] ABI: sysfs-nvmem-cells: Expose cells through sysfs Miquel Raynal
2023-10-05 15:59 ` [PATCH v12 7/7] nvmem: core: " Miquel Raynal
2023-10-09 9:48 ` Srinivas Kandagatla
2023-10-11 7:15 ` Miquel Raynal
2023-10-11 8:27 ` Srinivas Kandagatla
2023-10-11 8:33 ` Miquel Raynal
2023-10-11 8:45 ` Srinivas Kandagatla
2023-10-11 8:58 ` Miquel Raynal
2023-10-11 9:26 ` Srinivas Kandagatla
2023-10-11 9:44 ` Miquel Raynal
2023-10-11 10:02 ` Srinivas Kandagatla
2023-10-11 11:09 ` Miquel Raynal
2023-10-11 13:56 ` Srinivas Kandagatla
2023-10-11 14:02 ` Miquel Raynal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=05cd4592d0cfe0fb86aeb24db01de547@milecki.pl \
--to=rafal@milecki.pl \
--cc=daniel@makrotopia.org \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luka.perkov@sartura.hr \
--cc=michael@walle.cc \
--cc=miquel.raynal@bootlin.com \
--cc=rdunlap@infradead.org \
--cc=robert.marko@sartura.hr \
--cc=robh+dt@kernel.org \
--cc=srinivas.kandagatla@linaro.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=wenst@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).