From patchwork Wed Feb 20 04:58:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vaishali Thakkar X-Patchwork-Id: 158756 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4490165jaa; Tue, 19 Feb 2019 20:58:23 -0800 (PST) X-Google-Smtp-Source: AHgI3IYOWyFXuBRkM4BHQtcKZMwytH6oIUYcDcyaF0u5i3BxuIeXxImEV36HW0Cn5qkhg+oY2fpD X-Received: by 2002:a17:902:7608:: with SMTP id k8mr34094023pll.245.1550638703704; Tue, 19 Feb 2019 20:58:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550638703; cv=none; d=google.com; s=arc-20160816; b=01r2b/o1rTj8u14AF4FJ4p+qmf5STIZWaXDi0NMpXkk6+QEjNLryrThAcoTujhdIhP ziAzszFvbtFQXYcMmPCC2UbHT1810iVbVCIo046+nL2h7PCgv1vyNOiQuTT4qB96bPeu mEEM7C1i03qsSwidku3rAkJ4k0QOLIG4a4jzaYlErwukRQvl38Jr7pBahI+vgcrXcC5s gfHytacQOeb+S6Bnw2RnetlqJ+t/snkZzmdoxNzcUKnAaKmlC669o5PKi7puJWYzoMLA V+qTeuVOtgLNNoxPzyTvXwzRAPQb34PlB+U5QE+UevuixsIBOZ1pQrPLB9LOJ7pno0eo 2k7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=1pBHjk3updZIvXBgasb0eUsMOw684uPryESYhpgXWVg=; b=oQeTrt+dAG8dIJUUeksa0W5zW0lnMTAwpIPFEc9TocLOnjXZA5U0u3E+dy+Piiv6kg sQ1DJeWgFfsCJ6oZh/+Zd7rRq98V0lfwP6UvgO7buiKMLVPC66jC4xTydXtan9fLZB0z 2sj4Qgk+wz4UqYNUvFW7WMgEuim+NWb2jt+Gwe/cqS24ejj9/UmShtV5AqFXgpZaFSn7 wkrovBSuuY+w8Jq5yW74Zfd17rKgSg8tvL5UYsJiB4f8PgukK5+Dy9luO2V5pSSgLvio jTv9bEpc6tL+QPEg1dOgC6VXyg+4S0xV8WCwJVRJ9JvIxbZiSeYcRZxhfM+ZQ88bhLGl gI0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WPHepq86; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l186si16392001pge.482.2019.02.19.20.58.23; Tue, 19 Feb 2019 20:58:23 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WPHepq86; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730436AbfBTE6W (ORCPT + 15 others); Tue, 19 Feb 2019 23:58:22 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:44035 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728979AbfBTE6W (ORCPT ); Tue, 19 Feb 2019 23:58:22 -0500 Received: by mail-pf1-f195.google.com with SMTP id a3so1483694pff.11 for ; Tue, 19 Feb 2019 20:58:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=1pBHjk3updZIvXBgasb0eUsMOw684uPryESYhpgXWVg=; b=WPHepq86NLZctZfA8K7H+3xY6wWkQSQm+Nc1GYEetQqkjVaJycNmhVBgfm5MLpPMpl p9Q4yiDZCotJg8JtIhJ/mvKf/rAogN72vfY+44FCX4JnIy91y4JZbE/IqEdEJBbpddiN b0xDS3hEJFkQqh9wmuAn9+Qh0sqGve9JHmQnfxoFXCnXdzw4nlp6GtjX5FjcudiVmmzz Fj58Kbkb9ASzxNovZfvEkjMfMUryfzT5rjZ8m08Do3srEL7modXZcg6UTiLPUDdYv8GQ VOm0ELpy21tZQO4CBZ+at6CMrUhcBP73OTVMacDgWWRLs1AKGVx30De+OI5urjc/UcOn BsQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=1pBHjk3updZIvXBgasb0eUsMOw684uPryESYhpgXWVg=; b=FtO0Itk9d3aSM6maAEPICfzrRSFsEWeoFl9Gd3l9RRlQdXV6JDDI9agyH1NmxLkbYJ kv+bWRrRwtuNeKixPoQ1ZzOzqsWIMmvJAAiXZs6CmXFUaYCbFKy5Fpok6hcMEDOJH+GE Rqevq0D3aDh+wcnQxyBXPYpjgarNwozi5mCK9JP/poECm1U6XZtfVVPv4ti3du2OFkqW QcrOSzi030JI7ExApQu1W8F0YQ2NoV5ysoAR/08R9tJORUPWoSxN/i12+lta5iFs4BPO n6GXoAINHHapz2smWTRupsbwpKsZx06Fp2SvKCqptf89aZvm6W+7C7aWZA2pJwbBRVlJ TANQ== X-Gm-Message-State: AHQUAua7CNNC/biqrStCLfeBjgDyzYKef4C+FwiLCFhsCRUFjTjw3Uer C2qrJSaUuLivHg1U9Zuk+VScbw== X-Received: by 2002:a63:fd07:: with SMTP id d7mr26814868pgh.163.1550638701826; Tue, 19 Feb 2019 20:58:21 -0800 (PST) Received: from localhost.localdomain ([116.75.87.120]) by smtp.gmail.com with ESMTPSA id b70sm22464879pfm.6.2019.02.19.20.58.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 20:58:21 -0800 (PST) From: Vaishali Thakkar To: andy.gross@linaro.org Cc: david.brown@linaro.org, gregkh@linuxfoundation.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org, bjorn.andersson@linaro.org, vkoul@kernel.org, Vaishali Thakkar Subject: [PATCH v2 1/5] base: soc: Add serial_number attribute to soc Date: Wed, 20 Feb 2019 10:28:13 +0530 Message-Id: <20190220045813.6756-1-vaishali.thakkar@linaro.org> X-Mailer: git-send-email 2.17.1 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Bjorn Andersson 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 Signed-off-by: Vaishali Thakkar --- Changes since v1: - Make comment more clear for the case when serial number is not available --- Documentation/ABI/testing/sysfs-devices-soc | 7 +++++++ drivers/base/soc.c | 7 +++++++ include/linux/sys_soc.h | 1 + 3 files changed, 15 insertions(+) -- 2.17.1 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: 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 +Description: + Read-only attribute supported by most SoCs. Contains the SoC's + serial number, if available. + What: /sys/devices/socX/soc_id Date: January 2012 contact: Lee Jones 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; };