aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/rapidio/rio-sysfs.c26
-rw-r--r--include/linux/rio.h6
2 files changed, 25 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
65static DEVICE_ATTR(routes, S_IRUGO, routes_show, NULL);
66
70static ssize_t 67static ssize_t
71rio_read_config(struct file *filp, struct kobject *kobj, 68rio_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 */
232void rio_remove_sysfs_dev_files(struct rio_dev *rdev) 239void 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}
diff --git a/include/linux/rio.h b/include/linux/rio.h
index 8d9e66dc7969..4fa5e3d2b117 100644
--- a/include/linux/rio.h
+++ b/include/linux/rio.h
@@ -218,6 +218,10 @@ struct rio_net {
218 unsigned char id; /* RIO network ID */ 218 unsigned char id; /* RIO network ID */
219}; 219};
220 220
221/* Definitions used by switch sysfs initialization callback */
222#define RIO_SW_SYSFS_CREATE 1 /* Create switch attributes */
223#define RIO_SW_SYSFS_REMOVE 0 /* Remove switch attributes */
224
221/** 225/**
222 * struct rio_switch - RIO switch info 226 * struct rio_switch - RIO switch info
223 * @node: Node in global list of switches 227 * @node: Node in global list of switches
@@ -234,6 +238,7 @@ struct rio_net {
234 * @get_domain: Callback for switch-specific domain get function 238 * @get_domain: Callback for switch-specific domain get function
235 * @em_init: Callback for switch-specific error management initialization function 239 * @em_init: Callback for switch-specific error management initialization function
236 * @em_handle: Callback for switch-specific error management handler function 240 * @em_handle: Callback for switch-specific error management handler function
241 * @sw_sysfs: Callback that initializes switch-specific sysfs attributes
237 * @nextdev: Array of per-port pointers to the next attached device 242 * @nextdev: Array of per-port pointers to the next attached device
238 */ 243 */
239struct rio_switch { 244struct rio_switch {
@@ -256,6 +261,7 @@ struct rio_switch {
256 u8 *sw_domain); 261 u8 *sw_domain);
257 int (*em_init) (struct rio_dev *dev); 262 int (*em_init) (struct rio_dev *dev);
258 int (*em_handle) (struct rio_dev *dev, u8 swport); 263 int (*em_handle) (struct rio_dev *dev, u8 swport);
264 int (*sw_sysfs) (struct rio_dev *dev, int create);
259 struct rio_dev *nextdev[0]; 265 struct rio_dev *nextdev[0];
260}; 266};
261 267