aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rapidio/rio-sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rapidio/rio-sysfs.c')
-rw-r--r--drivers/rapidio/rio-sysfs.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c
index 1269fbd2deca..4dbe360989be 100644
--- a/drivers/rapidio/rio-sysfs.c
+++ b/drivers/rapidio/rio-sysfs.c
@@ -14,6 +14,7 @@
14#include <linux/rio.h> 14#include <linux/rio.h>
15#include <linux/rio_drv.h> 15#include <linux/rio_drv.h>
16#include <linux/stat.h> 16#include <linux/stat.h>
17#include <linux/capability.h>
17 18
18#include "rio.h" 19#include "rio.h"
19 20
@@ -33,6 +34,8 @@ rio_config_attr(device_rev, "0x%08x\n");
33rio_config_attr(asm_did, "0x%04x\n"); 34rio_config_attr(asm_did, "0x%04x\n");
34rio_config_attr(asm_vid, "0x%04x\n"); 35rio_config_attr(asm_vid, "0x%04x\n");
35rio_config_attr(asm_rev, "0x%04x\n"); 36rio_config_attr(asm_rev, "0x%04x\n");
37rio_config_attr(destid, "0x%04x\n");
38rio_config_attr(hopcount, "0x%02x\n");
36 39
37static ssize_t routes_show(struct device *dev, struct device_attribute *attr, char *buf) 40static ssize_t routes_show(struct device *dev, struct device_attribute *attr, char *buf)
38{ 41{
@@ -52,6 +55,35 @@ static ssize_t routes_show(struct device *dev, struct device_attribute *attr, ch
52 return (str - buf); 55 return (str - buf);
53} 56}
54 57
58static ssize_t lprev_show(struct device *dev,
59 struct device_attribute *attr, char *buf)
60{
61 struct rio_dev *rdev = to_rio_dev(dev);
62
63 return sprintf(buf, "%s\n",
64 (rdev->prev) ? rio_name(rdev->prev) : "root");
65}
66
67static ssize_t lnext_show(struct device *dev,
68 struct device_attribute *attr, char *buf)
69{
70 struct rio_dev *rdev = to_rio_dev(dev);
71 char *str = buf;
72 int i;
73
74 if (rdev->pef & RIO_PEF_SWITCH) {
75 for (i = 0; i < RIO_GET_TOTAL_PORTS(rdev->swpinfo); i++) {
76 if (rdev->rswitch->nextdev[i])
77 str += sprintf(str, "%s\n",
78 rio_name(rdev->rswitch->nextdev[i]));
79 else
80 str += sprintf(str, "null\n");
81 }
82 }
83
84 return str - buf;
85}
86
55struct device_attribute rio_dev_attrs[] = { 87struct device_attribute rio_dev_attrs[] = {
56 __ATTR_RO(did), 88 __ATTR_RO(did),
57 __ATTR_RO(vid), 89 __ATTR_RO(vid),
@@ -59,10 +91,14 @@ struct device_attribute rio_dev_attrs[] = {
59 __ATTR_RO(asm_did), 91 __ATTR_RO(asm_did),
60 __ATTR_RO(asm_vid), 92 __ATTR_RO(asm_vid),
61 __ATTR_RO(asm_rev), 93 __ATTR_RO(asm_rev),
94 __ATTR_RO(lprev),
95 __ATTR_RO(destid),
62 __ATTR_NULL, 96 __ATTR_NULL,
63}; 97};
64 98
65static DEVICE_ATTR(routes, S_IRUGO, routes_show, NULL); 99static DEVICE_ATTR(routes, S_IRUGO, routes_show, NULL);
100static DEVICE_ATTR(lnext, S_IRUGO, lnext_show, NULL);
101static DEVICE_ATTR(hopcount, S_IRUGO, hopcount_show, NULL);
66 102
67static ssize_t 103static ssize_t
68rio_read_config(struct file *filp, struct kobject *kobj, 104rio_read_config(struct file *filp, struct kobject *kobj,
@@ -218,7 +254,9 @@ int rio_create_sysfs_dev_files(struct rio_dev *rdev)
218 err = device_create_bin_file(&rdev->dev, &rio_config_attr); 254 err = device_create_bin_file(&rdev->dev, &rio_config_attr);
219 255
220 if (!err && (rdev->pef & RIO_PEF_SWITCH)) { 256 if (!err && (rdev->pef & RIO_PEF_SWITCH)) {
221 err = device_create_file(&rdev->dev, &dev_attr_routes); 257 err |= device_create_file(&rdev->dev, &dev_attr_routes);
258 err |= device_create_file(&rdev->dev, &dev_attr_lnext);
259 err |= device_create_file(&rdev->dev, &dev_attr_hopcount);
222 if (!err && rdev->rswitch->sw_sysfs) 260 if (!err && rdev->rswitch->sw_sysfs)
223 err = rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_CREATE); 261 err = rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_CREATE);
224 } 262 }
@@ -241,6 +279,8 @@ void rio_remove_sysfs_dev_files(struct rio_dev *rdev)
241 device_remove_bin_file(&rdev->dev, &rio_config_attr); 279 device_remove_bin_file(&rdev->dev, &rio_config_attr);
242 if (rdev->pef & RIO_PEF_SWITCH) { 280 if (rdev->pef & RIO_PEF_SWITCH) {
243 device_remove_file(&rdev->dev, &dev_attr_routes); 281 device_remove_file(&rdev->dev, &dev_attr_routes);
282 device_remove_file(&rdev->dev, &dev_attr_lnext);
283 device_remove_file(&rdev->dev, &dev_attr_hopcount);
244 if (rdev->rswitch->sw_sysfs) 284 if (rdev->rswitch->sw_sysfs)
245 rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_REMOVE); 285 rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_REMOVE);
246 } 286 }