From: Sascha Hauer <s.hauer@pengutronix.de>
To: BAREBOX <barebox@lists.infradead.org>
Subject: [PATCH 2/4] nvmem: fix device name setting
Date: Mon, 08 Dec 2025 13:00:52 +0100 [thread overview]
Message-ID: <20251208-nvmem-eeprom-v1-2-41ba588e2f3a@pengutronix.de> (raw)
In-Reply-To: <20251208-nvmem-eeprom-v1-0-41ba588e2f3a@pengutronix.de>
For the nvmem device ID it was only possible to specify NVMEM_DEVID_NONE
which translates to DEVICE_ID_SINGLE or NVMEM_DEVID_AUTO which
translates to DEVICE_ID_DYNAMIC. All other values default to
DEVICE_ID_DYNAMIC.
Explicitly allow to set a fixed device ID so that the caller can fully
specify the name under which the new nvmem device appears. The special
case is when no config->name is given. In this we use "nvmem" as device
name, but we also have to ignore config->id.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/nvmem/core.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index a96aaf0b5a7215d05e976133aacfee1fdf9c36f7..8e1cf400e5d83ad6d53d21a705913cee72bfd4ab 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -487,15 +487,23 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
if (config->read_only || !config->reg_write || of_property_read_bool(np, "read-only"))
nvmem->read_only = true;
- dev_set_name(&nvmem->dev, "%s", config->name ? : "nvmem");
- switch (config->id) {
- case NVMEM_DEVID_NONE:
- nvmem->dev.id = DEVICE_ID_SINGLE;
+ if (config->name) {
+ dev_set_name(&nvmem->dev, "%s", config->name);
+
+ switch (config->id) {
+ case NVMEM_DEVID_NONE:
+ nvmem->dev.id = DEVICE_ID_SINGLE;
+ break;
+ case NVMEM_DEVID_AUTO:
+ nvmem->dev.id = DEVICE_ID_DYNAMIC;
+ break;
+ default:
+ nvmem->dev.id = config->id;
break;
- case NVMEM_DEVID_AUTO:
- default:
+ }
+ } else {
+ dev_set_name(&nvmem->dev, "nvmem");
nvmem->dev.id = DEVICE_ID_DYNAMIC;
- break;
}
rval = register_device(&nvmem->dev);
--
2.47.3
next prev parent reply other threads:[~2025-12-08 12:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-08 12:00 [PATCH 0/4] driver name fixes Sascha Hauer
2025-12-08 12:00 ` [PATCH 1/4] driver: implement get_free_deviceid_from() Sascha Hauer
2025-12-08 12:00 ` Sascha Hauer [this message]
2025-12-08 12:00 ` [PATCH 3/4] driver: fix device name clashes Sascha Hauer
2025-12-08 12:00 ` [PATCH 4/4] eeprom: at24: reserve EEPROM names which have an alias Sascha Hauer
2025-12-10 7:09 ` [PATCH 0/4] driver name fixes Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251208-nvmem-eeprom-v1-2-41ba588e2f3a@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox