diff options
author | Bhuvanchandra DV <bhuvanchandra.dv@toradex.com> | 2017-02-20 22:49:33 +0530 |
---|---|---|
committer | Marcel Ziswiler <marcel.ziswiler@toradex.com> | 2020-02-09 22:45:33 +0100 |
commit | d326296204372ec5e0c37452271fc26844b61a55 (patch) | |
tree | 54bd097d5febdc92e634d88530168cc70c596a46 | |
parent | fd8a3307976f58bdcf47d0df23e46ee14d0dce90 (diff) |
drivers: soc: Add new sysfs attribute to expose SoC unique ID
Add new 'unique_id' sysfs attribute to expose SoC unique ID
Signed-off-by: Bhuvanchandra DV <bhuvanchandra.dv@toradex.com>
Acked-by: Max Krummenacher <max.krummenacher@toradex.com>
(cherry picked from commit 8a098f2f1b8ae277a38ee0c5e0b974d5baa8dd01)
(cherry picked from commit fb67fb4b277c6df9b5032564d6ae6756c905206d)
Conflicts:
include/linux/sys_soc.h
Signed-off-by: Philippe Schenker <philippe.schenker@toradex.com>
-rw-r--r-- | drivers/base/soc.c | 7 | ||||
-rw-r--r-- | include/linux/sys_soc.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/drivers/base/soc.c b/drivers/base/soc.c index 1242b2d2e01a..8141c0e1c7c3 100644 --- a/drivers/base/soc.c +++ b/drivers/base/soc.c @@ -34,6 +34,7 @@ static struct bus_type soc_bus_type = { static DEVICE_ATTR(machine, S_IRUGO, soc_info_get, NULL); static DEVICE_ATTR(family, S_IRUGO, soc_info_get, NULL); static DEVICE_ATTR(soc_id, S_IRUGO, soc_info_get, NULL); +static DEVICE_ATTR(unique_id, S_IRUGO, soc_info_get, NULL); static DEVICE_ATTR(revision, S_IRUGO, soc_info_get, NULL); struct device *soc_device_to_device(struct soc_device *soc_dev) @@ -60,6 +61,9 @@ static umode_t soc_attribute_mode(struct kobject *kobj, if ((attr == &dev_attr_soc_id.attr) && (soc_dev->attr->soc_id != NULL)) return attr->mode; + if ((attr == &dev_attr_unique_id.attr) + && (soc_dev->attr->unique_id != NULL)) + return attr->mode; /* Unknown or unfilled attribute. */ return 0; @@ -79,6 +83,8 @@ static ssize_t soc_info_get(struct device *dev, return sprintf(buf, "%s\n", soc_dev->attr->revision); if (attr == &dev_attr_soc_id) return sprintf(buf, "%s\n", soc_dev->attr->soc_id); + if (attr == &dev_attr_unique_id) + return sprintf(buf, "%s\n", soc_dev->attr->unique_id); return -EINVAL; @@ -88,6 +94,7 @@ static struct attribute *soc_attr[] = { &dev_attr_machine.attr, &dev_attr_family.attr, &dev_attr_soc_id.attr, + &dev_attr_unique_id.attr, &dev_attr_revision.attr, NULL, }; diff --git a/include/linux/sys_soc.h b/include/linux/sys_soc.h index bed223b70217..16cdbdb09100 100644 --- a/include/linux/sys_soc.h +++ b/include/linux/sys_soc.h @@ -14,6 +14,7 @@ struct soc_device_attribute { const char *revision; const char *soc_id; const void *data; + const char *unique_id; }; /** |