From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: barebox@lists.infradead.org
Cc: Andrey Smirnov <andrew.smirnov@gmail.com>,
Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Subject: [PATCH 6/7] nvmem: Use name from struct nvmem_config for cdev
Date: Tue, 22 May 2018 16:05:17 -0700 [thread overview]
Message-ID: <20180522230518.9070-7-andrew.smirnov@gmail.com> (raw)
In-Reply-To: <20180522230518.9070-1-andrew.smirnov@gmail.com>
Original name, 'nvmemN', doesn't really give any hint about which
physical HW it may represent, so change the code to either pick up an
DT alias or use the name passed via 'struct nvmem_config'.
Cc: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Tested-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
---
drivers/nvmem/core.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 172fa8b72..53b934bb3 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -88,26 +88,14 @@ static struct cdev_operations nvmem_chrdev_ops = {
.lseek = dev_lseek_default,
};
-static int nvmem_register_cdev(struct nvmem_device *nvmem)
+static int nvmem_register_cdev(struct nvmem_device *nvmem, const char *name)
{
struct device_d *dev = &nvmem->dev;
const char *alias;
- char *devname;
- int err;
alias = of_alias_get(dev->device_node);
- if (alias) {
- devname = xstrdup(alias);
- } else {
- err = cdev_find_free_index("nvmem");
- if (err < 0) {
- dev_err(dev, "no index found to name device\n");
- return err;
- }
- devname = xasprintf("nvmem%d", err);
- }
- nvmem->cdev.name = devname;
+ nvmem->cdev.name = xstrdup(alias ?: name);
nvmem->cdev.flags = DEVFS_IS_CHARACTER_DEV;
nvmem->cdev.ops = &nvmem_chrdev_ops;
nvmem->cdev.dev = &nvmem->dev;
@@ -222,7 +210,7 @@ struct nvmem_device *nvmem_register(const struct nvmem_config *config)
return ERR_PTR(rval);
}
- rval = nvmem_register_cdev(nvmem);
+ rval = nvmem_register_cdev(nvmem, config->name);
if (rval) {
kfree(nvmem);
return ERR_PTR(rval);
--
2.17.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-05-22 23:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-22 23:05 [PATCH 0/7] VF610 OCOTP MAC address layout change Andrey Smirnov
2018-05-22 23:05 ` [PATCH 1/7] i.MX: ocotp: Unify code paths for reading MAC address Andrey Smirnov
2018-05-22 23:05 ` [PATCH 2/7] i.MX: ocotp: Change MAC address layout for VFxxx Andrey Smirnov
2018-05-23 8:21 ` Sascha Hauer
2018-05-25 3:06 ` Andrey Smirnov
2018-05-22 23:05 ` [PATCH 3/7] i.MX: ocotp: Simplify OCOTP field packing/unpacking Andrey Smirnov
2018-05-22 23:05 ` [PATCH 4/7] i.MX: ocotp: Simplify BF macro Andrey Smirnov
2018-05-22 23:05 ` [PATCH 5/7] i.MX: ocotp: Move OCOTP driver to drivers/nvmem Andrey Smirnov
2018-05-22 23:05 ` Andrey Smirnov [this message]
2018-05-22 23:05 ` [PATCH 7/7] nvmem: ocotp: Convert to NVMEM device Andrey Smirnov
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=20180522230518.9070-7-andrew.smirnov@gmail.com \
--to=andrew.smirnov@gmail.com \
--cc=barebox@lists.infradead.org \
--cc=vivien.didelot@savoirfairelinux.com \
/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