summaryrefslogtreecommitdiffstats
path: root/drivers/nvmem
diff options
context:
space:
mode:
authorAban Bedel <albeu@free.fr>2017-03-31 14:44:46 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-04-08 17:51:48 +0200
commit5253193d5479006b14dbe475740d031ce3e01570 (patch)
tree8e386997cc7a3c1806da8998168932e41ac38f74 /drivers/nvmem
parentMAINTAINERS: nvmem: Remove myself from maintainers (diff)
downloadlinux-5253193d5479006b14dbe475740d031ce3e01570.tar.xz
linux-5253193d5479006b14dbe475740d031ce3e01570.zip
nvmem: core: Allow allocating several anonymous nvmem devices
Currently the nvmem core expect the config to provide a name and ID that are then used to create the device name. When no device name is given 'nvmem' is used. However if there is several such anonymous devices they all get named 'nvmem0', which doesn't work. To fix this problem use the ID from the config only when the config also provides a name. When no name is provided take the uinque ID of the nvmem device instead. Signed-off-by: Aban Bedel <albeu@free.fr> Reviewed-by: Moritz Fischer <mdf@kernel.org> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/nvmem')
-rw-r--r--drivers/nvmem/core.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 408b521ee520..8c830a80a648 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -468,7 +468,8 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
np = config->dev->of_node;
nvmem->dev.of_node = np;
dev_set_name(&nvmem->dev, "%s%d",
- config->name ? : "nvmem", config->id);
+ config->name ? : "nvmem",
+ config->name ? config->id : nvmem->id);
nvmem->read_only = of_property_read_bool(np, "read-only") |
config->read_only;