diff options
Diffstat (limited to 'drivers/rapidio/rio-sysfs.c')
-rw-r--r-- | drivers/rapidio/rio-sysfs.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/drivers/rapidio/rio-sysfs.c b/drivers/rapidio/rio-sysfs.c index 00b475658356..137ed93ee33f 100644 --- a/drivers/rapidio/rio-sysfs.c +++ b/drivers/rapidio/rio-sysfs.c | |||
@@ -40,9 +40,6 @@ static ssize_t routes_show(struct device *dev, struct device_attribute *attr, ch | |||
40 | char *str = buf; | 40 | char *str = buf; |
41 | int i; | 41 | int i; |
42 | 42 | ||
43 | if (!rdev->rswitch) | ||
44 | goto out; | ||
45 | |||
46 | for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size); | 43 | for (i = 0; i < RIO_MAX_ROUTE_ENTRIES(rdev->net->hport->sys_size); |
47 | i++) { | 44 | i++) { |
48 | if (rdev->rswitch->route_table[i] == RIO_INVALID_ROUTE) | 45 | if (rdev->rswitch->route_table[i] == RIO_INVALID_ROUTE) |
@@ -52,7 +49,6 @@ static ssize_t routes_show(struct device *dev, struct device_attribute *attr, ch | |||
52 | rdev->rswitch->route_table[i]); | 49 | rdev->rswitch->route_table[i]); |
53 | } | 50 | } |
54 | 51 | ||
55 | out: | ||
56 | return (str - buf); | 52 | return (str - buf); |
57 | } | 53 | } |
58 | 54 | ||
@@ -63,10 +59,11 @@ struct device_attribute rio_dev_attrs[] = { | |||
63 | __ATTR_RO(asm_did), | 59 | __ATTR_RO(asm_did), |
64 | __ATTR_RO(asm_vid), | 60 | __ATTR_RO(asm_vid), |
65 | __ATTR_RO(asm_rev), | 61 | __ATTR_RO(asm_rev), |
66 | __ATTR_RO(routes), | ||
67 | __ATTR_NULL, | 62 | __ATTR_NULL, |
68 | }; | 63 | }; |
69 | 64 | ||
65 | static DEVICE_ATTR(routes, S_IRUGO, routes_show, NULL); | ||
66 | |||
70 | static ssize_t | 67 | static ssize_t |
71 | rio_read_config(struct file *filp, struct kobject *kobj, | 68 | rio_read_config(struct file *filp, struct kobject *kobj, |
72 | struct bin_attribute *bin_attr, | 69 | struct bin_attribute *bin_attr, |
@@ -218,7 +215,17 @@ int rio_create_sysfs_dev_files(struct rio_dev *rdev) | |||
218 | { | 215 | { |
219 | int err = 0; | 216 | int err = 0; |
220 | 217 | ||
221 | err = sysfs_create_bin_file(&rdev->dev.kobj, &rio_config_attr); | 218 | err = device_create_bin_file(&rdev->dev, &rio_config_attr); |
219 | |||
220 | if (!err && rdev->rswitch) { | ||
221 | err = device_create_file(&rdev->dev, &dev_attr_routes); | ||
222 | if (!err && rdev->rswitch->sw_sysfs) | ||
223 | err = rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_CREATE); | ||
224 | } | ||
225 | |||
226 | if (err) | ||
227 | pr_warning("RIO: Failed to create attribute file(s) for %s\n", | ||
228 | rio_name(rdev)); | ||
222 | 229 | ||
223 | return err; | 230 | return err; |
224 | } | 231 | } |
@@ -231,5 +238,10 @@ int rio_create_sysfs_dev_files(struct rio_dev *rdev) | |||
231 | */ | 238 | */ |
232 | void rio_remove_sysfs_dev_files(struct rio_dev *rdev) | 239 | void rio_remove_sysfs_dev_files(struct rio_dev *rdev) |
233 | { | 240 | { |
234 | sysfs_remove_bin_file(&rdev->dev.kobj, &rio_config_attr); | 241 | device_remove_bin_file(&rdev->dev, &rio_config_attr); |
242 | if (rdev->rswitch) { | ||
243 | device_remove_file(&rdev->dev, &dev_attr_routes); | ||
244 | if (rdev->rswitch->sw_sysfs) | ||
245 | rdev->rswitch->sw_sysfs(rdev, RIO_SW_SYSFS_REMOVE); | ||
246 | } | ||
235 | } | 247 | } |