Commit de12c969 authored by Michael Walle's avatar Michael Walle Committed by Greg Kroah-Hartman
Browse files

nvmem: core: allow to modify a cell before adding it



Provide a way to modify a cell before it will get added. This is useful
to attach a custom post processing hook via a layout.

Signed-off-by: default avatarMichael Walle <michael@walle.cc>
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: default avatarSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230404172148.82422-18-srinivas.kandagatla@linaro.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 345ec382
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -695,6 +695,7 @@ static int nvmem_validate_keepouts(struct nvmem_device *nvmem)


static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
{
{
	struct nvmem_layout *layout = nvmem->layout;
	struct device *dev = &nvmem->dev;
	struct device *dev = &nvmem->dev;
	struct device_node *child;
	struct device_node *child;
	const __be32 *addr;
	const __be32 *addr;
@@ -724,6 +725,9 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)


		info.np = of_node_get(child);
		info.np = of_node_get(child);


		if (layout && layout->fixup_cell_info)
			layout->fixup_cell_info(nvmem, layout, &info);

		ret = nvmem_add_one_cell(nvmem, &info);
		ret = nvmem_add_one_cell(nvmem, &info);
		kfree(info.name);
		kfree(info.name);
		if (ret) {
		if (ret) {
+5 −0
Original line number Original line Diff line number Diff line
@@ -155,6 +155,8 @@ struct nvmem_cell_table {
 * @add_cells:		Will be called if a nvmem device is found which
 * @add_cells:		Will be called if a nvmem device is found which
 *			has this layout. The function will add layout
 *			has this layout. The function will add layout
 *			specific cells with nvmem_add_one_cell().
 *			specific cells with nvmem_add_one_cell().
 * @fixup_cell_info:	Will be called before a cell is added. Can be
 *			used to modify the nvmem_cell_info.
 * @owner:		Pointer to struct module.
 * @owner:		Pointer to struct module.
 * @node:		List node.
 * @node:		List node.
 *
 *
@@ -168,6 +170,9 @@ struct nvmem_layout {
	const struct of_device_id *of_match_table;
	const struct of_device_id *of_match_table;
	int (*add_cells)(struct device *dev, struct nvmem_device *nvmem,
	int (*add_cells)(struct device *dev, struct nvmem_device *nvmem,
			 struct nvmem_layout *layout);
			 struct nvmem_layout *layout);
	void (*fixup_cell_info)(struct nvmem_device *nvmem,
				struct nvmem_layout *layout,
				struct nvmem_cell_info *cell);


	/* private */
	/* private */
	struct module *owner;
	struct module *owner;