summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjorn Andersson <bjorn.andersson@linaro.org>2019-07-23 18:35:11 -0400
committerBjorn Andersson <bjorn.andersson@linaro.org>2019-08-05 17:56:30 -0400
commit9aebf4de220344e2f03ae6386272bf98f80fd295 (patch)
treead37ed085240cbfe96935ba1999c38dd804da85b
parentaf311ff9a69189a03548efd5a47d4bb44644fd45 (diff)
base: soc: Add serial_number attribute to soc
Add new attribute named "serial_number" as a standard interface for user space to acquire the serial number of the device. For ST-Ericsson SoCs this is exposed by the cryptically named "soc_id" attribute, but this provides a human readable standardized name for this property. Tested-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Vaishali Thakkar <vaishali.thakkar@linaro.org> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
-rw-r--r--Documentation/ABI/testing/sysfs-devices-soc7
-rw-r--r--drivers/base/soc.c7
-rw-r--r--include/linux/sys_soc.h1
3 files changed, 15 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/sysfs-devices-soc b/Documentation/ABI/testing/sysfs-devices-soc
index 6d9cc253f2b2..ba3a3fac0ee1 100644
--- a/Documentation/ABI/testing/sysfs-devices-soc
+++ b/Documentation/ABI/testing/sysfs-devices-soc
@@ -26,6 +26,13 @@ Description:
26 Read-only attribute common to all SoCs. Contains SoC family name 26 Read-only attribute common to all SoCs. Contains SoC family name
27 (e.g. DB8500). 27 (e.g. DB8500).
28 28
29What: /sys/devices/socX/serial_number
30Date: January 2019
31contact: Bjorn Andersson <bjorn.andersson@linaro.org>
32Description:
33 Read-only attribute supported by most SoCs. Contains the SoC's
34 serial number, if available.
35
29What: /sys/devices/socX/soc_id 36What: /sys/devices/socX/soc_id
30Date: January 2012 37Date: January 2012
31contact: Lee Jones <lee.jones@linaro.org> 38contact: Lee Jones <lee.jones@linaro.org>
diff --git a/drivers/base/soc.c b/drivers/base/soc.c
index 10b280f30217..b0933b9fe67f 100644
--- a/drivers/base/soc.c
+++ b/drivers/base/soc.c
@@ -33,6 +33,7 @@ static struct bus_type soc_bus_type = {
33 33
34static DEVICE_ATTR(machine, S_IRUGO, soc_info_get, NULL); 34static DEVICE_ATTR(machine, S_IRUGO, soc_info_get, NULL);
35static DEVICE_ATTR(family, S_IRUGO, soc_info_get, NULL); 35static DEVICE_ATTR(family, S_IRUGO, soc_info_get, NULL);
36static DEVICE_ATTR(serial_number, S_IRUGO, soc_info_get, NULL);
36static DEVICE_ATTR(soc_id, S_IRUGO, soc_info_get, NULL); 37static DEVICE_ATTR(soc_id, S_IRUGO, soc_info_get, NULL);
37static DEVICE_ATTR(revision, S_IRUGO, soc_info_get, NULL); 38static DEVICE_ATTR(revision, S_IRUGO, soc_info_get, NULL);
38 39
@@ -57,6 +58,9 @@ static umode_t soc_attribute_mode(struct kobject *kobj,
57 if ((attr == &dev_attr_revision.attr) 58 if ((attr == &dev_attr_revision.attr)
58 && (soc_dev->attr->revision != NULL)) 59 && (soc_dev->attr->revision != NULL))
59 return attr->mode; 60 return attr->mode;
61 if ((attr == &dev_attr_serial_number.attr)
62 && (soc_dev->attr->serial_number != NULL))
63 return attr->mode;
60 if ((attr == &dev_attr_soc_id.attr) 64 if ((attr == &dev_attr_soc_id.attr)
61 && (soc_dev->attr->soc_id != NULL)) 65 && (soc_dev->attr->soc_id != NULL))
62 return attr->mode; 66 return attr->mode;
@@ -77,6 +81,8 @@ static ssize_t soc_info_get(struct device *dev,
77 return sprintf(buf, "%s\n", soc_dev->attr->family); 81 return sprintf(buf, "%s\n", soc_dev->attr->family);
78 if (attr == &dev_attr_revision) 82 if (attr == &dev_attr_revision)
79 return sprintf(buf, "%s\n", soc_dev->attr->revision); 83 return sprintf(buf, "%s\n", soc_dev->attr->revision);
84 if (attr == &dev_attr_serial_number)
85 return sprintf(buf, "%s\n", soc_dev->attr->serial_number);
80 if (attr == &dev_attr_soc_id) 86 if (attr == &dev_attr_soc_id)
81 return sprintf(buf, "%s\n", soc_dev->attr->soc_id); 87 return sprintf(buf, "%s\n", soc_dev->attr->soc_id);
82 88
@@ -87,6 +93,7 @@ static ssize_t soc_info_get(struct device *dev,
87static struct attribute *soc_attr[] = { 93static struct attribute *soc_attr[] = {
88 &dev_attr_machine.attr, 94 &dev_attr_machine.attr,
89 &dev_attr_family.attr, 95 &dev_attr_family.attr,
96 &dev_attr_serial_number.attr,
90 &dev_attr_soc_id.attr, 97 &dev_attr_soc_id.attr,
91 &dev_attr_revision.attr, 98 &dev_attr_revision.attr,
92 NULL, 99 NULL,
diff --git a/include/linux/sys_soc.h b/include/linux/sys_soc.h
index b7c70c3e953f..48ceea867dd6 100644
--- a/include/linux/sys_soc.h
+++ b/include/linux/sys_soc.h
@@ -12,6 +12,7 @@ struct soc_device_attribute {
12 const char *machine; 12 const char *machine;
13 const char *family; 13 const char *family;
14 const char *revision; 14 const char *revision;
15 const char *serial_number;
15 const char *soc_id; 16 const char *soc_id;
16 const void *data; 17 const void *data;
17}; 18};