Skip to contentSkip to conversation

add xenbus_strstate()

PATCH In review Gerd Hoffmann 2 participants 2 messages Aug 31, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 add xenbus_strstate()

Hi,

This patch adds xenbus_strstate() helper function for more readable debug output.

please apply,

Gerd

Signature · 2 lines
Gerd Hoffmann <[email protected]>
http://www.suse.de/~kraxel/julika-dora.jpeg

Add xenbus_strstate() helper function for more readable debug output.

---
 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c |   15 +++++++++++++++
 linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c  |    4 ++--
 linux-2.6-xen-sparse/include/xen/xenbus.h               |    2 ++
 3 files changed, 19 insertions(+), 2 deletions(-)
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c +15 -0
Index: build-32-unstable-11286/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_client.c
===================================================================
@@ -41,6 +41,21 @@ extern char *kasprintf(const char *fmt, 
 #define DPRINTK(fmt, args...) \
     pr_debug("xenbus_client (%s:%d) " fmt ".\n", __FUNCTION__, __LINE__, ##args)
 
+char *xenbus_strstate(enum xenbus_state state)
+{
+	static char *name[] = {
+		[ XenbusStateUnknown      ] = "Unknown",
+		[ XenbusStateInitialising ] = "Initialising",
+		[ XenbusStateInitWait     ] = "InitWait",
+		[ XenbusStateInitialised  ] = "Initialised",
+		[ XenbusStateConnected    ] = "Connected",
+		[ XenbusStateClosing      ] = "Closing",
+		[ XenbusStateClosed	  ] = "Closed",
+	};
+	return state < sizeof(name)/sizeof(name[0])
+		? name[state] : "INVALID";
+}
+
 int xenbus_watch_path(struct xenbus_device *dev, const char *path,
 		      struct xenbus_watch *watch,
 		      void (*callback)(struct xenbus_watch *,
linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c +2 -2
Index: build-32-unstable-11286/linux-2.6-xen-sparse/drivers/xen/xenbus/xenbus_probe.c
===================================================================
@@ -316,8 +316,8 @@ static void otherend_changed(struct xenb
 
 	state = xenbus_read_driver_state(dev->otherend);
 
-	DPRINTK("state is %d, %s, %s",
-		state, dev->otherend_watch.node, vec[XS_WATCH_PATH]);
+	DPRINTK("state is %s, %s, %s", xenbus_strstate(state),
+		dev->otherend_watch.node, vec[XS_WATCH_PATH]);
 	if (drv->otherend_changed)
 		drv->otherend_changed(dev, state);
 }
linux-2.6-xen-sparse/include/xen/xenbus.h +2 -0
Index: build-32-unstable-11286/linux-2.6-xen-sparse/include/xen/xenbus.h
===================================================================
@@ -297,4 +297,6 @@ void xenbus_dev_fatal(struct xenbus_devi
 
 int __init xenbus_dev_init(void);
 
+char *xenbus_strstate(enum xenbus_state state);
+
 #endif /* _XEN_XENBUS_H */

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw
Quoted 2 lines · * Gerd Hoffmann ([email protected]) wrote:

This patch adds xenbus_strstate() helper function for more readable debug output.

Hey, I like that ;-) I just did smth similar for debugging yesterday.

thanks,
-chris