UPSTREAM: nvmem: provide nvmem_dev_name()

Kernel users don't have any means of checking the names of nvmem
devices. Add a routine that returns the name of the nvmem provider.

This will be useful for future nvmem notifier subscribers - otherwise
they can't check what device is being added/removed.

Bug: 154188491
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit d7b9fd1669d4a4f38281c4e29f1408e1bdce09b3)
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: Iecea6bb4844e87eadd4225b08c789a58029438d9
This commit is contained in:
Bartosz Golaszewski 2018-09-21 06:40:03 -07:00 committed by Will McVicker
parent 390c6fd825
commit 9320809c47
2 changed files with 21 additions and 0 deletions

View file

@ -1390,6 +1390,19 @@ int nvmem_device_write(struct nvmem_device *nvmem,
}
EXPORT_SYMBOL_GPL(nvmem_device_write);
/**
* nvmem_dev_name() - Get the name of a given nvmem device.
*
* @nvmem: nvmem device.
*
* Return: name of the nvmem device.
*/
const char *nvmem_dev_name(struct nvmem_device *nvmem)
{
return dev_name(&nvmem->dev);
}
EXPORT_SYMBOL_GPL(nvmem_dev_name);
static int __init nvmem_init(void)
{
return bus_register(&nvmem_bus_type);

View file

@ -55,6 +55,8 @@ ssize_t nvmem_device_cell_read(struct nvmem_device *nvmem,
int nvmem_device_cell_write(struct nvmem_device *nvmem,
struct nvmem_cell_info *info, void *buf);
const char *nvmem_dev_name(struct nvmem_device *nvmem);
#else
static inline struct nvmem_cell *nvmem_cell_get(struct device *dev,
@ -143,6 +145,12 @@ static inline int nvmem_device_write(struct nvmem_device *nvmem,
{
return -ENOSYS;
}
static inline const char *nvmem_dev_name(struct nvmem_device *nvmem)
{
return NULL;
}
#endif /* CONFIG_NVMEM */
#if IS_ENABLED(CONFIG_NVMEM) && IS_ENABLED(CONFIG_OF)