All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvmem: core: add fixed-layout declaration
@ 2024-01-11 15:28 Catalin Popescu
  2024-01-11 15:41 ` Miquel Raynal
  0 siblings, 1 reply; 4+ messages in thread
From: Catalin Popescu @ 2024-01-11 15:28 UTC (permalink / raw)
  To: srinivas.kandagatla, miquel.raynal
  Cc: michael, rafal, robh, linux-kernel, bsp-development.geo, gregkh,
	luca.ceresoli, Catalin Popescu

Declare fixed-layout as a supported layout and use add_cells
callback to parse the cells. This adds consistency over layouts
parsing as fixed-layout parsing is now handled in the same way
than others nvmem layouts.

Signed-off-by: Catalin Popescu <catalin.popescu@leica-geosystems.com>
---
 drivers/nvmem/core.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 608b352a7d91..d7f34cbea34b 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -746,7 +746,9 @@ static int nvmem_add_cells_from_legacy_of(struct nvmem_device *nvmem)
 	return nvmem_add_cells_from_dt(nvmem, nvmem->dev.of_node);
 }
 
-static int nvmem_add_cells_from_fixed_layout(struct nvmem_device *nvmem)
+static int nvmem_add_cells_from_fixed_layout(struct device *dev,
+					     struct nvmem_device *nvmem,
+					     struct nvmem_layout *layout)
 {
 	struct device_node *layout_np;
 	int err = 0;
@@ -755,8 +757,7 @@ static int nvmem_add_cells_from_fixed_layout(struct nvmem_device *nvmem)
 	if (!layout_np)
 		return 0;
 
-	if (of_device_is_compatible(layout_np, "fixed-layout"))
-		err = nvmem_add_cells_from_dt(nvmem, layout_np);
+	err = nvmem_add_cells_from_dt(nvmem, layout_np);
 
 	of_node_put(layout_np);
 
@@ -1009,10 +1010,6 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
 			goto err_remove_cells;
 	}
 
-	rval = nvmem_add_cells_from_fixed_layout(nvmem);
-	if (rval)
-		goto err_remove_cells;
-
 	rval = nvmem_add_cells_from_layout(nvmem);
 	if (rval)
 		goto err_remove_cells;
@@ -2132,6 +2129,19 @@ const char *nvmem_dev_name(struct nvmem_device *nvmem)
 }
 EXPORT_SYMBOL_GPL(nvmem_dev_name);
 
+static const struct of_device_id fixed_layout_of_match_table[] = {
+	{ .compatible = "fixed-layout", },
+	{},
+};
+MODULE_DEVICE_TABLE(of, fixed_layout_of_match_table);
+
+static struct nvmem_layout fixed_layout = {
+	.name = "NVMEM fixed layout",
+	.of_match_table = fixed_layout_of_match_table,
+	.add_cells = nvmem_add_cells_from_fixed_layout,
+};
+module_nvmem_layout_driver(fixed_layout);
+
 static int __init nvmem_init(void)
 {
 	return bus_register(&nvmem_bus_type);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-30 15:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-11 15:28 [PATCH] nvmem: core: add fixed-layout declaration Catalin Popescu
2024-01-11 15:41 ` Miquel Raynal
2024-01-29 15:29   ` POPESCU Catalin
2024-01-30 15:00     ` Miquel Raynal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.