NetBSD Problem Report #29754

From rix@anarchy.estpak.ee  Mon Mar 21 14:37:02 2005
Return-Path: <rix@anarchy.estpak.ee>
Received: from anarchy.estpak.ee (test.estpak.ee [194.126.115.47])
	by narn.netbsd.org (Postfix) with ESMTP id C8FF363B11B
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 21 Mar 2005 14:37:01 +0000 (UTC)
Message-Id: <200503211436.j2LEas45000418@anarchy.estpak.ee>
Date: Mon, 21 Mar 2005 14:36:55 GMT
From: rix@estpak.ee
Reply-To: rix@estpak.ee
To: gnats-bugs@netbsd.org
Subject: umodem doesn't support devices without CM or ACM
X-Send-Pr-Version: 3.95

>Number:         29754
>Category:       kern
>Synopsis:       umodem doesn't support devices without CM or ACM
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    itohy
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 21 14:38:00 +0000 2005
>Closed-Date:    Wed Apr 20 10:57:57 +0000 2005
>Last-Modified:  Thu Jul 21 19:27:09 +0000 2005
>Originator:     rivo nurges
>Release:        NetBSD 2.99.16
>Organization:
>Environment:
System: NetBSD anarchy.estpak.ee 2.99.16 NetBSD 2.99.16 (ANARCHY) #56: Mon Mar 21 14:03:29 UTC 2005 rix@anarchy.estpak.ee:/export/src/sys/arch/i386/compile/ANARCHY i386
Architecture: i386
Machine: i386
>Description:
	Nokia 9300 with DKU-2 usb cable doesn't have CM and ACM descriptors but 
	has UNION descriptor pointing to data interface. NetBSD's current
	driver doesn't handle this.

>How-To-Repeat:
>Fix:
	Here is a patch.

Index: sys/dev/usb/umodem.c
===================================================================
RCS file: /NetBSD/src/sys/dev/usb/umodem.c,v
retrieving revision 1.49
diff -u -3 -p -r1.49 umodem.c
--- sys/dev/usb/umodem.c	23 Oct 2004 13:28:26 -0000	1.49
+++ sys/dev/usb/umodem.c	21 Mar 2005 14:10:51 -0000
@@ -129,8 +129,6 @@ Static usbd_status umodem_set_comm_featu
 Static usbd_status umodem_set_line_coding(struct umodem_softc *sc,
 					  usb_cdc_line_state_t *state);

-Static void	umodem_get_caps(usbd_device_handle, int *, int *);
-
 Static void	umodem_get_status(void *, int portno, u_char *lsr, u_char *msr);
 Static void	umodem_set(void *, int, int, int);
 Static void	umodem_dtr(struct umodem_softc *, int);
@@ -160,7 +158,6 @@ USB_MATCH(umodem)
 {
 	USB_MATCH_START(umodem, uaa);
 	usb_interface_descriptor_t *id;
-	int cm, acm;

 	if (uaa->iface == NULL)
 		return (UMATCH_NONE);
@@ -172,12 +169,6 @@ USB_MATCH(umodem)
 	    id->bInterfaceProtocol != UIPROTO_CDC_AT)
 		return (UMATCH_NONE);

-	umodem_get_caps(uaa->device, &cm, &acm);
-	if (!(cm & USB_CDC_CM_DOES_CM) ||
-	    !(cm & USB_CDC_CM_OVER_DATA) ||
-	    !(acm & USB_CDC_ACM_HAS_LINE))
-		return (UMATCH_NONE);
-
 	return (UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO);
 }

@@ -188,9 +179,12 @@ USB_ATTACH(umodem)
 	usb_interface_descriptor_t *id;
 	usb_endpoint_descriptor_t *ed;
 	const usb_cdc_cm_descriptor_t *cmd;
+	const usb_cdc_acm_descriptor_t *acmd;
+	const usb_cdc_union_descriptor_t *uniond;
+	const usb_descriptor_t *desc;
+	usbd_desc_iter_t iter;
 	char devinfo[1024];
 	usbd_status err;
-	int data_ifcno;
 	int i;
 	struct ucom_attach_args uca;

@@ -205,19 +199,38 @@ USB_ATTACH(umodem)
 	       devinfo, id->bInterfaceClass, id->bInterfaceSubClass);
 	sc->sc_ctl_iface_no = id->bInterfaceNumber;

-	umodem_get_caps(dev, &sc->sc_cm_cap, &sc->sc_acm_cap);
+	/* Get the data interface no. and capabilities*/
+	usb_desc_iter_init(dev, &iter);
+	desc = usb_desc_iter_next(&iter);
+	while(desc) {
+		if(desc->bDescriptorType == UDESC_CS_INTERFACE) {
+			switch(desc->bDescriptorSubtype) {
+			case UDESCSUB_CDC_CM:
+				cmd = (usb_cdc_cm_descriptor_t *)desc;
+				sc->sc_cm_cap = cmd->bmCapabilities;
+				sc->sc_data_iface_no = cmd->bDataInterface;
+			break;
+			case UDESCSUB_CDC_ACM:
+				acmd = (usb_cdc_acm_descriptor_t *)desc;
+				sc->sc_acm_cap = acmd->bmCapabilities;
+			break;
+			case UDESCSUB_CDC_UNION:
+				uniond = (usb_cdc_union_descriptor_t *)desc;
+				sc->sc_data_iface_no = uniond->bSlaveInterface[0];
+			break;
+			}
+		}
+	desc = usb_desc_iter_next(&iter);
+	}

-	/* Get the data interface no. */
-	cmd = (usb_cdc_cm_descriptor_t *)usb_find_desc(dev, UDESC_CS_INTERFACE,
-						       UDESCSUB_CDC_CM);
-	if (cmd == NULL) {
-		printf("%s: no CM descriptor\n", USBDEVNAME(sc->sc_dev));
+	if (sc->sc_data_iface_no == 0) {
+		printf("%s: no pointer to data interface\n",
+		       USBDEVNAME(sc->sc_dev));
 		goto bad;
 	}
-	sc->sc_data_iface_no = data_ifcno = cmd->bDataInterface;

 	printf("%s: data interface %d, has %sCM over data, has %sbreak\n",
-	       USBDEVNAME(sc->sc_dev), data_ifcno,
+	       USBDEVNAME(sc->sc_dev), sc->sc_data_iface_no,
 	       sc->sc_cm_cap & USB_CDC_CM_OVER_DATA ? "" : "no ",
 	       sc->sc_acm_cap & USB_CDC_ACM_HAS_BREAK ? "" : "no ");

@@ -225,7 +238,8 @@ USB_ATTACH(umodem)
 	for (i = 0; i < uaa->nifaces; i++) {
 		if (uaa->ifaces[i] != NULL) {
 			id = usbd_get_interface_descriptor(uaa->ifaces[i]);
-			if (id != NULL && id->bInterfaceNumber == data_ifcno) {
+			if (id != NULL &&
+                            id->bInterfaceNumber == sc->sc_data_iface_no) {
 				sc->sc_data_iface = uaa->ifaces[i];
 				uaa->ifaces[i] = NULL;
 			}
@@ -443,31 +457,6 @@ umodem_intr(usbd_xfer_handle xfer, usbd_
 			 sc->sc_notify_buf.bNotification));
 		break;
 	}
-}
-
-void
-umodem_get_caps(usbd_device_handle dev, int *cm, int *acm)
-{
-	const usb_cdc_cm_descriptor_t *cmd;
-	const usb_cdc_acm_descriptor_t *cad;
-
-	*cm = *acm = 0;
-
-	cmd = (usb_cdc_cm_descriptor_t *)usb_find_desc(dev, UDESC_CS_INTERFACE,
-						       UDESCSUB_CDC_CM);
-	if (cmd == NULL) {
-		DPRINTF(("umodem_get_desc: no CM desc\n"));
-		return;
-	}
-	*cm = cmd->bmCapabilities;
-
-	cad = (usb_cdc_acm_descriptor_t *)usb_find_desc(dev, UDESC_CS_INTERFACE,
-							UDESCSUB_CDC_ACM);
-	if (cad == NULL) {
-		DPRINTF(("umodem_get_desc: no ACM desc\n"));
-		return;
-	}
-	*acm = cad->bmCapabilities;
 }

 void

>Release-Note:

>Audit-Trail:
From: ITOH Yasufumi <itohy@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: PR/29754 CVS commit: src/sys/dev/usb
Date: Fri, 15 Apr 2005 14:43:05 +0000 (UTC)

 Module Name:	src
 Committed By:	itohy
 Date:		Fri Apr 15 14:43:05 UTC 2005

 Modified Files:
 	src/sys/dev/usb: umodem.c umodem_common.c umodemvar.h

 Log Message:
 If CM descriptor is found, use the data interface in it;
 if CM descriptor is NOT found but UNION descriotor is found,
 use the data interface in it.
 Do not require CM or ACM descriptors as long as
 the data interface is found.

 Should fix NetBSD PR #29754 by rivo nurges.


 To generate a diff of this commit:
 cvs rdiff -r1.51 -r1.52 src/sys/dev/usb/umodem.c
 cvs rdiff -r1.1 -r1.2 src/sys/dev/usb/umodem_common.c \
     src/sys/dev/usb/umodemvar.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

Responsible-Changed-From-To: kern-bug-people->itohy
Responsible-Changed-By: itohy@netbsd.org
Responsible-Changed-When: Fri, 15 Apr 2005 14:58:10 +0000
Responsible-Changed-Why:
I'll look at it.


State-Changed-From-To: open->feedback
State-Changed-By: itohy@netbsd.org
State-Changed-When: Fri, 15 Apr 2005 14:58:10 +0000
State-Changed-Why:
Should be fixed by umodem.c:1.52, umodem_common.c:1.2, umodemvar.h:1.2
but I don't have the hardware.  Can you see if it works for you?


From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: PR/29754 CVS commit: [netbsd-3] src/sys/dev/usb
Date: Sun, 17 Apr 2005 10:29:49 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Sun Apr 17 10:29:49 UTC 2005

 Modified Files:
 	src/sys/dev/usb [netbsd-3]: umodem_common.c umodemvar.h

 Log Message:
 Pull up revision 1.2 (requested by itohy in ticket #160):
 If CM descriptor is found, use the data interface in it;
 if CM descriptor is NOT found but UNION descriotor is found,
 use the data interface in it.
 Do not require CM or ACM descriptors as long as
 the data interface is found.
 Should fix NetBSD PR #29754 by rivo nurges.


 To generate a diff of this commit:
 cvs rdiff -r1.3.2.1 -r1.3.2.2 src/sys/dev/usb/umodem_common.c
 cvs rdiff -r1.2.2.1 -r1.2.2.2 src/sys/dev/usb/umodemvar.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Matthias Scheler <tron@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: PR/29754 CVS commit: [netbsd-3] src/sys/dev/usb
Date: Sun, 17 Apr 2005 10:29:57 +0000 (UTC)

 Module Name:	src
 Committed By:	tron
 Date:		Sun Apr 17 10:29:57 UTC 2005

 Modified Files:
 	src/sys/dev/usb [netbsd-3]: umodem.c

 Log Message:
 Pull up revision 1.52 (requested by itohy in ticket #160):
 If CM descriptor is found, use the data interface in it;
 if CM descriptor is NOT found but UNION descriotor is found,
 use the data interface in it.
 Do not require CM or ACM descriptors as long as
 the data interface is found.
 Should fix NetBSD PR #29754 by rivo nurges.


 To generate a diff of this commit:
 cvs rdiff -r1.49.10.2 -r1.49.10.3 src/sys/dev/usb/umodem.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: feedback->closed
State-Changed-By: itohy@netbsd.org
State-Changed-When: Wed, 20 Apr 2005 10:57:57 +0000
State-Changed-Why:
Fix confirmed by the submitter.
Thank you for reporting and testing.


From: Jeff Rizzo <riz@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: PR/29754 CVS commit: [netbsd-2] src/sys/dev/usb
Date: Thu, 21 Jul 2005 19:26:39 +0000 (UTC)

 Module Name:	src
 Committed By:	riz
 Date:		Thu Jul 21 19:26:39 UTC 2005

 Modified Files:
 	src/sys/dev/usb [netbsd-2]: umodem.c

 Log Message:
 Pull up revisions 1.47-1.52 (requested by itohy in ticket #1430):
 1.47:
 use bounded string ops (snprintf, strl*)

 1.48:
 a round of autoconf cleanup:
 -convert submatch() style functions (passed to config_search() or
 config_found_sm()) to the locator passing variants
 -pass interface attributes in some cases
 -make submatch() functions look uniformly as far as possible
 -avoid macros which just hide cfdata members, and reduce dependencies
 on "locators.h"

 1.49:
 Use new functions for getting descriptors.

 1.50:
 Allow multiple modem interfaces per configuration.

 1.51:
 Split common modem part of umodem.c to umodem_common.c and umodemvar.h,
 to be shared with other umodem-like drivers.

 1.52:
 If CM descriptor is found, use the data interface in it;
 if CM descriptor is NOT found but UNION descriotor is found,
 use the data interface in it.
 Do not require CM or ACM descriptors as long as
 the data interface is found.
 Should fix NetBSD PR #29754 by rivo nurges.


 To generate a diff of this commit:
 cvs rdiff -r1.46 -r1.46.4.1 src/sys/dev/usb/umodem.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Jeff Rizzo <riz@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: PR/29754 CVS commit: [netbsd-2] src/sys/dev/usb
Date: Thu, 21 Jul 2005 19:26:44 +0000 (UTC)

 Module Name:	src
 Committed By:	riz
 Date:		Thu Jul 21 19:26:44 UTC 2005

 Added Files:
 	src/sys/dev/usb [netbsd-2]: umodemvar.h

 Log Message:
 Pull up new file (revisions 1.1-1.2) (requested by itohy in ticket #1430):
 1.1:
 Split common modem part of umodem.c to umodem_common.c and umodemvar.h,
 to be shared with other umodem-like drivers.

 1.2:
 If CM descriptor is found, use the data interface in it;
 if CM descriptor is NOT found but UNION descriotor is found,
 use the data interface in it.
 Do not require CM or ACM descriptors as long as
 the data interface is found.
 Should fix NetBSD PR #29754 by rivo nurges.


 To generate a diff of this commit:
 cvs rdiff -r0 -r1.2.8.1 src/sys/dev/usb/umodemvar.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: Jeff Rizzo <riz@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: PR/29754 CVS commit: [netbsd-2] src/sys/dev/usb
Date: Thu, 21 Jul 2005 19:26:48 +0000 (UTC)

 Module Name:	src
 Committed By:	riz
 Date:		Thu Jul 21 19:26:48 UTC 2005

 Added Files:
 	src/sys/dev/usb [netbsd-2]: umodem_common.c

 Log Message:
 Pull up new file (revisions 1.1-1.3 via patch) (requested by itohy
 in ticket #1430):
 1.1:
 Split common modem part of umodem.c to umodem_common.c and umodemvar.h,
 to be shared with other umodem-like drivers.

 1.2:
 If CM descriptor is found, use the data interface in it;
 if CM descriptor is NOT found but UNION descriotor is found,
 use the data interface in it.
 Do not require CM or ACM descriptors as long as
 the data interface is found.
 Should fix NetBSD PR #29754 by rivo nurges.

 1.3:
 Fix function name in debug messages.
 White space police.


 To generate a diff of this commit:
 cvs rdiff -r0 -r1.5.4.1 src/sys/dev/usb/umodem_common.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.