Skip to contentSkip to conversation

xen: export device state to sysfs

PATCH Superseded Joe Jin 2 participants 3 messages Aug 27, 2018 – Aug 28, 2018 Xen hypervisor interface

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Joe Jin

author
#0 lore raw

PATCH 1/1 xen: export device state to sysfs

Export device state to sysfs to allow for easier get device state.

Boris Ostrovsky <[email protected]>
Juergen Gross <[email protected]>

---
 drivers/xen/xenbus/xenbus_probe.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/xen/xenbus/xenbus_probe.c +9 -0
index 74888cacd0b0..52f99b80a1c0 100644
@@ -402,10 +402,19 @@ static ssize_t modalias_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(modalias);
 
+static ssize_t state_show(struct device *dev,
+			    struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%s\n",
+			xenbus_strstate(to_xenbus_device(dev)->state));
+}
+static DEVICE_ATTR_RO(state);
+
 static struct attribute *xenbus_dev_attrs[] = {
 	&dev_attr_nodename.attr,
 	&dev_attr_devtype.attr,
 	&dev_attr_modalias.attr,
+	&dev_attr_state.attr,
 	NULL,
 };
 
Signature · 1 line
2.15.2 (Apple Git-101.1)
maintainer
#1 lore raw
Quoted 5 lines · Joe Jin

Export device state to sysfs to allow for easier get device state.

Boris Ostrovsky <[email protected]>
Juergen Gross <[email protected]>

Please add the related documentation to

Documentation/ABI/stable/sysfs-bus-xen-backend

Juergen

Quoted 19 lines
---
 drivers/xen/xenbus/xenbus_probe.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/xen/xenbus/xenbus_probe.c +6 -0
index 74888cacd0b0..52f99b80a1c0 100644
@@ -402,10 +402,19 @@ static ssize_t modalias_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(modalias);
 
+static ssize_t state_show(struct device *dev,
+			    struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%s\n",
+			xenbus_strstate(to_xenbus_device(dev)->state));
+}

drivers/xen/xenbus/xenbus_probe.c static ssize_t modalias_show(struct device *dev, · line 420

Quoted 10 lines
drivers/xen/xenbus/xenbus_probe.c +3 -0
+static DEVICE_ATTR_RO(state);
+
 static struct attribute *xenbus_dev_attrs[] = {
 	&dev_attr_nodename.attr,
 	&dev_attr_devtype.attr,
 	&dev_attr_modalias.attr,
+	&dev_attr_state.attr,
 	NULL,
 };
 

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

maintainer
#2 lore raw
In reply to Joe Jin
Quoted 5 lines · Joe Jin

Export device state to sysfs to allow for easier get device state.

Boris Ostrovsky <[email protected]>
Juergen Gross <[email protected]>

Please add the related documentation to

Documentation/ABI/stable/sysfs-bus-xen-backend

Juergen

Quoted 29 lines
---
 drivers/xen/xenbus/xenbus_probe.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/xen/xenbus/xenbus_probe.c +9 -0
index 74888cacd0b0..52f99b80a1c0 100644
@@ -402,10 +402,19 @@ static ssize_t modalias_show(struct device *dev,
 }
 static DEVICE_ATTR_RO(modalias);
 
+static ssize_t state_show(struct device *dev,
+			    struct device_attribute *attr, char *buf)
+{
+	return sprintf(buf, "%s\n",
+			xenbus_strstate(to_xenbus_device(dev)->state));
+}
+static DEVICE_ATTR_RO(state);
+
 static struct attribute *xenbus_dev_attrs[] = {
 	&dev_attr_nodename.attr,
 	&dev_attr_devtype.attr,
 	&dev_attr_modalias.attr,
+	&dev_attr_state.attr,
 	NULL,
 };