diff options
author | Bastian Blank <waldi@debian.org> | 2011-06-29 08:39:26 -0400 |
---|---|---|
committer | Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 2011-06-30 12:15:29 -0400 |
commit | cc85e93342c030f8ba07f572afa159ec4518231f (patch) | |
tree | 329d1450de5086b9db0b9bfd8fad495ca823a4a3 /drivers/xen/xenbus/xenbus_probe.c | |
parent | 08b8bfc1c649cf82edf43f686cbb9a4bac809679 (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/xenbus_probe.c')
-rw-r--r-- | drivers/xen/xenbus/xenbus_probe.c | 41 |
1 files changed, 14 insertions, 27 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 | ||
381 | static ssize_t xendev_show_nodename(struct device *dev, | 381 | static 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 | } |
386 | static DEVICE_ATTR(nodename, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_nodename, NULL); | ||
387 | 386 | ||
388 | static ssize_t xendev_show_devtype(struct device *dev, | 387 | static 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 | } |
393 | static DEVICE_ATTR(devtype, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_devtype, NULL); | ||
394 | 392 | ||
395 | static ssize_t xendev_show_modalias(struct device *dev, | 393 | static 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 | } |
400 | static DEVICE_ATTR(modalias, S_IRUSR | S_IRGRP | S_IROTH, xendev_show_modalias, NULL); | 398 | |
399 | struct device_attribute xenbus_dev_attrs[] = { | ||
400 | __ATTR_RO(nodename), | ||
401 | __ATTR_RO(devtype), | ||
402 | __ATTR_RO(modalias), | ||
403 | __ATTR_NULL | ||
404 | }; | ||
405 | EXPORT_SYMBOL_GPL(xenbus_dev_attrs); | ||
401 | 406 | ||
402 | int xenbus_probe_node(struct xen_bus_type *bus, | 407 | int 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; |
465 | fail_remove_devtype: | ||
466 | device_remove_file(&xendev->dev, &dev_attr_devtype); | ||
467 | fail_remove_nodename: | ||
468 | device_remove_file(&xendev->dev, &dev_attr_nodename); | ||
469 | fail_unregister: | ||
470 | device_unregister(&xendev->dev); | ||
471 | fail: | 458 | fail: |
472 | kfree(xendev); | 459 | kfree(xendev); |
473 | return err; | 460 | return err; |