[target/generic]: refresh 2.6.38 patches with -rc2
[openwrt.git] / target / linux / brcm47xx / patches-2.6.37 / 950-sbb-sysfs-files.patch
1 From 3cfa0a9d4b4cc30ec735c5c9535ff493bae24d08 Mon Sep 17 00:00:00 2001
2 From: Hauke Mehrtens <hauke@hauke-m.de>
3 Date: Sat, 27 Nov 2010 18:14:23 +0100
4 Subject: [PATCH] ssb: Add sysfs attributes to ssb devices
5
6 Make it possible to read out the attributes, till now only show on
7 dmesg, through sysfs.
8
9 This patch was some time in OpenWrt.
10
11 Signed-off-by: Bernhard Loos <bernhardloos@googlemail.com>
12 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
13 ---
14 drivers/ssb/main.c | 30 ++++++++++++++++++++++++++++++
15 1 files changed, 30 insertions(+), 0 deletions(-)
16
17 --- a/drivers/ssb/main.c
18 +++ b/drivers/ssb/main.c
19 @@ -383,6 +383,35 @@ static int ssb_device_uevent(struct devi
20 ssb_dev->id.revision);
21 }
22
23 +#define ssb_config_attr(attrib, field, format_string) \
24 +static ssize_t \
25 +attrib##_show(struct device *dev, struct device_attribute *attr, char *buf) \
26 +{ \
27 + return sprintf(buf, format_string, dev_to_ssb_dev(dev)->field); \
28 +}
29 +
30 +ssb_config_attr(core_num, core_index, "%u\n")
31 +ssb_config_attr(coreid, id.coreid, "0x%04x\n")
32 +ssb_config_attr(vendor, id.vendor, "0x%04x\n")
33 +ssb_config_attr(revision, id.revision, "%u\n")
34 +ssb_config_attr(irq, irq, "%u\n")
35 +static ssize_t
36 +name_show(struct device *dev, struct device_attribute *attr, char *buf)
37 +{
38 + return sprintf(buf, "%s\n",
39 + ssb_core_name(dev_to_ssb_dev(dev)->id.coreid));
40 +}
41 +
42 +static struct device_attribute ssb_device_attrs[] = {
43 + __ATTR_RO(name),
44 + __ATTR_RO(core_num),
45 + __ATTR_RO(coreid),
46 + __ATTR_RO(vendor),
47 + __ATTR_RO(revision),
48 + __ATTR_RO(irq),
49 + __ATTR_NULL,
50 +};
51 +
52 static struct bus_type ssb_bustype = {
53 .name = "ssb",
54 .match = ssb_bus_match,
55 @@ -392,6 +421,7 @@ static struct bus_type ssb_bustype = {
56 .suspend = ssb_device_suspend,
57 .resume = ssb_device_resume,
58 .uevent = ssb_device_uevent,
59 + .dev_attrs = ssb_device_attrs,
60 };
61
62 static void ssb_buses_lock(void)
This page took 0.041428 seconds and 5 git commands to generate.