diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2018-05-28 21:47:30 -0700 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-05-31 17:26:49 +0200 |
commit | 611a0d0b73d55b74a43c573ef80a843c70d2baad (patch) | |
tree | 67d0379dca0b3072ed6d9fbebfa512bd68749cb2 /drivers/nvmem | |
parent | 137e8e3c1748a6ad39201b22316182bd01adb5d5 (diff) | |
download | barebox-611a0d0b73d55b74a43c573ef80a843c70d2baad.tar.gz barebox-611a0d0b73d55b74a43c573ef80a843c70d2baad.tar.xz |
nvmem: Use name from struct nvmem_config for cdev
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>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/nvmem')
-rw-r--r-- | drivers/nvmem/core.c | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c index 172fa8b720..53b934bb33 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); |