[PATCH 3/5] misc: eeprom: at24: Support custom device names for AT24 EEPROMs

From: Jon Hunter
Date: Thu Sep 10 2020 - 17:31:08 EST


By using the label property, a more descriptive name can be populated
for AT24 EEPROMs NVMEM device. Update the AT24 driver to check to see
if the label property is present and if so, use this as the name for
NVMEM device.

Signed-off-by: Jon Hunter <jonathanh@xxxxxxxxxx>
---
drivers/misc/eeprom/at24.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 3f7a3bb6a36c..058be08a9a40 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -713,7 +713,15 @@ static int at24_probe(struct i2c_client *client)
return err;
}

- nvmem_config.name = dev_name(dev);
+ if (device_property_present(dev, "label")) {
+ err = device_property_read_string(dev, "label",
+ &nvmem_config.name);
+ if (err)
+ return err;
+ } else {
+ nvmem_config.name = dev_name(dev);
+ }
+
nvmem_config.dev = dev;
nvmem_config.id = NVMEM_DEVID_NONE;
nvmem_config.read_only = !writable;
--
2.25.1