diff mbox series

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

Message ID 20200910134239.192030-4-jonathanh@nvidia.com
State Changes Requested
Headers show
Series Add support for custom names for AT24 EEPROMs | expand

Commit Message

Jon Hunter Sept. 10, 2020, 1:42 p.m. UTC
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@nvidia.com>
---
 drivers/misc/eeprom/at24.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
diff mbox series

Patch

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;