aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/xenbus
diff options
context:
space:
mode:
authorBastian Blank <waldi@debian.org>2011-06-29 08:39:26 -0400
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>2011-06-30 12:15:29 -0400
commitcc85e93342c030f8ba07f572afa159ec4518231f (patch)
tree329d1450de5086b9db0b9bfd8fad495ca823a4a3 /drivers/xen/xenbus
parent08b8bfc1c649cf82edf43f686cbb9a4bac809679 (diff)
xen: Populate xenbus device attributes
The xenbus bus type uses device_create_file to assign all used device attributes. However it does not remove them when the device goes away. This patch uses the dev_attrs field of the bus type to specify default attributes for all devices. Signed-off-by: Bastian Blank <waldi@debian.org> Acked-by: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Diffstat (limited to 'drivers/xen/xenbus')
-rw-r--r--drivers/xen/xenbus/xenbus_probe.c41
-rw-r--r--drivers/xen/xenbus/xenbus_probe.h2
-rw-r--r--drivers/xen/xenbus/xenbus_probe_backend.c6
-rw-r--r--drivers/xen/xenbus/xenbus_probe_frontend.c6
4 files changed, 18 insertions, 37 deletions
diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c
index 739769551e33..2ed0b045c69a 100644
--- a/drivers/xen/xenbus/xenbus_probe.c
+++ b/drivers/xen/xenbus/xenbus_probe.c
@@ -378,26 +378,31 @@ static void xenbus_dev_release(struct device *dev)
378 kfree(to_xenbus_device(dev)); 378 kfree(to_xenbus_device(dev));
379} 379}
380 380
381static ssize_t xendev_show_nodename(struct device *dev, 381static ssize_t nodename_show(struct device *dev,
382 struct device_attribute *attr, char *buf) 382 struct device_attribute *attr, char *buf)
383{ 383{
384 return sprintf(buf, "%s\n", to_xenbus_device(dev)->nodename); 384 return sprintf(buf, "%s\n", to_xenbus_device(dev)->nodename);
385} 385}
386static DEVICE_ATTR(nodename, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_nodename, NULL);
387 386
388static ssize_t xendev_show_devtype(struct device *dev, 387static ssize_t devtype_show(struct device *dev,
389 struct device_attribute *attr, char *buf) 388 struct device_attribute *attr, char *buf)
390{ 389{
391 return sprintf(buf, "%s\n", to_xenbus_device(dev)->devicetype); 390 return sprintf(buf, "%s\n", to_xenbus_device(dev)->devicetype);
392} 391}
393static DEVICE_ATTR(devtype, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_devtype, NULL);
394 392
395static ssize_t xendev_show_modalias(struct device *dev, 393static ssize_t modalias_show(struct device *dev,
396 struct device_attribute *attr, char *buf) 394 struct device_attribute *attr, char *buf)
397{ 395{
398 return sprintf(buf, "xen:%s\n", to_xenbus_device(dev)->devicetype); 396 return sprintf(buf, "xen:%s\n", to_xenbus_device(dev)->devicetype);
399} 397}
400static DEVICE_ATTR(modalias, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_modalias, NULL); 398
399struct device_attribute xenbus_dev_attrs[] = {
400 __ATTR_RO(nodename),
401 __ATTR_RO(devtype),
402 __ATTR_RO(modalias),
403 __ATTR_NULL
404};
405EXPORT_SYMBOL_GPL(xenbus_dev_attrs);
401 406
402int xenbus_probe_node(struct xen_bus_type *bus, 407int xenbus_probe_node(struct xen_bus_type *bus,
403 const char *type, 408 const char *type,
@@ -449,25 +454,7 @@ int xenbus_probe_node(struct xen_bus_type *bus,
449 if (err) 454 if (err)
450 goto fail; 455 goto fail;
451 456
452 err = device_create_file(&xendev->dev, &dev_attr_nodename);
453 if (err)
454 goto fail_unregister;
455
456 err = device_create_file(&xendev->dev, &dev_attr_devtype);
457 if (err)
458 goto fail_remove_nodename;
459
460 err = device_create_file(&xendev->dev, &dev_attr_modalias);
461 if (err)
462 goto fail_remove_devtype;
463
464 return 0; 457 return 0;
465fail_remove_devtype:
466 device_remove_file(&xendev->dev, &dev_attr_devtype);
467fail_remove_nodename:
468 device_remove_file(&xendev->dev, &dev_attr_nodename);
469fail_unregister:
470 device_unregister(&xendev->dev);
471fail: 458fail:
472 kfree(xendev); 459 kfree(xendev);
473 return err; 460 return err;
diff --git a/drivers/xen/xenbus/xenbus_probe.h b/drivers/xen/xenbus/xenbus_probe.h
index 888b9900ca08..b814935378c7 100644
--- a/drivers/xen/xenbus/xenbus_probe.h
+++ b/drivers/xen/xenbus/xenbus_probe.h
@@ -48,6 +48,8 @@ struct xen_bus_type
48 struct bus_type bus; 48 struct bus_type bus;
49}; 49};
50 50
51extern struct device_attribute xenbus_dev_attrs[];
52
51extern int xenbus_match(struct device *_dev, struct device_driver *_drv); 53extern int xenbus_match(struct device *_dev, struct device_driver *_drv);
52extern int xenbus_dev_probe(struct device *_dev); 54extern int xenbus_dev_probe(struct device *_dev);
53extern int xenbus_dev_remove(struct device *_dev); 55extern int xenbus_dev_remove(struct device *_dev);
diff --git a/drivers/xen/xenbus/xenbus_probe_backend.c b/drivers/xen/xenbus/xenbus_probe_backend.c
index 6cf467bf63ec..ec510e562820 100644
--- a/drivers/xen/xenbus/xenbus_probe_backend.c
+++ b/drivers/xen/xenbus/xenbus_probe_backend.c
@@ -183,10 +183,6 @@ static void frontend_changed(struct xenbus_watch *watch,
183 xenbus_otherend_changed(watch, vec, len, 0); 183 xenbus_otherend_changed(watch, vec, len, 0);
184} 184}
185 185
186static struct device_attribute xenbus_backend_dev_attrs[] = {
187 __ATTR_NULL
188};
189
190static struct xen_bus_type xenbus_backend = { 186static struct xen_bus_type xenbus_backend = {
191 .root = "backend", 187 .root = "backend",
192 .levels = 3, /* backend/type/<frontend>/<id> */ 188 .levels = 3, /* backend/type/<frontend>/<id> */
@@ -200,7 +196,7 @@ static struct xen_bus_type xenbus_backend = {
200 .probe = xenbus_dev_probe, 196 .probe = xenbus_dev_probe,
201 .remove = xenbus_dev_remove, 197 .remove = xenbus_dev_remove,
202 .shutdown = xenbus_dev_shutdown, 198 .shutdown = xenbus_dev_shutdown,
203 .dev_attrs = xenbus_backend_dev_attrs, 199 .dev_attrs = xenbus_dev_attrs,
204 }, 200 },
205}; 201};
206 202
diff --git a/drivers/xen/xenbus/xenbus_probe_frontend.c b/drivers/xen/xenbus/xenbus_probe_frontend.c
index b6a2690c9d49..ed2ba474a560 100644
--- a/drivers/xen/xenbus/xenbus_probe_frontend.c
+++ b/drivers/xen/xenbus/xenbus_probe_frontend.c
@@ -81,10 +81,6 @@ static void backend_changed(struct xenbus_watch *watch,
81 xenbus_otherend_changed(watch, vec, len, 1); 81 xenbus_otherend_changed(watch, vec, len, 1);
82} 82}
83 83
84static struct device_attribute xenbus_frontend_dev_attrs[] = {
85 __ATTR_NULL
86};
87
88static const struct dev_pm_ops xenbus_pm_ops = { 84static const struct dev_pm_ops xenbus_pm_ops = {
89 .suspend = xenbus_dev_suspend, 85 .suspend = xenbus_dev_suspend,
90 .resume = xenbus_dev_resume, 86 .resume = xenbus_dev_resume,
@@ -106,7 +102,7 @@ static struct xen_bus_type xenbus_frontend = {
106 .probe = xenbus_dev_probe, 102 .probe = xenbus_dev_probe,
107 .remove = xenbus_dev_remove, 103 .remove = xenbus_dev_remove,
108 .shutdown = xenbus_dev_shutdown, 104 .shutdown = xenbus_dev_shutdown,
109 .dev_attrs = xenbus_frontend_dev_attrs, 105 .dev_attrs = xenbus_dev_attrs,
110 106
111 .pm = &xenbus_pm_ops, 107 .pm = &xenbus_pm_ops,
112 }, 108 },