nvmem: core: Create all cells before adding the nvmem device
authorMiquel Raynal <miquel.raynal@bootlin.com>
Wed, 23 Aug 2023 13:27:41 +0000 (14:27 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Aug 2023 14:34:02 +0000 (16:34 +0200)
Let's pack all the cells creation in one place, so they are all created
before we add the nvmem device.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Michael Walle <michael@walle.cc>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Link: https://lore.kernel.org/r/20230823132744.350618-20-srinivas.kandagatla@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/nvmem/core.c

index 2251103..bc7ea00 100644 (file)
@@ -997,17 +997,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;