Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Sep 2011 07:38:02 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r225759 - stable/8/lib/libusb
Message-ID:  <201109260738.p8Q7c2Qx061589@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Mon Sep 26 07:38:01 2011
New Revision: 225759
URL: http://svn.freebsd.org/changeset/base/225759

Log:
  MFC r225659:
  Implement missing USB debug information functions.

Modified:
  stable/8/lib/libusb/Makefile
  stable/8/lib/libusb/libusb.3
  stable/8/lib/libusb/libusb.h
  stable/8/lib/libusb/libusb10.c
  stable/8/lib/libusb/libusb20.3
  stable/8/lib/libusb/libusb20.c
  stable/8/lib/libusb/libusb20.h
Directory Properties:
  stable/8/lib/libusb/   (props changed)
  stable/8/lib/libusb/usb.h   (props changed)

Modified: stable/8/lib/libusb/Makefile
==============================================================================
--- stable/8/lib/libusb/Makefile	Mon Sep 26 07:05:40 2011	(r225758)
+++ stable/8/lib/libusb/Makefile	Mon Sep 26 07:38:01 2011	(r225759)
@@ -38,6 +38,7 @@ CFLAGS+=	-DCOMPAT_32BIT
 MLINKS += libusb.3 libusb_init.3
 MLINKS += libusb.3 libusb_exit.3
 MLINKS += libusb.3 libusb_strerror.3
+MLINKS += libusb.3 libusb_error_name.3
 MLINKS += libusb.3 libusb_set_debug.3
 MLINKS += libusb.3 libusb_get_device_list.3
 MLINKS += libusb.3 libusb_free_device_list.3
@@ -208,3 +209,5 @@ MLINKS += libusb20.3 libusb20_me_get_2.3
 MLINKS += libusb20.3 libusb20_me_encode.3
 MLINKS += libusb20.3 libusb20_me_decode.3
 MLINKS += libusb20.3 libusb20_desc_foreach.3
+MLINKS += libusb20.3 libusb20_strerror.3
+MLINKS += libusb20.3 libusb20_error_name.3

Modified: stable/8/lib/libusb/libusb.3
==============================================================================
--- stable/8/lib/libusb/libusb.3	Mon Sep 26 07:05:40 2011	(r225758)
+++ stable/8/lib/libusb/libusb.3	Mon Sep 26 07:38:01 2011	(r225759)
@@ -63,6 +63,14 @@ Other libusb routines may not be called 
 Get the ASCII representation of the error given by the
 .Fa code
 argument.
+This function does not return NULL.
+.Pp
+.Ft const char *
+.Fn libusb_error_name "int code"
+Get the ASCII representation of the error enum given by the
+.Fa code
+argument.
+This function does not return NULL.
 .Pp
 .Ft void
 .Fn libusb_set_debug "libusb_context *ctx" "int level"
@@ -502,7 +510,8 @@ The library is also compliant with LibUS
 .Sh SEE ALSO
 .Xr libusb20 3 ,
 .Xr usb 4 ,
-.Xr usbconfig 8
+.Xr usbconfig 8 ,
+.Xr usbdump 8
 .Pp
 .Pa http://libusb.sourceforge.net/
 .Sh HISTORY

Modified: stable/8/lib/libusb/libusb.h
==============================================================================
--- stable/8/lib/libusb/libusb.h	Mon Sep 26 07:05:40 2011	(r225758)
+++ stable/8/lib/libusb/libusb.h	Mon Sep 26 07:38:01 2011	(r225759)
@@ -303,6 +303,7 @@ typedef struct libusb_transfer {
 
 void	libusb_set_debug(libusb_context * ctx, int level);
 const char *libusb_strerror(int code);
+const char *libusb_error_name(int code);
 int	libusb_init(libusb_context ** context);
 void	libusb_exit(struct libusb_context *ctx);
 

Modified: stable/8/lib/libusb/libusb10.c
==============================================================================
--- stable/8/lib/libusb/libusb10.c	Mon Sep 26 07:05:40 2011	(r225758)
+++ stable/8/lib/libusb/libusb10.c	Mon Sep 26 07:38:01 2011	(r225759)
@@ -1449,6 +1449,73 @@ libusb_le16_to_cpu(uint16_t x)
 const char *
 libusb_strerror(int code)
 {
-	/* TODO */
-	return ("Unknown error");
+	switch (code) {
+	case LIBUSB_SUCCESS:
+		return ("Success");
+	case LIBUSB_ERROR_IO:
+		return ("I/O error");
+	case LIBUSB_ERROR_INVALID_PARAM:
+		return ("Invalid parameter");
+	case LIBUSB_ERROR_ACCESS:
+		return ("Permissions error");
+	case LIBUSB_ERROR_NO_DEVICE:
+		return ("No device");
+	case LIBUSB_ERROR_NOT_FOUND:
+		return ("Not found");
+	case LIBUSB_ERROR_BUSY:
+		return ("Device busy");
+	case LIBUSB_ERROR_TIMEOUT:
+		return ("Timeout");
+	case LIBUSB_ERROR_OVERFLOW:
+		return ("Overflow");
+	case LIBUSB_ERROR_PIPE:
+		return ("Pipe error");
+	case LIBUSB_ERROR_INTERRUPTED:
+		return ("Interrupted");
+	case LIBUSB_ERROR_NO_MEM:
+		return ("Out of memory");
+	case LIBUSB_ERROR_NOT_SUPPORTED:
+		return ("Not supported");
+	case LIBUSB_ERROR_OTHER:
+		return ("Other error");
+	default:
+		return ("Unknown error");
+	}
+}
+
+const char *
+libusb_error_name(int code)
+{
+	switch (code) {
+	case LIBUSB_SUCCESS:
+		return ("LIBUSB_SUCCESS");
+	case LIBUSB_ERROR_IO:
+		return ("LIBUSB_ERROR_IO");
+	case LIBUSB_ERROR_INVALID_PARAM:
+		return ("LIBUSB_ERROR_INVALID_PARAM");
+	case LIBUSB_ERROR_ACCESS:
+		return ("LIBUSB_ERROR_ACCESS");
+	case LIBUSB_ERROR_NO_DEVICE:
+		return ("LIBUSB_ERROR_NO_DEVICE");
+	case LIBUSB_ERROR_NOT_FOUND:
+		return ("LIBUSB_ERROR_NOT_FOUND");
+	case LIBUSB_ERROR_BUSY:
+		return ("LIBUSB_ERROR_BUSY");
+	case LIBUSB_ERROR_TIMEOUT:
+		return ("LIBUSB_ERROR_TIMEOUT");
+	case LIBUSB_ERROR_OVERFLOW:
+		return ("LIBUSB_ERROR_OVERFLOW");
+	case LIBUSB_ERROR_PIPE:
+		return ("LIBUSB_ERROR_PIPE");
+	case LIBUSB_ERROR_INTERRUPTED:
+		return ("LIBUSB_ERROR_INTERRUPTED");
+	case LIBUSB_ERROR_NO_MEM:
+		return ("LIBUSB_ERROR_NO_MEM");
+	case LIBUSB_ERROR_NOT_SUPPORTED:
+		return ("LIBUSB_ERROR_NOT_SUPPORTED");
+	case LIBUSB_ERROR_OTHER:
+		return ("LIBUSB_ERROR_OTHER");
+	default:
+		return ("LIBUSB_ERROR_UNKNOWN");
+	}
 }

Modified: stable/8/lib/libusb/libusb20.3
==============================================================================
--- stable/8/lib/libusb/libusb20.3	Mon Sep 26 07:05:40 2011	(r225758)
+++ stable/8/lib/libusb/libusb20.3	Mon Sep 26 07:38:01 2011	(r225759)
@@ -212,6 +212,10 @@ USB access library (libusb -lusb)
 .Fn libusb20_me_decode "const void *pdata" "uint16_t len" "void *pdecoded"
 .Ft "const uint8_t *"
 .Fn libusb20_desc_foreach "const struct libusb20_me_struct *me" "const uint8_t *pdesc"
+.Ft "const char *"
+.Fn libusb20_strerror "int code"
+.Ft "const char *"
+.Fn libusb20_error_name "int code"
 .
 .
 .Sh DESCRIPTION
@@ -996,6 +1000,22 @@ The total decoded length is returned.
 The buffer pointer cannot be NULL.
 .
 .
+.Sh USB DEBUGGING
+.Pp
+.Ft const char *
+.Fn libusb20_strerror "int code"
+Get the ASCII representation of the error given by the
+.Fa code
+argument.
+This function does not return NULL.
+.Pp
+.Ft const char *
+.Fn libusb20_error_name "int code"
+Get the ASCII representation of the error enum given by the
+.Fa code
+argument.
+This function does not return NULL.
+.
 .Sh FILES
 .
 .
@@ -1003,7 +1023,8 @@ The buffer pointer cannot be NULL.
 .Sh SEE ALSO
 .Xr usb 4 ,
 .Xr libusb 3 ,
-.Xr usbconfig 8
+.Xr usbconfig 8 ,
+.Xr usbdump 8
 .
 .
 .Sh HISTORY

Modified: stable/8/lib/libusb/libusb20.c
==============================================================================
--- stable/8/lib/libusb/libusb20.c	Mon Sep 26 07:05:40 2011	(r225758)
+++ stable/8/lib/libusb/libusb20.c	Mon Sep 26 07:38:01 2011	(r225759)
@@ -1244,3 +1244,77 @@ libusb20_be_dequeue_device(struct libusb
 {
 	TAILQ_REMOVE(&(pbe->usb_devs), pdev, dev_entry);
 }
+
+const char *
+libusb20_strerror(int code)
+{
+	switch (code) {
+	case LIBUSB20_SUCCESS:
+		return ("Success");
+	case LIBUSB20_ERROR_IO:
+		return ("I/O error");
+	case LIBUSB20_ERROR_INVALID_PARAM:
+		return ("Invalid parameter");
+	case LIBUSB20_ERROR_ACCESS:
+		return ("Permissions error");
+	case LIBUSB20_ERROR_NO_DEVICE:
+		return ("No device");
+	case LIBUSB20_ERROR_NOT_FOUND:
+		return ("Not found");
+	case LIBUSB20_ERROR_BUSY:
+		return ("Device busy");
+	case LIBUSB20_ERROR_TIMEOUT:
+		return ("Timeout");
+	case LIBUSB20_ERROR_OVERFLOW:
+		return ("Overflow");
+	case LIBUSB20_ERROR_PIPE:
+		return ("Pipe error");
+	case LIBUSB20_ERROR_INTERRUPTED:
+		return ("Interrupted");
+	case LIBUSB20_ERROR_NO_MEM:
+		return ("Out of memory");
+	case LIBUSB20_ERROR_NOT_SUPPORTED:
+		return ("Not supported");
+	case LIBUSB20_ERROR_OTHER:
+		return ("Other error");
+	default:
+		return ("Unknown error");
+	}
+}
+
+const char *
+libusb20_error_name(int code)
+{
+	switch (code) {
+	case LIBUSB20_SUCCESS:
+		return ("LIBUSB20_SUCCESS");
+	case LIBUSB20_ERROR_IO:
+		return ("LIBUSB20_ERROR_IO");
+	case LIBUSB20_ERROR_INVALID_PARAM:
+		return ("LIBUSB20_ERROR_INVALID_PARAM");
+	case LIBUSB20_ERROR_ACCESS:
+		return ("LIBUSB20_ERROR_ACCESS");
+	case LIBUSB20_ERROR_NO_DEVICE:
+		return ("LIBUSB20_ERROR_NO_DEVICE");
+	case LIBUSB20_ERROR_NOT_FOUND:
+		return ("LIBUSB20_ERROR_NOT_FOUND");
+	case LIBUSB20_ERROR_BUSY:
+		return ("LIBUSB20_ERROR_BUSY");
+	case LIBUSB20_ERROR_TIMEOUT:
+		return ("LIBUSB20_ERROR_TIMEOUT");
+	case LIBUSB20_ERROR_OVERFLOW:
+		return ("LIBUSB20_ERROR_OVERFLOW");
+	case LIBUSB20_ERROR_PIPE:
+		return ("LIBUSB20_ERROR_PIPE");
+	case LIBUSB20_ERROR_INTERRUPTED:
+		return ("LIBUSB20_ERROR_INTERRUPTED");
+	case LIBUSB20_ERROR_NO_MEM:
+		return ("LIBUSB20_ERROR_NO_MEM");
+	case LIBUSB20_ERROR_NOT_SUPPORTED:
+		return ("LIBUSB20_ERROR_NOT_SUPPORTED");
+	case LIBUSB20_ERROR_OTHER:
+		return ("LIBUSB20_ERROR_OTHER");
+	default:
+		return ("LIBUSB20_ERROR_UNKNOWN");
+	}
+}

Modified: stable/8/lib/libusb/libusb20.h
==============================================================================
--- stable/8/lib/libusb/libusb20.h	Mon Sep 26 07:05:40 2011	(r225758)
+++ stable/8/lib/libusb/libusb20.h	Mon Sep 26 07:38:01 2011	(r225759)
@@ -293,6 +293,11 @@ void	libusb20_be_dequeue_device(struct l
 void	libusb20_be_enqueue_device(struct libusb20_backend *pbe, struct libusb20_device *pdev);
 void	libusb20_be_free(struct libusb20_backend *pbe);
 
+/* USB debugging */
+
+const char *libusb20_strerror(int);
+const char *libusb20_error_name(int);
+
 #if 0
 {					/* style */
 #endif



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201109260738.p8Q7c2Qx061589>