[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20191210145345.11616-10-sudeep.holla@arm.com>
Date: Tue, 10 Dec 2019 14:53:39 +0000
From: Sudeep Holla <sudeep.holla@....com>
To: linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Cc: Sudeep Holla <sudeep.holla@....com>,
Cristian Marussi <cristian.marussi@....com>
Subject: [PATCH 09/15] firmware: arm_scmi: Add scmi protocol version and id device attributes
Linux kernel bus driver management layer provides way to add set of
default attributes of the devices on the bus. Using the same, let's add
the scmi per protocol version and id attributes to the sysfs.
It helps to identify the individual protocol details from the sysfs
entries similar to the SCMI protocol and firmware version.
Signed-off-by: Sudeep Holla <sudeep.holla@....com>
---
drivers/firmware/arm_scmi/bus.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/firmware/arm_scmi/bus.c b/drivers/firmware/arm_scmi/bus.c
index f619da2634a6..ed0ed02f7158 100644
--- a/drivers/firmware/arm_scmi/bus.c
+++ b/drivers/firmware/arm_scmi/bus.c
@@ -92,11 +92,38 @@ static int scmi_dev_remove(struct device *dev)
return 0;
}
+static ssize_t protocol_version_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct scmi_device *scmi_dev = to_scmi_dev(dev);
+
+ return sprintf(buf, "%u.%u\n", PROTOCOL_REV_MAJOR(scmi_dev->version),
+ PROTOCOL_REV_MINOR(scmi_dev->version));
+}
+static DEVICE_ATTR_RO(protocol_version);
+
+static ssize_t protocol_id_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct scmi_device *scmi_dev = to_scmi_dev(dev);
+
+ return sprintf(buf, "%u\n", scmi_dev->protocol_id);
+}
+static DEVICE_ATTR_RO(protocol_id);
+
+static struct attribute *versions_attrs[] = {
+ &dev_attr_protocol_version.attr,
+ &dev_attr_protocol_id.attr,
+ NULL,
+};
+ATTRIBUTE_GROUPS(versions);
+
static struct bus_type scmi_bus_type = {
.name = "scmi_protocol",
.match = scmi_dev_match,
.probe = scmi_dev_probe,
.remove = scmi_dev_remove,
+ .dev_groups = versions_groups,
};
int scmi_driver_register(struct scmi_driver *driver, struct module *owner,
--
2.17.1
Powered by blists - more mailing lists