linux/drivers/nvmem/layouts/fixed-layout.c
Mathieu Dubois-Briand b5be879519 nvmem: layouts: Add fixed-layout driver
Current implementation isn't working well when device tree nodes have a
phandle on a fixed-layout nvmem node. As the fixed layout is handled in
nvmem core, no driver is ever associated with the layout, and the device
consumer driver probe is deferred indefinitely.

Remove the specific handling of fixed-layout and add a layout driver.
This makes the fixed-layout similar to all other layouts, fixing the
whole issue.

Fixes: fc29fd821d ("nvmem: core: Rework layouts to become regular devices")
Cc: stable@vger.kernel.org
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Srinivas Kandagatla <srini@kernel.org>
Link: https://patch.msgid.link/20260724223404.629248-3-srini@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2026-07-31 11:00:13 +02:00

59 lines
1.3 KiB
C

// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2026 Bootlin
*
* Authors: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
*/
#include <linux/nvmem-provider.h>
#include <linux/of.h>
#include "../internals.h"
static int fixed_layout_add_cells(struct nvmem_layout *layout)
{
struct device_node *np;
int ret;
np = of_nvmem_layout_get_container(layout->nvmem);
if (!np)
return -ENOENT;
ret = nvmem_add_cells_from_dt(layout->nvmem, np);
of_node_put(np);
return ret;
}
static int fixed_layout_probe(struct nvmem_layout *layout)
{
layout->add_cells = fixed_layout_add_cells;
return nvmem_layout_register(layout);
}
static void fixed_layout_remove(struct nvmem_layout *layout)
{
nvmem_layout_unregister(layout);
}
static const struct of_device_id fixed_layout_of_match_table[] = {
{ .compatible = "fixed-layout", },
{},
};
static struct nvmem_layout_driver fixed_layout_layout = {
.driver = {
.name = "fixed-layout",
.of_match_table = fixed_layout_of_match_table,
},
.probe = fixed_layout_probe,
.remove = fixed_layout_remove,
};
module_nvmem_layout_driver(fixed_layout_layout);
MODULE_AUTHOR("Mathieu Dubois-Briand");
MODULE_LICENSE("GPL");
MODULE_DEVICE_TABLE(of, fixed_layout_of_match_table);
MODULE_DESCRIPTION("NVMEM fixed-layout driver");