2010-11-27 22:47:11 +00:00
|
|
|
From 3cfa0a9d4b4cc30ec735c5c9535ff493bae24d08 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Hauke Mehrtens <hauke@hauke-m.de>
|
|
|
|
Date: Sat, 27 Nov 2010 18:14:23 +0100
|
|
|
|
Subject: [PATCH] ssb: Add sysfs attributes to ssb devices
|
|
|
|
|
|
|
|
Make it possible to read out the attributes, till now only show on
|
|
|
|
dmesg, through sysfs.
|
|
|
|
|
|
|
|
This patch was some time in OpenWrt.
|
|
|
|
|
|
|
|
Signed-off-by: Bernhard Loos <bernhardloos@googlemail.com>
|
|
|
|
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
|
|
|
|
---
|
|
|
|
drivers/ssb/main.c | 30 ++++++++++++++++++++++++++++++
|
|
|
|
1 files changed, 30 insertions(+), 0 deletions(-)
|
|
|
|
|
2010-11-10 19:01:07 +00:00
|
|
|
--- a/drivers/ssb/main.c
|
|
|
|
+++ b/drivers/ssb/main.c
|
2010-11-27 22:47:11 +00:00
|
|
|
@@ -383,6 +383,35 @@ static int ssb_device_uevent(struct devi
|
2010-11-10 19:01:07 +00:00
|
|
|
ssb_dev->id.revision);
|
|
|
|
}
|
|
|
|
|
2010-11-27 22:47:11 +00:00
|
|
|
+#define ssb_config_attr(attrib, field, format_string) \
|
|
|
|
+static ssize_t \
|
2010-11-10 19:01:07 +00:00
|
|
|
+attrib##_show(struct device *dev, struct device_attribute *attr, char *buf) \
|
2010-11-27 22:47:11 +00:00
|
|
|
+{ \
|
|
|
|
+ return sprintf(buf, format_string, dev_to_ssb_dev(dev)->field); \
|
2010-11-10 19:01:07 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+ssb_config_attr(core_num, core_index, "%u\n")
|
|
|
|
+ssb_config_attr(coreid, id.coreid, "0x%04x\n")
|
|
|
|
+ssb_config_attr(vendor, id.vendor, "0x%04x\n")
|
|
|
|
+ssb_config_attr(revision, id.revision, "%u\n")
|
|
|
|
+ssb_config_attr(irq, irq, "%u\n")
|
|
|
|
+static ssize_t
|
|
|
|
+name_show(struct device *dev, struct device_attribute *attr, char *buf)
|
|
|
|
+{
|
2010-11-27 22:47:11 +00:00
|
|
|
+ return sprintf(buf, "%s\n",
|
|
|
|
+ ssb_core_name(dev_to_ssb_dev(dev)->id.coreid));
|
2010-11-10 19:01:07 +00:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static struct device_attribute ssb_device_attrs[] = {
|
|
|
|
+ __ATTR_RO(name),
|
|
|
|
+ __ATTR_RO(core_num),
|
|
|
|
+ __ATTR_RO(coreid),
|
|
|
|
+ __ATTR_RO(vendor),
|
|
|
|
+ __ATTR_RO(revision),
|
|
|
|
+ __ATTR_RO(irq),
|
|
|
|
+ __ATTR_NULL,
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
static struct bus_type ssb_bustype = {
|
|
|
|
.name = "ssb",
|
|
|
|
.match = ssb_bus_match,
|
2010-11-27 22:47:11 +00:00
|
|
|
@@ -392,6 +421,7 @@ static struct bus_type ssb_bustype = {
|
2010-11-10 19:01:07 +00:00
|
|
|
.suspend = ssb_device_suspend,
|
|
|
|
.resume = ssb_device_resume,
|
|
|
|
.uevent = ssb_device_uevent,
|
|
|
|
+ .dev_attrs = ssb_device_attrs,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void ssb_buses_lock(void)
|