From louie@whizzo.transsys.com  Sun Jan 23 10:48:20 2000
Return-Path: <louie@whizzo.transsys.com>
Received: from whizzo.transsys.com (whizzo.TransSys.COM [144.202.42.10])
	by hub.freebsd.org (Postfix) with ESMTP id 1062914C88
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 23 Jan 2000 10:48:20 -0800 (PST)
	(envelope-from louie@whizzo.transsys.com)
Received: (from louie@localhost)
	by whizzo.transsys.com (8.9.3/8.9.1) id NAA05102;
	Sun, 23 Jan 2000 13:48:16 -0500 (EST)
	(envelope-from louie)
Message-Id: <200001231848.NAA05102@whizzo.transsys.com>
Date: Sun, 23 Jan 2000 13:48:16 -0500 (EST)
From: Louis Mamakos <louie@TransSys.COM>
Sender: louie@whizzo.transsys.com
Reply-To: louie@TransSys.COM
To: FreeBSD-gnats-submit@freebsd.org, n_hibma@webweaving.org
Subject: ugen set configuration ioctl returns EIO on "normal" completeion
X-Send-Pr-Version: 3.2

>Number:         16315
>Category:       kern
>Synopsis:       USB ugen set configuration ioctl() returns EIO rather than 0
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 23 10:50:01 PST 2000
>Closed-Date:    Mon Jan 24 02:25:04 PST 2000
>Last-Modified:  Mon Jan 24 02:25:27 PST 2000
>Originator:     Louis Mamakos
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
>Environment:

Just out of the oven 4.0-current.

>Description:

The previous fix for the USB ugen device set configuration ioctl()
has a slight error, and returns EIO way too often.

>How-To-Repeat:

Try the ioctl() on a device that supports it.

>Fix:

Includes additional debugging message.

Index: /sys/dev/usb/ugen.c
===================================================================
RCS file: /usr/local/FreeBSD/cvs/src/sys/dev/usb/ugen.c,v
retrieving revision 1.35
diff -u -r1.35 ugen.c
--- /sys/dev/usb/ugen.c	2000/01/23 15:48:29	1.35
+++ /sys/dev/usb/ugen.c	2000/01/23 18:42:49
@@ -209,8 +209,12 @@
 	 * control endpoint is open or not. It is always present.
 	 */
 	for (endptno = 1; endptno < USB_MAX_ENDPOINTS; endptno++)
-		if (sc->sc_is_open[endptno])
+		if (sc->sc_is_open[endptno]) {
+			DPRINTFN(1,
+			     ("ugen_set_config: %s - endpoint %d is open\n",
+			      USBDEVNAME(sc->sc_dev), endptno));
 			return (USBD_IN_USE);
+		}
 
 	if (usbd_get_config_descriptor(dev)->bConfigurationValue != configno) {
 		/* Avoid setting the current value. */
@@ -957,10 +961,14 @@
 		if (!(flag & FWRITE))
 			return (EPERM);
 		err = ugen_set_config(sc, *(int *)addr);
-		if (err == USBD_IN_USE)
-			return(EBUSY);
-		else
+		switch (err) {
+		case USBD_NORMAL_COMPLETION:
+			break;
+		case USBD_IN_USE:
+			return (EBUSY);
+		default:
 			return (EIO);
+		}
 		break;
 	case USB_GET_ALTINTERFACE:
 		ai = (struct usb_alt_interface *)addr;


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: n_hibma 
State-Changed-When: Mon Jan 24 02:25:04 PST 2000 
State-Changed-Why:  
Patch committed. thanks for the testing. 
. 
>Unformatted:
