Skip to content

Commit 9aebf4d

Browse files
committed
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>
1 parent af311ff commit 9aebf4d

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎Documentation/ABI/testing/sysfs-devices-soc‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ Description:
2626
Read-only attribute common to all SoCs. Contains SoC family name
2727
(e.g. DB8500).
2828

29+
What: /sys/devices/socX/serial_number
30+
Date: January 2019
31+
contact: Bjorn Andersson <bjorn.andersson@linaro.org>
32+
Description:
33+
Read-only attribute supported by most SoCs. Contains the SoC's
34+
serial number, if available.
35+
2936
What: /sys/devices/socX/soc_id
3037
Date: January 2012
3138
contact: Lee Jones <lee.jones@linaro.org>

‎drivers/base/soc.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static struct bus_type soc_bus_type = {
3333

3434
static DEVICE_ATTR(machine, S_IRUGO, soc_info_get, NULL);
3535
static DEVICE_ATTR(family, S_IRUGO, soc_info_get, NULL);
36+
static DEVICE_ATTR(serial_number, S_IRUGO, soc_info_get, NULL);
3637
static DEVICE_ATTR(soc_id, S_IRUGO, soc_info_get, NULL);
3738
static DEVICE_ATTR(revision, S_IRUGO, soc_info_get, NULL);
3839

@@ -57,6 +58,9 @@ static umode_t soc_attribute_mode(struct kobject *kobj,
5758
if ((attr == &dev_attr_revision.attr)
5859
&& (soc_dev->attr->revision != NULL))
5960
return attr->mode;
61+
if ((attr == &dev_attr_serial_number.attr)
62+
&& (soc_dev->attr->serial_number != NULL))
63+
return attr->mode;
6064
if ((attr == &dev_attr_soc_id.attr)
6165
&& (soc_dev->attr->soc_id != NULL))
6266
return attr->mode;
@@ -77,6 +81,8 @@ static ssize_t soc_info_get(struct device *dev,
7781
return sprintf(buf, "%s\n", soc_dev->attr->family);
7882
if (attr == &dev_attr_revision)
7983
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);
8086
if (attr == &dev_attr_soc_id)
8187
return sprintf(buf, "%s\n", soc_dev->attr->soc_id);
8288

@@ -87,6 +93,7 @@ static ssize_t soc_info_get(struct device *dev,
8793
static struct attribute *soc_attr[] = {
8894
&dev_attr_machine.attr,
8995
&dev_attr_family.attr,
96+
&dev_attr_serial_number.attr,
9097
&dev_attr_soc_id.attr,
9198
&dev_attr_revision.attr,
9299
NULL,

‎include/linux/sys_soc.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ struct soc_device_attribute {
1212
const char *machine;
1313
const char *family;
1414
const char *revision;
15+
const char *serial_number;
1516
const char *soc_id;
1617
const void *data;
1718
};

0 commit comments

Comments
 (0)