[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231004222236.411248-3-miquel.raynal@bootlin.com>
Date: Thu, 5 Oct 2023 00:22:31 +0200
From: Miquel Raynal <miquel.raynal@...tlin.com>
To: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Michael Walle <michael@...le.cc>,
Rafał Miłecki <rafal@...ecki.pl>,
Rob Herring <robh+dt@...nel.org>,
Frank Rowand <frowand.list@...il.com>,
devicetree@...r.kernel.org, <linux-kernel@...r.kernel.org>,
Robert Marko <robert.marko@...tura.hr>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Luka Perkov <luka.perkov@...tura.hr>,
Randy Dunlap <rdunlap@...radead.org>,
Chen-Yu Tsai <wenst@...omium.org>,
Daniel Golle <daniel@...rotopia.org>,
Miquel Raynal <miquel.raynal@...tlin.com>
Subject: [PATCH v11 2/7] nvmem: Clarify the situation when there is no DT node available
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@...tlin.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
Powered by blists - more mailing lists