Date: Sat, 25 Apr 2009 21:25:52 +0000 (UTC) From: Andrew Thompson <thompsa@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r191498 - head/sys/dev/usb Message-ID: <200904252125.n3PLPqvZ063558@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: thompsa Date: Sat Apr 25 21:25:52 2009 New Revision: 191498 URL: http://svn.freebsd.org/changeset/base/191498 Log: Make the state string descriptions public. Modified: head/sys/dev/usb/usb_core.h head/sys/dev/usb/usb_device.c Modified: head/sys/dev/usb/usb_core.h ============================================================================== --- head/sys/dev/usb/usb_core.h Sat Apr 25 21:16:06 2009 (r191497) +++ head/sys/dev/usb/usb_core.h Sat Apr 25 21:25:52 2009 (r191498) @@ -515,6 +515,7 @@ typedef struct malloc_type *usb2_malloc_ /* prototypes */ const char *usb2_errstr(usb2_error_t error); +const char *usb2_statestr(enum usb_dev_state state); struct usb2_config_descriptor *usb2_get_config_descriptor( struct usb2_device *udev); struct usb2_device_descriptor *usb2_get_device_descriptor( Modified: head/sys/dev/usb/usb_device.c ============================================================================== --- head/sys/dev/usb/usb_device.c Sat Apr 25 21:16:06 2009 (r191497) +++ head/sys/dev/usb/usb_device.c Sat Apr 25 21:25:52 2009 (r191498) @@ -90,6 +90,22 @@ int usb2_template = 0; SYSCTL_INT(_hw_usb2, OID_AUTO, template, CTLFLAG_RW, &usb2_template, 0, "Selected USB device side template"); +static const char* statestr[USB_STATE_MAX] = { + [USB_STATE_DETACHED] = "DETACHED", + [USB_STATE_ATTACHED] = "ATTACHED", + [USB_STATE_POWERED] = "POWERED", + [USB_STATE_ADDRESSED] = "ADDRESSED", + [USB_STATE_CONFIGURED] = "CONFIGURED", + [USB_STATE_SUSPENDED] = "SUSPENDED" +}; + +const char * +usb2_statestr(enum usb_dev_state state) +{ + KASSERT(state < USB_STATE_MAX, ("invalid udev state")); + + return (statestr[state]); +} /*------------------------------------------------------------------------* * usb2_get_pipe_by_addr @@ -2448,19 +2464,11 @@ usb2_peer_can_wakeup(struct usb2_device void usb2_set_device_state(struct usb2_device *udev, enum usb_dev_state state) { - static const char* statestr[USB_STATE_MAX] = { - [USB_STATE_DETACHED] = "DETACHED", - [USB_STATE_ATTACHED] = "ATTACHED", - [USB_STATE_POWERED] = "POWERED", - [USB_STATE_ADDRESSED] = "ADDRESSED", - [USB_STATE_CONFIGURED] = "CONFIGURED", - [USB_STATE_SUSPENDED] = "SUSPENDED" - }; KASSERT(state < USB_STATE_MAX, ("invalid udev state")); DPRINTF("udev %p state %s -> %s\n", udev, - statestr[udev->state], statestr[state]); + usb2_statestr(udev->state), usb2_statestr(state)); udev->state = state; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904252125.n3PLPqvZ063558>