public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* usb.c patch -> successfuly read usb descriptors on some USB device
@ 2002-01-15  9:47 Dmitri Kassatkine
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitri Kassatkine @ 2002-01-15  9:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: Kassatkine Dmitri (NRC/Helsinki)

[-- Attachment #1: Type: text/plain, Size: 641 bytes --]

Hi,

Sometimes USB subsystem cannot get USB descriptor.

Jan 15 10:44:21 selma kernel: hub.c: USB new device connect on bus1/1, 
assign
ed device number 25
Jan 15 10:44:21 selma kernel: usb.c: couldn't get all of config descriptors
Jan 15 10:44:21 selma kernel: usb.c: unable to get device 25 
configuration (e
rror=-110)


Here is patch how to fix it for 2.4.17. It works for 2.4.16 as well.
 It necassary to read descriptor at once, not first 8 byte first.

It works well now for NSM USB Bluetooth dongle.

br, DMitri

-- 
 Dmitri Kassatkine
 Nokia Research Center / Helsinki
 Mobile: +358 50 4836365
 E-Mail: dmitri.kassatkine@nokia.com


[-- Attachment #2: usb.c.patch-2.4.17 --]
[-- Type: text/plain, Size: 1840 bytes --]

--- usb.c.orig	Wed Nov 21 19:59:11 2001
+++ usb.c	Tue Jan 15 11:38:35 2002
@@ -2041,7 +2041,7 @@
 		return -ENOMEM;
 	}
 
-	buffer = kmalloc(8, GFP_KERNEL);
+	buffer = kmalloc(255, GFP_KERNEL);
 	if (!buffer) {
 		err("unable to allocate memory for configuration descriptors");
 		return -ENOMEM;
@@ -2049,9 +2049,9 @@
 	desc = (struct usb_config_descriptor *)buffer;
 
 	for (cfgno = 0; cfgno < dev->descriptor.bNumConfigurations; cfgno++) {
-		/* We grab the first 8 bytes so we know how long the whole */
+		/* We grab the first 255 bytes so we know how long the whole */
 		/*  configuration is */
-		result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 8);
+		result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 255);
 		if (result < 8) {
 			if (result < 0)
 				err("unable to get descriptor");
@@ -2072,19 +2072,24 @@
 			goto err;
 		}
 
-		/* Now that we know the length, get the whole thing */
-		result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, bigbuffer, length);
-		if (result < 0) {
-			err("couldn't get all of config descriptors");
-			kfree(bigbuffer);
-			goto err;
-		}	
+		if (length > 255) {
+			/* Now that we know the length, get the whole thing */
+			result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, bigbuffer, length);
+			if (result < 0) {
+				err("couldn't get all of config descriptors");
+				kfree(bigbuffer);
+				goto err;
+			}	
 	
-		if (result < length) {
-			err("config descriptor too short (expected %i, got %i)", length, result);
-			result = -EINVAL;
-			kfree(bigbuffer);
-			goto err;
+			if (result < length) {
+				err("config descriptor too short (expected %i, got %i)", length, result);
+				result = -EINVAL;
+				kfree(bigbuffer);
+				goto err;
+			}
+		}
+		else {
+			memcpy(bigbuffer, buffer, length);
 		}
 
 		dev->rawdescriptors[cfgno] = bigbuffer;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* usb.c patch -> successfuly read usb descriptors on some USB device
@ 2002-01-15  9:59 Dmitri Kassatkine
  2002-01-15 18:38 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitri Kassatkine @ 2002-01-15  9:59 UTC (permalink / raw)
  To: linux-kernel, Dmitri Kassatkine

Hi,

Sometimes USB subsystem cannot get USB descriptor.

Jan 15 10:44:21 selma kernel: hub.c: USB new device connect on bus1/1, 
assign
ed device number 25
Jan 15 10:44:21 selma kernel: usb.c: couldn't get all of config descriptors
Jan 15 10:44:21 selma kernel: usb.c: unable to get device 25 
configuration (e
rror=-110)


Here is patch how to fix it for 2.4.17. It works for 2.4.16 as well.
 It necassary to read descriptor at once, not first 8 byte first.

It works well now for NSM USB Bluetooth dongle.

br, Dmitri


----------------------------- CUT HERE ---------------------------------------------------------
--- usb.c.orig	Wed Nov 21 19:59:11 2001
+++ usb.c	Tue Jan 15 11:38:35 2002
@@ -2041,7 +2041,7 @@
 		return -ENOMEM;
 	}
 
-	buffer = kmalloc(8, GFP_KERNEL);
+	buffer = kmalloc(255, GFP_KERNEL);
 	if (!buffer) {
 		err("unable to allocate memory for configuration descriptors");
 		return -ENOMEM;
@@ -2049,9 +2049,9 @@
 	desc = (struct usb_config_descriptor *)buffer;
 
 	for (cfgno = 0; cfgno < dev->descriptor.bNumConfigurations; cfgno++) {
-		/* We grab the first 8 bytes so we know how long the whole */
+		/* We grab the first 255 bytes so we know how long the whole */
 		/*  configuration is */
-		result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 8);
+		result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, buffer, 255);
 		if (result < 8) {
 			if (result < 0)
 				err("unable to get descriptor");
@@ -2072,19 +2072,24 @@
 			goto err;
 		}
 
-		/* Now that we know the length, get the whole thing */
-		result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, bigbuffer, length);
-		if (result < 0) {
-			err("couldn't get all of config descriptors");
-			kfree(bigbuffer);
-			goto err;
-		}	
+		if (length > 255) {
+			/* Now that we know the length, get the whole thing */
+			result = usb_get_descriptor(dev, USB_DT_CONFIG, cfgno, bigbuffer, length);
+			if (result < 0) {
+				err("couldn't get all of config descriptors");
+				kfree(bigbuffer);
+				goto err;
+			}	
 	
-		if (result < length) {
-			err("config descriptor too short (expected %i, got %i)", length, result);
-			result = -EINVAL;
-			kfree(bigbuffer);
-			goto err;
+			if (result < length) {
+				err("config descriptor too short (expected %i, got %i)", length, result);
+				result = -EINVAL;
+				kfree(bigbuffer);
+				goto err;
+			}
+		}
+		else {
+			memcpy(bigbuffer, buffer, length);
 		}
 
 		dev->rawdescriptors[cfgno] = bigbuffer;
-------------- CUT HERE ----------------------------------------------------------------------------

-- 
 Dmitri Kassatkine
 Nokia Research Center / Helsinki
 Mobile: +358 50 4836365
 E-Mail: dmitri.kassatkine@nokia.com




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: usb.c patch -> successfuly read usb descriptors on some USB device
  2002-01-15  9:59 Dmitri Kassatkine
@ 2002-01-15 18:38 ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2002-01-15 18:38 UTC (permalink / raw)
  To: Dmitri Kassatkine; +Cc: linux-kernel

On Tue, Jan 15, 2002 at 11:59:57AM +0200, Dmitri Kassatkine wrote:
> Hi,
> 
> Sometimes USB subsystem cannot get USB descriptor.
> 
> Jan 15 10:44:21 selma kernel: hub.c: USB new device connect on bus1/1, assigned device number 25
> Jan 15 10:44:21 selma kernel: usb.c: couldn't get all of config descriptors
> Jan 15 10:44:21 selma kernel: usb.c: unable to get device 25 configuration (error=-110)
> 
> Here is patch how to fix it for 2.4.17. It works for 2.4.16 as well.
> It necassary to read descriptor at once, not first 8 byte first.

Then this device does not match the USB spec.

> It works well now for NSM USB Bluetooth dongle.

Has this device gone through the USB certification process?  There are a
_lot_ of USB bluetooth devices out there that violate the USB spec, and
have not been certified.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-01-15 18:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-01-15  9:47 usb.c patch -> successfuly read usb descriptors on some USB device Dmitri Kassatkine
  -- strict thread matches above, loose matches on Subject: below --
2002-01-15  9:59 Dmitri Kassatkine
2002-01-15 18:38 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox