devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: "Michael Walle" <michael@walle.cc>,
	"Rafał Miłecki" <rafal@milecki.pl>,
	"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>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>
Subject: [PATCH v11 2/7] nvmem: Clarify the situation when there is no DT node available
Date: Thu,  5 Oct 2023 00:22:31 +0200	[thread overview]
Message-ID: <20231004222236.411248-3-miquel.raynal@bootlin.com> (raw)
In-Reply-To: <20231004222236.411248-1-miquel.raynal@bootlin.com>

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.

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);
 }
 
-- 
2.34.1


  parent reply	other threads:[~2023-10-04 22:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-04 22:22 [PATCH v11 0/7] NVMEM cells in sysfs Miquel Raynal
2023-10-04 22:22 ` [PATCH v11 1/7] of: device: Export of_device_make_bus_id() Miquel Raynal
2023-10-04 22:22 ` Miquel Raynal [this message]
2023-10-04 22:22 ` [PATCH v11 3/7] nvmem: Move of_nvmem_layout_get_container() in another header Miquel Raynal
2023-10-05  2:47   ` kernel test robot
2023-10-05 11:37   ` kernel test robot
2023-10-04 22:22 ` [PATCH v11 4/7] nvmem: Create a header for internal sharing Miquel Raynal
2023-10-04 22:22 ` [PATCH v11 5/7] nvmem: core: Rework layouts to become regular devices Miquel Raynal
2023-10-05  8:24   ` kernel test robot
2023-10-04 22:22 ` [PATCH v11 6/7] ABI: sysfs-nvmem-cells: Expose cells through sysfs Miquel Raynal
2023-10-04 22:22 ` [PATCH v11 7/7] nvmem: core: " Miquel Raynal
2023-10-05  8:56 ` [PATCH v11 0/7] NVMEM cells in sysfs Chen-Yu Tsai

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=20231004222236.411248-3-miquel.raynal@bootlin.com \
    --to=miquel.raynal@bootlin.com \
    --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=rafal@milecki.pl \
    --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).