[PATCH 127/961] staging/easycap: implement strerror function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tomas Winkler <tomas.winkler@xxxxxxxxx>

Replace long switch statements that just print out errno
with strerror function. It reduces around 700 lines from the code.

The function should be probably dropped at all but leave for now
to not break currently expected debug output.

Signed-off-by: Tomas Winkler <tomas.winkler@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>
---
 drivers/staging/easycap/easycap.h       |    2 +
 drivers/staging/easycap/easycap_main.c  |  323 ++++---------------
 drivers/staging/easycap/easycap_sound.c |  555 ++-----------------------------
 3 files changed, 87 insertions(+), 793 deletions(-)

diff --git a/drivers/staging/easycap/easycap.h b/drivers/staging/easycap/easycap.h
index 21355cc..d751e75 100644
--- a/drivers/staging/easycap/easycap.h
+++ b/drivers/staging/easycap/easycap.h
@@ -644,6 +644,8 @@ struct signed_div_result {
  *  IMMEDIATELY OBVIOUS FROM A CASUAL READING OF THE SOURCE CODE.  BEWARE.
 */
 /*---------------------------------------------------------------------------*/
+const char *strerror(int err);
+
 #define SAY(format, args...) do { \
 	printk(KERN_DEBUG "easycap:: %s: " \
 			format, __func__, ##args); \
diff --git a/drivers/staging/easycap/easycap_main.c b/drivers/staging/easycap/easycap_main.c
index 85a26e3..cc1460b 100644
--- a/drivers/staging/easycap/easycap_main.c
+++ b/drivers/staging/easycap/easycap_main.c
@@ -58,6 +58,48 @@ static struct mutex mutex_dongle;
 static void easycap_complete(struct urb *purb);
 static int reset(struct easycap *peasycap);
 
+const char *strerror(int err)
+{
+#define ERRNOSTR(_e) case _e: return # _e
+	switch (err) {
+	case 0: return "OK";
+	ERRNOSTR(ENOMEM);
+	ERRNOSTR(ENODEV);
+	ERRNOSTR(ENXIO);
+	ERRNOSTR(EINVAL);
+	ERRNOSTR(EAGAIN);
+	ERRNOSTR(EFBIG);
+	ERRNOSTR(EPIPE);
+	ERRNOSTR(EMSGSIZE);
+	ERRNOSTR(ENOSPC);
+	ERRNOSTR(EINPROGRESS);
+	ERRNOSTR(ENOSR);
+	ERRNOSTR(EOVERFLOW);
+	ERRNOSTR(EPROTO);
+	ERRNOSTR(EILSEQ);
+	ERRNOSTR(ETIMEDOUT);
+	ERRNOSTR(EOPNOTSUPP);
+	ERRNOSTR(EPFNOSUPPORT);
+	ERRNOSTR(EAFNOSUPPORT);
+	ERRNOSTR(EADDRINUSE);
+	ERRNOSTR(EADDRNOTAVAIL);
+	ERRNOSTR(ENOBUFS);
+	ERRNOSTR(EISCONN);
+	ERRNOSTR(ENOTCONN);
+	ERRNOSTR(ESHUTDOWN);
+	ERRNOSTR(ENOENT);
+	ERRNOSTR(ECONNRESET);
+	ERRNOSTR(ETIME);
+	ERRNOSTR(ECOMM);
+	ERRNOSTR(EREMOTEIO);
+	ERRNOSTR(EXDEV);
+	ERRNOSTR(EPERM);
+	default: return "unknown";
+	}
+
+#undef ERRNOSTR
+}
+
 /*---------------------------------------------------------------------------*/
 /*
  *  PARAMETERS USED WHEN REGISTERING THE VIDEO INTERFACE
@@ -599,72 +641,23 @@ if (!peasycap->video_isoc_streaming) {
 					}
 
 				rc = usb_submit_urb(purb, GFP_KERNEL);
-				if (0 != rc) {
+				if (rc) {
 					isbad++;
 					SAM("ERROR: usb_submit_urb() failed "
-							"for urb with rc:\n");
-					switch (rc) {
-					case -ENOMEM: {
-						SAM("ERROR: -ENOMEM="
-							"usb_submit_urb()\n");
-						break;
-					}
-					case -ENODEV: {
-						SAM("ERROR: -ENODEV="
-							"usb_submit_urb()\n");
-						break;
-					}
-					case -ENXIO: {
-						SAM("ERROR: -ENXIO="
-							"usb_submit_urb()\n");
-						break;
-					}
-					case -EINVAL: {
-						SAM("ERROR: -EINVAL="
-							"usb_submit_urb()\n");
-						break;
-					}
-					case -EAGAIN: {
-						SAM("ERROR: -EAGAIN="
-							"usb_submit_urb()\n");
-						break;
-					}
-					case -EFBIG: {
-						SAM("ERROR: -EFBIG="
-							"usb_submit_urb()\n");
-						break;
-					}
-					case -EPIPE: {
-						SAM("ERROR: -EPIPE="
-							"usb_submit_urb()\n");
-						break;
-					}
-					case -EMSGSIZE: {
-						SAM("ERROR: -EMSGSIZE="
-							"usb_submit_urb()\n");
-						break;
-					}
-					case -ENOSPC: {
+							"for urb with rc:-%s\n",
+							strerror(rc));
+					if (rc == -ENOSPC)
 						nospc++;
-						break;
-					}
-					default: {
-						SAM("ERROR: %i="
-							"usb_submit_urb()\n",
-							rc);
-						break;
-					}
-					}
 				} else {
 					m++;
 				}
-				} else {
-					 isbad++;
-				}
 			} else {
-				 isbad++;
+				isbad++;
 			}
+		} else {
+			 isbad++;
 		}
+	}
 	if (nospc) {
 		SAM("-ENOSPC=usb_submit_urb() for %i urbs\n", nospc);
 		SAM(".....  possibly inadequate USB bandwidth\n");
@@ -2801,49 +2794,8 @@ if (peasycap->video_idle) {
 			peasycap->video_idle, peasycap->video_isoc_streaming);
 	if (peasycap->video_isoc_streaming) {
 		rc = usb_submit_urb(purb, GFP_ATOMIC);
-		if (0 != rc) {
-			switch (rc) {
-			case -ENOMEM: {
-				SAM("ENOMEM\n");
-				break;
-			}
-			case -ENODEV: {
-				SAM("ENODEV\n");
-				break;
-			}
-			case -ENXIO: {
-				SAM("ENXIO\n");
-				break;
-			}
-			case -EINVAL: {
-				SAM("EINVAL\n");
-				break;
-			}
-			case -EAGAIN: {
-				SAM("EAGAIN\n");
-				break;
-			}
-			case -EFBIG: {
-				SAM("EFBIG\n");
-				break;
-			}
-			case -EPIPE: {
-				SAM("EPIPE\n");
-				break;
-			}
-			case -EMSGSIZE: {
-				SAM("EMSGSIZE\n");
-				break;
-			}
-			case -ENOSPC: {
-				SAM("ENOSPC\n");
-				break;
-			}
-			default: {
-				SAM("0x%08X\n", rc);
-				break;
-			}
-			}
+		if (rc) {
+			SAM("%s:%d ENOMEM\n", strerror(rc), rc);
 			if (-ENODEV != rc)
 				SAM("ERROR: while %i=video_idle, "
 							"usb_submit_urb() "
@@ -2866,137 +2818,17 @@ if (purb->status) {
 	}
 
 	(peasycap->field_buffer[peasycap->field_fill][0].kount) |= 0x8000 ;
-	SAM("ERROR: bad urb status:\n");
-	switch (purb->status) {
-	case -EINPROGRESS: {
-		SAM("-EINPROGRESS\n"); break;
-	}
-	case -ENOSR: {
-		SAM("-ENOSR\n"); break;
-	}
-	case -EPIPE: {
-		SAM("-EPIPE\n"); break;
-	}
-	case -EOVERFLOW: {
-		SAM("-EOVERFLOW\n"); break;
-	}
-	case -EPROTO: {
-		SAM("-EPROTO\n"); break;
-	}
-	case -EILSEQ: {
-		SAM("-EILSEQ\n"); break;
-	}
-	case -ETIMEDOUT: {
-		SAM("-ETIMEDOUT\n"); break;
-	}
-	case -EMSGSIZE: {
-		SAM("-EMSGSIZE\n"); break;
-	}
-	case -EOPNOTSUPP: {
-		SAM("-EOPNOTSUPP\n"); break;
-	}
-	case -EPFNOSUPPORT: {
-		SAM("-EPFNOSUPPORT\n"); break;
-	}
-	case -EAFNOSUPPORT: {
-		SAM("-EAFNOSUPPORT\n"); break;
-	}
-	case -EADDRINUSE: {
-		SAM("-EADDRINUSE\n"); break;
-	}
-	case -EADDRNOTAVAIL: {
-		SAM("-EADDRNOTAVAIL\n"); break;
-	}
-	case -ENOBUFS: {
-		SAM("-ENOBUFS\n"); break;
-	}
-	case -EISCONN: {
-		SAM("-EISCONN\n"); break;
-	}
-	case -ENOTCONN: {
-		SAM("-ENOTCONN\n"); break;
-	}
-	case -ESHUTDOWN: {
-		SAM("-ESHUTDOWN\n"); break;
-	}
-	case -ENOENT: {
-		SAM("-ENOENT\n"); break;
-	}
-	case -ECONNRESET: {
-		SAM("-ECONNRESET\n"); break;
-	}
-	case -ENOSPC: {
-		SAM("ENOSPC\n"); break;
-	}
-	default: {
-		SAM("unknown error code 0x%08X\n", purb->status); break;
-	}
-	}
+	SAM("ERROR: bad urb status -%s: %d\n",
+			strerror(purb->status), purb->status);
 /*---------------------------------------------------------------------------*/
 } else {
 	for (i = 0;  i < purb->number_of_packets; i++) {
 		if (0 != purb->iso_frame_desc[i].status) {
 			(peasycap->field_buffer
 				[peasycap->field_fill][0].kount) |= 0x8000 ;
-			switch (purb->iso_frame_desc[i].status) {
-			case  0: {
-				strcpy(&errbuf[0], "OK"); break;
-			}
-			case -ENOENT: {
-				strcpy(&errbuf[0], "-ENOENT"); break;
-			}
-			case -EINPROGRESS: {
-				strcpy(&errbuf[0], "-EINPROGRESS"); break;
-			}
-			case -EPROTO: {
-				strcpy(&errbuf[0], "-EPROTO"); break;
-			}
-			case -EILSEQ: {
-				strcpy(&errbuf[0], "-EILSEQ"); break;
-			}
-			case -ETIME: {
-				strcpy(&errbuf[0], "-ETIME"); break;
-			}
-			case -ETIMEDOUT: {
-				strcpy(&errbuf[0], "-ETIMEDOUT"); break;
-			}
-			case -EPIPE: {
-				strcpy(&errbuf[0], "-EPIPE"); break;
-			}
-			case -ECOMM: {
-				strcpy(&errbuf[0], "-ECOMM"); break;
-			}
-			case -ENOSR: {
-				strcpy(&errbuf[0], "-ENOSR"); break;
-			}
-			case -EOVERFLOW: {
-				strcpy(&errbuf[0], "-EOVERFLOW"); break;
-			}
-			case -EREMOTEIO: {
-				strcpy(&errbuf[0], "-EREMOTEIO"); break;
-			}
-			case -ENODEV: {
-				strcpy(&errbuf[0], "-ENODEV"); break;
-			}
-			case -EXDEV: {
-				strcpy(&errbuf[0], "-EXDEV"); break;
-			}
-			case -EINVAL: {
-				strcpy(&errbuf[0], "-EINVAL"); break;
-			}
-			case -ECONNRESET: {
-				strcpy(&errbuf[0], "-ECONNRESET"); break;
-			}
-			case -ENOSPC: {
-				SAM("ENOSPC\n"); break;
-			}
-			case -ESHUTDOWN: {
-				strcpy(&errbuf[0], "-ESHUTDOWN"); break;
-			}
-			default: {
-				strcpy(&errbuf[0], "unknown error"); break;
-			}
-			}
+			/* FIXME: 1. missing '-' check boundaries */
+			strcpy(&errbuf[0],
+				strerror(purb->iso_frame_desc[i].status));
 		}
 		framestatus = purb->iso_frame_desc[i].status;
 		framelength = purb->iso_frame_desc[i].length;
@@ -3270,44 +3102,13 @@ if (VIDEO_ISOC_BUFFER_MANY <= peasycap->video_junk) {
 }
 if (peasycap->video_isoc_streaming) {
 	rc = usb_submit_urb(purb, GFP_ATOMIC);
-	if (0 != rc) {
-		switch (rc) {
-		case -ENOMEM: {
-			SAM("ENOMEM\n"); break;
-		}
-		case -ENODEV: {
-			SAM("ENODEV\n"); break;
-		}
-		case -ENXIO: {
-			SAM("ENXIO\n"); break;
-		}
-		case -EINVAL: {
-			SAM("EINVAL\n"); break;
-		}
-		case -EAGAIN: {
-			SAM("EAGAIN\n"); break;
-		}
-		case -EFBIG: {
-			SAM("EFBIG\n"); break;
-		}
-		case -EPIPE: {
-			SAM("EPIPE\n"); break;
-		}
-		case -EMSGSIZE: {
-			SAM("EMSGSIZE\n");  break;
-		}
-		case -ENOSPC: {
-			SAM("ENOSPC\n"); break;
-		}
-		default: {
-			SAM("0x%08X\n", rc); break;
-		}
-		}
+	if (rc) {
+		SAM("%s: %d\n", strerror(rc), rc);
 		if (-ENODEV != rc)
 			SAM("ERROR: while %i=video_idle, "
-						"usb_submit_urb() "
-						"failed with rc:\n",
-						peasycap->video_idle);
+				"usb_submit_urb() "
+				"failed with rc:\n",
+				peasycap->video_idle);
 	}
 }
 return;
diff --git a/drivers/staging/easycap/easycap_sound.c b/drivers/staging/easycap/easycap_sound.c
index d539e28..05d9eed 100644
--- a/drivers/staging/easycap/easycap_sound.c
+++ b/drivers/staging/easycap/easycap_sound.c
@@ -213,93 +213,8 @@ if (purb->status) {
 		JOM(16, "urb status -ESHUTDOWN or -ENOENT\n");
 		return;
 	}
-	SAM("ERROR: non-zero urb status:\n");
-	switch (purb->status) {
-	case -EINPROGRESS: {
-		SAM("-EINPROGRESS\n");
-		break;
-	}
-	case -ENOSR: {
-		SAM("-ENOSR\n");
-		break;
-	}
-	case -EPIPE: {
-		SAM("-EPIPE\n");
-		break;
-	}
-	case -EOVERFLOW: {
-		SAM("-EOVERFLOW\n");
-		break;
-	}
-	case -EPROTO: {
-		SAM("-EPROTO\n");
-		break;
-	}
-	case -EILSEQ: {
-		SAM("-EILSEQ\n");
-		break;
-	}
-	case -ETIMEDOUT: {
-		SAM("-ETIMEDOUT\n");
-		break;
-	}
-	case -EMSGSIZE: {
-		SAM("-EMSGSIZE\n");
-		break;
-	}
-	case -EOPNOTSUPP: {
-		SAM("-EOPNOTSUPP\n");
-		break;
-	}
-	case -EPFNOSUPPORT: {
-		SAM("-EPFNOSUPPORT\n");
-		break;
-	}
-	case -EAFNOSUPPORT: {
-		SAM("-EAFNOSUPPORT\n");
-		break;
-	}
-	case -EADDRINUSE: {
-		SAM("-EADDRINUSE\n");
-		break;
-	}
-	case -EADDRNOTAVAIL: {
-		SAM("-EADDRNOTAVAIL\n");
-		break;
-	}
-	case -ENOBUFS: {
-		SAM("-ENOBUFS\n");
-		break;
-	}
-	case -EISCONN: {
-		SAM("-EISCONN\n");
-		break;
-	}
-	case -ENOTCONN: {
-		SAM("-ENOTCONN\n");
-		break;
-	}
-	case -ESHUTDOWN: {
-		SAM("-ESHUTDOWN\n");
-		break;
-	}
-	case -ENOENT: {
-		SAM("-ENOENT\n");
-		break;
-	}
-	case -ECONNRESET: {
-		SAM("-ECONNRESET\n");
-		break;
-	}
-	case -ENOSPC: {
-		SAM("ENOSPC\n");
-		break;
-	}
-	default: {
-		SAM("unknown error: %i\n", purb->status);
-		break;
-	}
-	}
+	SAM("ERROR: non-zero urb status: -%s: %d\n",
+		strerror(purb->status), purb->status);
 	goto resubmit;
 }
 /*---------------------------------------------------------------------------*/
@@ -313,86 +228,10 @@ oldaudio = peasycap->oldaudio;
 #endif /*UPSAMPLE*/
 
 for (i = 0;  i < purb->number_of_packets; i++) {
-	switch (purb->iso_frame_desc[i].status) {
-	case  0: {
-		break;
-	}
-	case -ENOENT: {
-		SAM("-ENOENT\n");
-		break;
-	}
-	case -EINPROGRESS: {
-		SAM("-EINPROGRESS\n");
-		break;
-	}
-	case -EPROTO: {
-		SAM("-EPROTO\n");
-		break;
-	}
-	case -EILSEQ: {
-		SAM("-EILSEQ\n");
-		break;
-	}
-	case -ETIME: {
-		SAM("-ETIME\n");
-		break;
-	}
-	case -ETIMEDOUT: {
-		SAM("-ETIMEDOUT\n");
-		break;
-	}
-	case -EPIPE: {
-		SAM("-EPIPE\n");
-		break;
-	}
-	case -ECOMM: {
-		SAM("-ECOMM\n");
-		break;
-	}
-	case -ENOSR: {
-		SAM("-ENOSR\n");
-		break;
-	}
-	case -EOVERFLOW: {
-		SAM("-EOVERFLOW\n");
-		break;
-	}
-	case -EREMOTEIO: {
-		SAM("-EREMOTEIO\n");
-		break;
-	}
-	case -ENODEV: {
-		SAM("-ENODEV\n");
-		break;
-	}
-	case -EXDEV: {
-		SAM("-EXDEV\n");
-		break;
-	}
-	case -EINVAL: {
-		SAM("-EINVAL\n");
-		break;
-	}
-	case -ECONNRESET: {
-		SAM("-ECONNRESET\n");
-		break;
-	}
-	case -ENOSPC: {
-		SAM("-ENOSPC\n");
-		break;
-	}
-	case -ESHUTDOWN: {
-		SAM("-ESHUTDOWN\n");
-		break;
-	}
-	case -EPERM: {
-		SAM("-EPERM\n");
-		break;
-	}
-	default: {
-		SAM("unknown error: %i\n", purb->iso_frame_desc[i].status);
-		break;
-	}
+	if (purb->iso_frame_desc[i].status < 0) {
+		SAM("-%s: %d\n",
+			strerror(purb->iso_frame_desc[i].status),
+			purb->iso_frame_desc[i].status);
 	}
 	if (!purb->iso_frame_desc[i].status) {
 		more = purb->iso_frame_desc[i].actual_length;
@@ -537,56 +376,12 @@ peasycap->oldaudio = oldaudio;
 resubmit:
 if (peasycap->audio_isoc_streaming) {
 	rc = usb_submit_urb(purb, GFP_ATOMIC);
-	if (0 != rc) {
+	if (rc) {
 		if ((-ENODEV != rc) && (-ENOENT != rc)) {
 			SAM("ERROR: while %i=audio_idle, "
 				"usb_submit_urb() failed "
-				"with rc:\n", peasycap->audio_idle);
-		}
-		switch (rc) {
-		case -ENODEV:
-		case -ENOENT:
-			break;
-		case -ENOMEM: {
-			SAM("-ENOMEM\n");
-			break;
-		}
-		case -ENXIO: {
-			SAM("-ENXIO\n");
-			break;
-		}
-		case -EINVAL: {
-			SAM("-EINVAL\n");
-			break;
-		}
-		case -EAGAIN: {
-			SAM("-EAGAIN\n");
-			break;
-		}
-		case -EFBIG: {
-			SAM("-EFBIG\n");
-			break;
-		}
-		case -EPIPE: {
-			SAM("-EPIPE\n");
-			break;
-		}
-		case -EMSGSIZE: {
-			SAM("-EMSGSIZE\n");
-			break;
-		}
-		case -ENOSPC: {
-			SAM("-ENOSPC\n");
-			break;
-		}
-		case -EPERM: {
-			SAM("-EPERM\n");
-			break;
-		}
-		default: {
-			SAM("unknown error: %i\n", rc);
-			break;
-		}
+				"with rc: -%s :%d\n", peasycap->audio_idle,
+				strerror(rc), rc);
 		}
 		if (0 < peasycap->audio_isoc_streaming)
 			(peasycap->audio_isoc_streaming)--;
@@ -945,56 +740,12 @@ if (peasycap->audio_idle) {
 			peasycap->audio_idle, peasycap->audio_isoc_streaming);
 	if (peasycap->audio_isoc_streaming) {
 		rc = usb_submit_urb(purb, GFP_ATOMIC);
-		if (0 != rc) {
+		if (rc) {
 			if (-ENODEV != rc && -ENOENT != rc) {
 				SAM("ERROR: while %i=audio_idle, "
-					"usb_submit_urb() failed with rc:\n",
-							peasycap->audio_idle);
-			}
-			switch (rc) {
-			case -ENODEV:
-			case -ENOENT:
-				break;
-			case -ENOMEM: {
-				SAM("-ENOMEM\n");
-				break;
-			}
-			case -ENXIO: {
-				SAM("-ENXIO\n");
-				break;
-			}
-			case -EINVAL: {
-				SAM("-EINVAL\n");
-				break;
-			}
-			case -EAGAIN: {
-				SAM("-EAGAIN\n");
-				break;
-			}
-			case -EFBIG: {
-				SAM("-EFBIG\n");
-				break;
-			}
-			case -EPIPE: {
-				SAM("-EPIPE\n");
-				break;
-			}
-			case -EMSGSIZE: {
-				SAM("-EMSGSIZE\n");
-				break;
-			}
-			case -ENOSPC: {
-				SAM("-ENOSPC\n");
-				break;
-			}
-			case -EPERM: {
-				SAM("-EPERM\n");
-				break;
-			}
-			default: {
-				SAM("unknown error: %i\n", rc);
-				break;
-			}
+				    "usb_submit_urb() failed with rc: -%s: %d\n",
+					peasycap->audio_idle,
+					strerror(rc), rc);
 			}
 		}
 	}
@@ -1006,97 +757,8 @@ if (purb->status) {
 		JOM(16, "urb status -ESHUTDOWN or -ENOENT\n");
 		return;
 	}
-	SAM("ERROR: non-zero urb status:\n");
-	switch (purb->status) {
-	case -EINPROGRESS: {
-		SAM("-EINPROGRESS\n");
-		break;
-	}
-	case -ENOSR: {
-		SAM("-ENOSR\n");
-		break;
-	}
-	case -EPIPE: {
-		SAM("-EPIPE\n");
-		break;
-	}
-	case -EOVERFLOW: {
-		SAM("-EOVERFLOW\n");
-		break;
-	}
-	case -EPROTO: {
-		SAM("-EPROTO\n");
-		break;
-	}
-	case -EILSEQ: {
-		SAM("-EILSEQ\n");
-		break;
-	}
-	case -ETIMEDOUT: {
-		SAM("-ETIMEDOUT\n");
-		break;
-	}
-	case -EMSGSIZE: {
-		SAM("-EMSGSIZE\n");
-		break;
-	}
-	case -EOPNOTSUPP: {
-		SAM("-EOPNOTSUPP\n");
-		break;
-	}
-	case -EPFNOSUPPORT: {
-		SAM("-EPFNOSUPPORT\n");
-		break;
-	}
-	case -EAFNOSUPPORT: {
-		SAM("-EAFNOSUPPORT\n");
-		break;
-	}
-	case -EADDRINUSE: {
-		SAM("-EADDRINUSE\n");
-		break;
-	}
-	case -EADDRNOTAVAIL: {
-		SAM("-EADDRNOTAVAIL\n");
-		break;
-	}
-	case -ENOBUFS: {
-		SAM("-ENOBUFS\n");
-		break;
-	}
-	case -EISCONN: {
-		SAM("-EISCONN\n");
-		break;
-	}
-	case -ENOTCONN: {
-		SAM("-ENOTCONN\n");
-		break;
-	}
-	case -ESHUTDOWN: {
-		SAM("-ESHUTDOWN\n");
-		break;
-	}
-	case -ENOENT: {
-		SAM("-ENOENT\n");
-		break;
-	}
-	case -ECONNRESET: {
-		SAM("-ECONNRESET\n");
-		break;
-	}
-	case -ENOSPC: {
-		SAM("ENOSPC\n");
-		break;
-	}
-	case -EPERM: {
-		SAM("-EPERM\n");
-		break;
-	}
-	default: {
-		SAM("unknown error: %i\n", purb->status);
-		break;
-	}
-	}
+	SAM("ERROR: non-zero urb status: -%s: %d\n",
+		strerror(purb->status), purb->status);
 	goto resubmit;
 }
 /*---------------------------------------------------------------------------*/
@@ -1109,88 +771,10 @@ oldaudio = peasycap->oldaudio;
 #endif /*UPSAMPLE*/
 
 for (i = 0;  i < purb->number_of_packets; i++) {
-	switch (purb->iso_frame_desc[i].status) {
-	case  0: {
-		break;
-	}
-	case -ENODEV: {
-		SAM("-ENODEV\n");
-		break;
-	}
-	case -ENOENT: {
-		SAM("-ENOENT\n");
-		break;
-	}
-	case -EINPROGRESS: {
-		SAM("-EINPROGRESS\n");
-		break;
-	}
-	case -EPROTO: {
-		SAM("-EPROTO\n");
-		break;
-	}
-	case -EILSEQ: {
-		SAM("-EILSEQ\n");
-		break;
-	}
-	case -ETIME: {
-		SAM("-ETIME\n");
-		break;
-	}
-	case -ETIMEDOUT: {
-		SAM("-ETIMEDOUT\n");
-		break;
-	}
-	case -EPIPE: {
-		SAM("-EPIPE\n");
-		break;
-	}
-	case -ECOMM: {
-		SAM("-ECOMM\n");
-		break;
-	}
-	case -ENOSR: {
-		SAM("-ENOSR\n");
-		break;
-	}
-	case -EOVERFLOW: {
-		SAM("-EOVERFLOW\n");
-		break;
-	}
-	case -EREMOTEIO: {
-		SAM("-EREMOTEIO\n");
-		break;
-	}
-	case -EXDEV: {
-		SAM("-EXDEV\n");
-		break;
-	}
-	case -EINVAL: {
-		SAM("-EINVAL\n");
-		break;
-	}
-	case -ECONNRESET: {
-		SAM("-ECONNRESET\n");
-		break;
-	}
-	case -ENOSPC: {
-		SAM("-ENOSPC\n");
-		break;
-	}
-	case -ESHUTDOWN: {
-		SAM("-ESHUTDOWN\n");
-		break;
-	}
-	case -EPERM: {
-		SAM("-EPERM\n");
-		break;
-	}
-	default: {
-		SAM("unknown error: %i\n", purb->iso_frame_desc[i].status);
-		break;
-	}
-	}
 	if (!purb->iso_frame_desc[i].status) {
+
+		SAM("-%s\n", strerror(purb->iso_frame_desc[i].status));
+
 		more = purb->iso_frame_desc[i].actual_length;
 
 #if defined(TESTTONE)
@@ -1370,52 +954,8 @@ if (peasycap->audio_isoc_streaming) {
 		if (-ENODEV != rc && -ENOENT != rc) {
 			SAM("ERROR: while %i=audio_idle, "
 				"usb_submit_urb() failed "
-				"with rc:\n", peasycap->audio_idle);
-		}
-		switch (rc) {
-		case -ENODEV:
-		case -ENOENT:
-			break;
-		case -ENOMEM: {
-			SAM("-ENOMEM\n");
-			break;
-		}
-		case -ENXIO: {
-			SAM("-ENXIO\n");
-			break;
-		}
-		case -EINVAL: {
-			SAM("-EINVAL\n");
-			break;
-		}
-		case -EAGAIN: {
-			SAM("-EAGAIN\n");
-			break;
-		}
-		case -EFBIG: {
-			SAM("-EFBIG\n");
-			break;
-		}
-		case -EPIPE: {
-			SAM("-EPIPE\n");
-			break;
-		}
-		case -EMSGSIZE: {
-			SAM("-EMSGSIZE\n");
-			break;
-		}
-		case -ENOSPC: {
-			SAM("-ENOSPC\n");
-			break;
-		}
-		case -EPERM: {
-			SAM("-EPERM\n");
-			break;
-		}
-		default: {
-			SAM("unknown error: %i\n", rc);
-			break;
-		}
+				"with rc: -%s: %d\n", peasycap->audio_idle,
+				strerror(rc), rc);
 		}
 	}
 }
@@ -1965,60 +1505,11 @@ if (!peasycap->audio_isoc_streaming) {
 				}
 
 				rc = usb_submit_urb(purb, GFP_KERNEL);
-				if (0 != rc) {
+				if (rc) {
 					isbad++;
 					SAM("ERROR: usb_submit_urb() failed"
-							" for urb with rc:\n");
-					switch (rc) {
-					case -ENODEV: {
-						SAM("-ENODEV\n");
-						break;
-					}
-					case -ENOENT: {
-						SAM("-ENOENT\n");
-						break;
-					}
-					case -ENOMEM: {
-						SAM("-ENOMEM\n");
-						break;
-					}
-					case -ENXIO: {
-						SAM("-ENXIO\n");
-						break;
-					}
-					case -EINVAL: {
-						SAM("-EINVAL\n");
-						break;
-					}
-					case -EAGAIN: {
-						SAM("-EAGAIN\n");
-						break;
-					}
-					case -EFBIG: {
-						SAM("-EFBIG\n");
-						break;
-					}
-					case -EPIPE: {
-						SAM("-EPIPE\n");
-						break;
-					}
-					case -EMSGSIZE: {
-						SAM("-EMSGSIZE\n");
-						break;
-					}
-					case -ENOSPC: {
-						nospc++;
-						break;
-					}
-					case -EPERM: {
-						SAM("-EPERM\n");
-						break;
-					}
-					default: {
-						SAM("unknown error: %i\n", rc);
-						break;
-					}
-					}
+						" for urb with rc: -%s: %d\n",
+						strerror(rc), rc);
 				} else {
 					 m++;
 				}
-- 
1.7.4.1

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux