diff options
| author | Joe Jin <joe.jin@oracle.com> | 2018-08-28 10:56:08 -0400 |
|---|---|---|
| committer | Boris Ostrovsky <boris.ostrovsky@oracle.com> | 2018-08-28 17:37:40 -0400 |
| commit | 076e2cedd6ea4786569c35f8725b4efdc1ecf2f2 (patch) | |
| tree | d5c6d2f1523f5f130b94e3b63d656d1456c2daa4 | |
| parent | b2d7a075a1ccef2fb321d595802190c8e9b39004 (diff) | |
xen: export device state to sysfs
Export device state to sysfs to allow for easier get device state.
Signed-off-by: Joe Jin <joe.jin@oracle.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
| -rw-r--r-- | Documentation/ABI/stable/sysfs-bus-xen-backend | 9 | ||||
| -rw-r--r-- | drivers/xen/xenbus/xenbus_probe.c | 9 |
2 files changed, 18 insertions, 0 deletions
diff --git a/Documentation/ABI/stable/sysfs-bus-xen-backend b/Documentation/ABI/stable/sysfs-bus-xen-backend index 3d5951c8bf5f..e8b60bd766f7 100644 --- a/Documentation/ABI/stable/sysfs-bus-xen-backend +++ b/Documentation/ABI/stable/sysfs-bus-xen-backend | |||
| @@ -73,3 +73,12 @@ KernelVersion: 3.0 | |||
| 73 | Contact: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> | 73 | Contact: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> |
| 74 | Description: | 74 | Description: |
| 75 | Number of sectors written by the frontend. | 75 | Number of sectors written by the frontend. |
| 76 | |||
| 77 | What: /sys/bus/xen-backend/devices/*/state | ||
| 78 | Date: August 2018 | ||
| 79 | KernelVersion: 4.19 | ||
| 80 | Contact: Joe Jin <joe.jin@oracle.com> | ||
| 81 | Description: | ||
| 82 | The state of the device. One of: 'Unknown', | ||
| 83 | 'Initialising', 'Initialised', 'Connected', 'Closing', | ||
| 84 | 'Closed', 'Reconfiguring', 'Reconfigured'. | ||
diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c index f2088838f690..5b471889d723 100644 --- a/drivers/xen/xenbus/xenbus_probe.c +++ b/drivers/xen/xenbus/xenbus_probe.c | |||
| @@ -402,10 +402,19 @@ static ssize_t modalias_show(struct device *dev, | |||
| 402 | } | 402 | } |
| 403 | static DEVICE_ATTR_RO(modalias); | 403 | static DEVICE_ATTR_RO(modalias); |
| 404 | 404 | ||
| 405 | static ssize_t state_show(struct device *dev, | ||
| 406 | struct device_attribute *attr, char *buf) | ||
| 407 | { | ||
| 408 | return sprintf(buf, "%s\n", | ||
| 409 | xenbus_strstate(to_xenbus_device(dev)->state)); | ||
| 410 | } | ||
| 411 | static DEVICE_ATTR_RO(state); | ||
| 412 | |||
| 405 | static struct attribute *xenbus_dev_attrs[] = { | 413 | static struct attribute *xenbus_dev_attrs[] = { |
| 406 | &dev_attr_nodename.attr, | 414 | &dev_attr_nodename.attr, |
| 407 | &dev_attr_devtype.attr, | 415 | &dev_attr_devtype.attr, |
| 408 | &dev_attr_modalias.attr, | 416 | &dev_attr_modalias.attr, |
| 417 | &dev_attr_state.attr, | ||
| 409 | NULL, | 418 | NULL, |
| 410 | }; | 419 | }; |
| 411 | 420 | ||
