summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBhuvanchandra DV <bhuvanchandra.dv@toradex.com>2017-02-20 22:49:33 +0530
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2017-04-03 15:10:39 +0200
commit8a098f2f1b8ae277a38ee0c5e0b974d5baa8dd01 (patch)
tree4ff9ddda4c9535104e2c5262a04101817875e37a
parent003c45ff87a7360e0ed25de2d0dc959a075ab3cc (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>
-rw-r--r--drivers/base/soc.c7
-rw-r--r--include/linux/sys_soc.h1
2 files changed, 8 insertions, 0 deletions
diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index 39fca01c8fa1..f58632a972bf 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -35,6 +35,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)
@@ -61,6 +62,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;
@@ -80,6 +84,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;
@@ -89,6 +95,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 2739ccb69571..5412d2b7de7f 100644
--- a/include/linux/sys_soc.h
+++ b/include/linux/sys_soc.h
@@ -13,6 +13,7 @@ struct soc_device_attribute {
const char *family;
const char *revision;
const char *soc_id;
+ const char *unique_id;
};
/**