提交 5253193d 编写于 作者: A Aban Bedel 提交者: Greg Kroah-Hartman

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: NAban Bedel <albeu@free.fr>
Reviewed-by: NMoritz Fischer <mdf@kernel.org>
Signed-off-by: NSrinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 1b595505
...@@ -468,7 +468,8 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config) ...@@ -468,7 +468,8 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
np = config->dev->of_node; np = config->dev->of_node;
nvmem->dev.of_node = np; nvmem->dev.of_node = np;
dev_set_name(&nvmem->dev, "%s%d", 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") | nvmem->read_only = of_property_read_bool(np, "read-only") |
config->read_only; config->read_only;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册