aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rapidio/rio-sysfs.c
diff options
context:
space:
mode:
authorAlexandre Bounine <alexandre.bounine@idt.com>2011-03-23 19:42:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-23 22:46:41 -0400
commitcd8b974fad4f993bde74d820f83bd0a88ad82491 (patch)
treefc68e756681d2fa1857a6ab56284d7e50db3ed3a /drivers/rapidio/rio-sysfs.c
parentcfaf346cb2741ca648d83527df173b759381e607 (diff)
rapidio: add new sysfs attributes
Add new sysfs attributes. 1. Routing information required to to reach the RIO device: destid - device destination ID (real for for endpoint, route for switch) hopcount - hopcount for maintenance requests (switches only) 2. device linking information: lprev - name of device that precedes the given device in the enumeration or discovery order (displayed along with of the port to which it is attached). lnext - names of devices (with corresponding port numbers) that are attached to the given device as next in the enumeration or discovery order (switches only) Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com> Cc: Kumar Gala <galak@kernel.crashing.org> Cc: Matt Porter <mporter@kernel.crashing.org> Cc: Li Yang <leoli@freescale.com> Cc: Thomas Moll <thomas.moll@sysgo.com> Cc: Micha Nelissen <micha@neli.hopto.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rapidio/rio-sysfs.c')
-rw-r--r--drivers/rapidio/rio-sysfs.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c
index 1269fbd2deca..0d894320e227 100644
--- a/drivers/rapidio/rio-sysfs.c
+++ b/drivers/rapidio/rio-sysfs.c
@@ -33,6 +33,8 @@ rio_config_attr(device_rev, "0x%08x\n");
33rio_config_attr(asm_did, "0x%04x\n"); 33rio_config_attr(asm_did, "0x%04x\n");
34rio_config_attr(asm_vid, "0x%04x\n"); 34rio_config_attr(asm_vid, "0x%04x\n");
35rio_config_attr(asm_rev, "0x%04x\n"); 35rio_config_attr(asm_rev, "0x%04x\n");
36rio_config_attr(destid, "0x%04x\n");
37rio_config_attr(hopcount, "0x%02x\n");
36 38
37static ssize_t routes_show(struct device *dev, struct device_attribute *attr, char *buf) 39static ssize_t routes_show(struct device *dev, struct device_attribute *attr, char *buf)
38{ 40{
@@ -52,6 +54,35 @@ static ssize_t routes_show(struct device *dev, struct device_attribute *attr, ch
52 return (str - buf); 54 return (str - buf);
53} 55}
54 56
57static ssize_t lprev_show(struct device *dev,
58 struct device_attribute *attr, char *buf)
59{
60 struct rio_dev *rdev = to_rio_dev(dev);
61
62 return sprintf(buf, "%s\n",
63 (rdev->prev) ? rio_name(rdev->prev) : "root");
64}
65
66static ssize_t lnext_show(struct device *dev,
67 struct device_attribute *attr, char *buf)
68{
69 struct rio_dev *rdev = to_rio_dev(dev);
70 char *str = buf;
71 int i;
72
73 if (rdev->pef & RIO_PEF_SWITCH) {
74 for (i = 0; i < RIO_GET_TOTAL_PORTS(rdev->swpinfo); i++) {
75 if (rdev->rswitch->nextdev[i])
76 str += sprintf(str, "%s\n",
77 rio_name(rdev->rswitch->nextdev[i]));
78 else
79 str += sprintf(str, "null\n");
80 }
81 }
82
83 return str - buf;
84}
85
55struct device_attribute rio_dev_attrs[] = { 86struct device_attribute rio_dev_attrs[] = {
56 __ATTR_RO(did), 87 __ATTR_RO(did),
57 __ATTR_RO(vid), 88 __ATTR_RO(vid),
@@ -59,10 +90,14 @@ struct device_attribute rio_dev_attrs[] = {
59 __ATTR_RO(asm_did), 90 __ATTR_RO(asm_did),
60 __ATTR_RO(asm_vid), 91 __ATTR_RO(asm_vid),
61 __ATTR_RO(asm_rev), 92 __ATTR_RO(asm_rev),
93 __ATTR_RO(lprev),
94 __ATTR_RO(destid),
62 __ATTR_NULL, 95 __ATTR_NULL,
63}; 96};
64 97
65static DEVICE_ATTR(routes, S_IRUGO, routes_show, NULL); 98static DEVICE_ATTR(routes, S_IRUGO, routes_show, NULL);
99static DEVICE_ATTR(lnext, S_IRUGO, lnext_show, NULL);
100static DEVICE_ATTR(hopcount, S_IRUGO, hopcount_show, NULL);
66 101
67static ssize_t 102static ssize_t
68rio_read_config(struct file *filp, struct kobject *kobj, 103rio_read_config(struct file *filp, struct kobject *kobj,
@@ -218,7 +253,9 @@ int rio_create_sysfs_dev_files(struct rio_dev *rdev)
218 err = device_create_bin_file(&rdev->dev, &rio_config_attr); 253 err = device_create_bin_file(&rdev->dev, &rio_config_attr);
219 254
220 if (!err && (rdev->pef & RIO_PEF_SWITCH)) { 255 if (!err && (rdev->pef & RIO_PEF_SWITCH)) {
221 err = device_create_file(&rdev->dev, &dev_attr_routes); 256 err |= device_create_file(&rdev->dev, &dev_attr_routes);
257 err |= device_create_file(&rdev->dev, &dev_attr_lnext);
258 err |= device_create_file(&rdev->dev, &dev_attr_hopcount);
222 if (!err && rdev->rswitch->sw_sysfs) 259 if (!err && rdev->rswitch->sw_sysfs)
223 err = rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_CREATE); 260 err = rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_CREATE);
224 } 261 }
@@ -241,6 +278,8 @@ void rio_remove_sysfs_dev_files(struct rio_dev *rdev)
241 device_remove_bin_file(&rdev->dev, &rio_config_attr); 278 device_remove_bin_file(&rdev->dev, &rio_config_attr);
242 if (rdev->pef & RIO_PEF_SWITCH) { 279 if (rdev->pef & RIO_PEF_SWITCH) {
243 device_remove_file(&rdev->dev, &dev_attr_routes); 280 device_remove_file(&rdev->dev, &dev_attr_routes);
281 device_remove_file(&rdev->dev, &dev_attr_lnext);
282 device_remove_file(&rdev->dev, &dev_attr_hopcount);
244 if (rdev->rswitch->sw_sysfs) 283 if (rdev->rswitch->sw_sysfs)
245 rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_REMOVE); 284 rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_REMOVE);
246 } 285 }