Re: [PATCH 1/5] base: soc: Add serial_number attribute to soc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Feb 14, 2019 at 4:41 AM Vaishali Thakkar
<vaishali.thakkar@xxxxxxxxxx> wrote:
>
> From: Bjorn Andersson <bjorn.andersson@xxxxxxxxxx>
>
> 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.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@xxxxxxxxxx>
> Signed-off-by: Vaishali Thakkar <vaishali.thakkar@xxxxxxxxxx>
> ---
>  Documentation/ABI/testing/sysfs-devices-soc | 7 +++++++
>  drivers/base/soc.c                          | 7 +++++++
>  include/linux/sys_soc.h                     | 1 +
>  3 files changed, 15 insertions(+)
>
> diff --git a/Documentation/ABI/testing/sysfs-devices-soc b/Documentation/ABI/testing/sysfs-devices-soc
> index 6d9cc253f2b2..919109697bf0 100644
> --- a/Documentation/ABI/testing/sysfs-devices-soc
> +++ b/Documentation/ABI/testing/sysfs-devices-soc
> @@ -26,6 +26,13 @@ Description:
>                 Read-only attribute common to all SoCs. Contains SoC family name
>                 (e.g. DB8500).
>
> +What:          /sys/devices/socX/serial_number
> +Date:          January 2019
> +contact:       Bjorn Andersson <bjorn.andersson@xxxxxxxxxx>
> +Description:
> +               Read-only attribute supported by most SoCs. Contains the SoC's
> +               serial number.

Do I understand it correctly that the attr is not present if the
serial number is not there?

If so, you should say that here.

> +
>  What:          /sys/devices/socX/soc_id
>  Date:          January 2012
>  contact:       Lee Jones <lee.jones@xxxxxxxxxx>
> 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 = {
>
>  static DEVICE_ATTR(machine,  S_IRUGO, soc_info_get,  NULL);
>  static DEVICE_ATTR(family,   S_IRUGO, soc_info_get,  NULL);
> +static DEVICE_ATTR(serial_number, S_IRUGO, soc_info_get,  NULL);
>  static DEVICE_ATTR(soc_id,   S_IRUGO, soc_info_get,  NULL);
>  static DEVICE_ATTR(revision, S_IRUGO, soc_info_get,  NULL);
>
> @@ -57,6 +58,9 @@ static umode_t soc_attribute_mode(struct kobject *kobj,
>         if ((attr == &dev_attr_revision.attr)
>             && (soc_dev->attr->revision != NULL))
>                 return attr->mode;
> +       if ((attr == &dev_attr_serial_number.attr)
> +           && (soc_dev->attr->serial_number != NULL))
> +               return attr->mode;
>         if ((attr == &dev_attr_soc_id.attr)
>             && (soc_dev->attr->soc_id != NULL))
>                 return attr->mode;
> @@ -77,6 +81,8 @@ static ssize_t soc_info_get(struct device *dev,
>                 return sprintf(buf, "%s\n", soc_dev->attr->family);
>         if (attr == &dev_attr_revision)
>                 return sprintf(buf, "%s\n", soc_dev->attr->revision);
> +       if (attr == &dev_attr_serial_number)
> +               return sprintf(buf, "%s\n", soc_dev->attr->serial_number);
>         if (attr == &dev_attr_soc_id)
>                 return sprintf(buf, "%s\n", soc_dev->attr->soc_id);
>
> @@ -87,6 +93,7 @@ static ssize_t soc_info_get(struct device *dev,
>  static struct attribute *soc_attr[] = {
>         &dev_attr_machine.attr,
>         &dev_attr_family.attr,
> +       &dev_attr_serial_number.attr,
>         &dev_attr_soc_id.attr,
>         &dev_attr_revision.attr,
>         NULL,
> diff --git a/include/linux/sys_soc.h b/include/linux/sys_soc.h
> index bed223b70217..2a13bc033bd6 100644
> --- a/include/linux/sys_soc.h
> +++ b/include/linux/sys_soc.h
> @@ -12,6 +12,7 @@ struct soc_device_attribute {
>         const char *machine;
>         const char *family;
>         const char *revision;
> +       const char *serial_number;
>         const char *soc_id;
>         const void *data;
>  };
> --
> 2.17.1
>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux