Merge tag 'rpmsg-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/remoteproc...
[linux-2.6-block.git] / drivers / nvmem / core.c
index 3f8c7718412b484ba649dd9f540dd6479dbf0ab6..eaf6a3fe8ca6d42ccb6971770e221af9497242e6 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/nvmem-provider.h>
 #include <linux/gpio/consumer.h>
 #include <linux/of.h>
-#include <linux/of_device.h>
 #include <linux/slab.h>
 
 struct nvmem_device {
@@ -772,12 +771,16 @@ int __nvmem_layout_register(struct nvmem_layout *layout, struct module *owner)
        list_add(&layout->node, &nvmem_layouts);
        spin_unlock(&nvmem_layout_lock);
 
+       blocking_notifier_call_chain(&nvmem_notifier, NVMEM_LAYOUT_ADD, layout);
+
        return 0;
 }
 EXPORT_SYMBOL_GPL(__nvmem_layout_register);
 
 void nvmem_layout_unregister(struct nvmem_layout *layout)
 {
+       blocking_notifier_call_chain(&nvmem_notifier, NVMEM_LAYOUT_REMOVE, layout);
+
        spin_lock(&nvmem_layout_lock);
        list_del(&layout->node);
        spin_unlock(&nvmem_layout_lock);
@@ -786,10 +789,10 @@ EXPORT_SYMBOL_GPL(nvmem_layout_unregister);
 
 static struct nvmem_layout *nvmem_layout_get(struct nvmem_device *nvmem)
 {
-       struct device_node *layout_np, *np = nvmem->dev.of_node;
+       struct device_node *layout_np;
        struct nvmem_layout *l, *layout = ERR_PTR(-EPROBE_DEFER);
 
-       layout_np = of_get_child_by_name(np, "nvmem-layout");
+       layout_np = of_nvmem_layout_get_container(nvmem);
        if (!layout_np)
                return NULL;
 
@@ -998,17 +1001,17 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
        if (rval)
                goto err_remove_cells;
 
-       dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name);
-
-       rval = device_add(&nvmem->dev);
+       rval = nvmem_add_cells_from_fixed_layout(nvmem);
        if (rval)
                goto err_remove_cells;
 
-       rval = nvmem_add_cells_from_fixed_layout(nvmem);
+       rval = nvmem_add_cells_from_layout(nvmem);
        if (rval)
                goto err_remove_cells;
 
-       rval = nvmem_add_cells_from_layout(nvmem);
+       dev_dbg(&nvmem->dev, "Registering nvmem device %s\n", config->name);
+
+       rval = device_add(&nvmem->dev);
        if (rval)
                goto err_remove_cells;