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

[bluetooth-dev] [PATCH] usb bluetooth bug fix for 2.4.0-test9



Hi,

Here's a patch against 2.4.0-test9 that fixes the USB bluetooth driver
due to the core usb changes.

It also adds a bare-bones text document explaining how to set up the
device nodes for the driver, and it includes a device major number
change, as it now has an "official" number and name (216 and ttyUB for
those not wanting to dig through the patch.)

thanks,

greg k-h

-- 
greg@xxxxxxx.com
diff -Naur -X /home/greg/linux/dontdiff linux-2.4.0-test9/Documentation/usb/bluetooth.txt linux-2.4.0-test9-greg/Documentation/usb/bluetooth.txt
--- linux-2.4.0-test9/Documentation/usb/bluetooth.txt	Wed Dec 31 16:00:00 1969
+++ linux-2.4.0-test9-greg/Documentation/usb/bluetooth.txt	Thu Oct  5 12:00:51 2000
@@ -0,0 +1,44 @@
+INTRODUCTION
+
+  The USB Bluetooth driver supports any USB Bluetooth device.
+  It currently works well with the Linux USB Bluetooth stack from Axis 
+  (available at http://developer.axis.com/software/bluetooth/ ) and 
+  has been rumored to work with other Linux USB Bluetooth stacks.
+
+
+CONFIGURATION
+
+  Currently the driver can handle up to 256 different USB Bluetooth 
+  devices at once. 
+
+  If you are not using devfs:
+    The major number that the driver uses is 216 so to use the driver,
+    create the following nodes:
+	mknod /dev/ttyUB0 c 216 0
+	mknod /dev/ttyUB1 c 216 1
+	mknod /dev/ttyUB2 c 216 2
+	mknod /dev/ttyUB3 c 216 3
+		.
+		.
+		.
+	mknod /dev/ttyUB254 c 216 254
+	mknod /dev/ttyUB255 c 216 255
+
+  If you are using devfs:
+    The devices supported by this driver will show up as
+    /dev/usb/ttub/{0,1,...}
+
+  When the device is connected and recognized by the driver, the driver
+  will print to the system log, which node the device has been bound to.
+
+
+CONTACT:
+
+  If anyone has any problems using this driver, please contact me, or 
+  join the Linux-USB mailing list (information on joining the mailing 
+  list, as well as a link to its searchable archive is at 
+  http://www.linux-usb.org/ )
+
+
+Greg Kroah-Hartman
+greg@xxxxxxx.com
diff -Naur -X /home/greg/linux/dontdiff linux-2.4.0-test9/drivers/usb/bluetooth.c linux-2.4.0-test9-greg/drivers/usb/bluetooth.c
--- linux-2.4.0-test9/drivers/usb/bluetooth.c	Thu Sep  7 08:39:49 2000
+++ linux-2.4.0-test9-greg/drivers/usb/bluetooth.c	Thu Oct  5 11:19:11 2000
@@ -1,11 +1,16 @@
 /*
- * bluetooth.c   Version 0.4
+ * bluetooth.c   Version 0.6
  *
  * Copyright (c) 2000 Greg Kroah-Hartman	<greg@xxxxxxx.com>
  * Copyright (c) 2000 Mark Douglas Corner	<mcorner@xxxxxxx.edu>
  *
  * USB Bluetooth driver, based on the Bluetooth Spec version 1.0B
  *
+ * (10/05/2000) Version 0.6 gkh
+ *	Fixed bug with urb->dev not being set properly, now that the usb
+ *	core needs it.
+ *	Got a real major id number and name.
+ *
  * (08/06/2000) Version 0.5 gkh
  *	Fixed problem of not resubmitting the bulk read urb if there is
  *	an error in the callback.  Ericsson devices seem to need this.
@@ -89,8 +94,8 @@
 #define BLUETOOTH_PROGRAMMING_PROTOCOL_CODE	0x01
 
 
-#define BLUETOOTH_TTY_MAJOR	240	/* Prototype number for now */
-#define BLUETOOTH_TTY_MINORS	8
+#define BLUETOOTH_TTY_MAJOR	216	/* real device node major id */
+#define BLUETOOTH_TTY_MINORS	256	/* whole lotta bluetooth devices */
 
 #define USB_BLUETOOTH_MAGIC	0x6d02	/* magic number for bluetooth struct */
 
@@ -138,11 +143,16 @@
 
 	unsigned char *		interrupt_in_buffer;
 	struct urb *		interrupt_in_urb;
+	__u8			interrupt_in_endpointAddress;
+	__u8			interrupt_in_interval;
+	int			interrupt_in_buffer_size;
 
 	unsigned char *		bulk_in_buffer;
 	struct urb *		read_urb;
+	__u8			bulk_in_endpointAddress;
+	int			bulk_in_buffer_size;
 
-	int			bulk_out_size;
+	int			bulk_out_buffer_size;
 	struct urb *		write_urb_pool[NUM_BULK_URBS];
 	__u8			bulk_out_endpointAddress;
 
@@ -312,10 +322,18 @@
 
 #ifndef BTBUGGYHARDWARE
 	/* Start reading from the device */
+	FILL_BULK_URB(bluetooth->read_urb, bluetooth->dev, 
+		      usb_rcvbulkpipe(bluetooth->dev, bluetooth->bulk_in_endpointAddress),
+		      bluetooth->bulk_in_buffer, bluetooth->bulk_in_buffer_size, 
+		      bluetooth_read_bulk_callback, bluetooth);
 	result = usb_submit_urb(bluetooth->read_urb);
 	if (result)
 		dbg(__FUNCTION__ " - usb_submit_urb(read bulk) failed with status %d", result);
 #endif
+	FILL_INT_URB(bluetooth->interrupt_in_urb, bluetooth->dev, 
+		     usb_rcvintpipe(bluetooth->dev, bluetooth->interrupt_in_endpointAddress),
+		     bluetooth->interrupt_in_buffer, bluetooth->interrupt_in_buffer_size, 
+		     bluetooth_int_callback, bluetooth, bluetooth->interrupt_in_interval);
 	result = usb_submit_urb(bluetooth->interrupt_in_urb);
 	if (result)
 		dbg(__FUNCTION__ " - usb_submit_urb(interrupt in) failed with status %d", result);
@@ -445,7 +463,7 @@
 					urb->transfer_buffer = NULL;
 				}
 
-				buffer_size = MIN (count, bluetooth->bulk_out_size);
+				buffer_size = MIN (count, bluetooth->bulk_out_buffer_size);
 				
 				new_buffer = kmalloc (buffer_size, GFP_KERNEL);
 				if (new_buffer == NULL) {
@@ -508,7 +526,7 @@
 
 	for (i = 0; i < NUM_BULK_URBS; ++i) {
 		if (bluetooth->write_urb_pool[i]->status != -EINPROGRESS) {
-			room += bluetooth->bulk_out_size;
+			room += bluetooth->bulk_out_buffer_size;
 		}
 	}
 
@@ -627,6 +645,7 @@
 #ifdef BTBUGGYHARDWARE
 void btusb_enable_bulk_read(struct tty_struct *tty){
 	struct usb_bluetooth *bluetooth = get_usb_bluetooth ((struct usb_bluetooth *)tty->driver_data, __FUNCTION__);
+	int result;
 
 	if (!bluetooth) {
 		return;
@@ -639,9 +658,15 @@
 		return;
 	}
 
-	if (bluetooth->read_urb)
-		if (usb_submit_urb(bluetooth->read_urb))
-			dbg (__FUNCTION__ " - usb_submit_urb(read bulk) failed");
+	if (bluetooth->read_urb) {
+		FILL_BULK_URB(bluetooth->read_urb, bluetooth->dev, 
+			      usb_rcvbulkpipe(bluetooth->dev, bluetooth->bulk_in_endpointAddress),
+			      bluetooth->bulk_in_buffer, bluetooth->bulk_in_buffer_size, 
+			      bluetooth_read_bulk_callback, bluetooth);
+		result = usb_submit_urb(bluetooth->read_urb);
+		if (result)
+			err (__FUNCTION__ " - failed submitting read urb, error %d", result);
+	}
 }
 
 void btusb_disable_bulk_read(struct tty_struct *tty){
@@ -782,14 +807,20 @@
 	unsigned char *data = urb->transfer_buffer;
 	unsigned int count = urb->actual_length;
 	unsigned int i;
-	uint packet_size;
+	unsigned int packet_size;
+	int result;
 
 #ifdef BTBUGGYHARDWARE
 	if ((count == 4) && (data[0] == 0x00) && (data[1] == 0x00)
 	    && (data[2] == 0x00) && (data[3] == 0x00)) {
 		urb->actual_length = 0;
-		if (usb_submit_urb(urb))
-			dbg(__FUNCTION__ " - failed resubmitting read urb");
+		FILL_BULK_URB(bluetooth->read_urb, bluetooth->dev, 
+			      usb_rcvbulkpipe(bluetooth->dev, bluetooth->bulk_in_endpointAddress),
+			      bluetooth->bulk_in_buffer, bluetooth->bulk_in_buffer_size, 
+			      bluetooth_read_bulk_callback, bluetooth);
+		result = usb_submit_urb(bluetooth->read_urb);
+		if (result)
+			err (__FUNCTION__ " - failed resubmitting read urb, error %d", result);
 
 		return;
 	}
@@ -863,8 +894,13 @@
 	}	
 
 exit:
-	if (usb_submit_urb(urb))
-		dbg(__FUNCTION__ " - failed resubmitting read urb");
+	FILL_BULK_URB(bluetooth->read_urb, bluetooth->dev, 
+		      usb_rcvbulkpipe(bluetooth->dev, bluetooth->bulk_in_endpointAddress),
+		      bluetooth->bulk_in_buffer, bluetooth->bulk_in_buffer_size, 
+		      bluetooth_read_bulk_callback, bluetooth);
+	result = usb_submit_urb(bluetooth->read_urb);
+	if (result)
+		err (__FUNCTION__ " - failed resubmitting read urb, error %d", result);
 
 	return;
 }
@@ -1027,7 +1063,8 @@
 		err("No free urbs available");
 		goto probe_error;
 	}
-	buffer_size = endpoint->wMaxPacketSize;
+	bluetooth->bulk_in_buffer_size = buffer_size = endpoint->wMaxPacketSize;
+	bluetooth->bulk_in_endpointAddress = endpoint->bEndpointAddress;
 	bluetooth->bulk_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
 	if (!bluetooth->bulk_in_buffer) {
 		err("Couldn't allocate bulk_in_buffer");
@@ -1050,7 +1087,7 @@
 		bluetooth->write_urb_pool[i] = urb;
 	}
 	
-	bluetooth->bulk_out_size = endpoint->wMaxPacketSize * 2;
+	bluetooth->bulk_out_buffer_size = endpoint->wMaxPacketSize * 2;
 
 	endpoint = interrupt_in_endpoint[0];
 	bluetooth->interrupt_in_urb = usb_alloc_urb(0);
@@ -1058,7 +1095,9 @@
 		err("No free urbs available");
 		goto probe_error;
 	}
-	buffer_size = endpoint->wMaxPacketSize;
+	bluetooth->interrupt_in_buffer_size = buffer_size = endpoint->wMaxPacketSize;
+	bluetooth->interrupt_in_endpointAddress = endpoint->bEndpointAddress;
+	bluetooth->interrupt_in_interval = endpoint->bInterval;
 	bluetooth->interrupt_in_buffer = kmalloc (buffer_size, GFP_KERNEL);
 	if (!bluetooth->interrupt_in_buffer) {
 		err("Couldn't allocate interrupt_in_buffer");
@@ -1070,7 +1109,7 @@
 
 	/* initialize the devfs nodes for this device and let the user know what bluetooths we are bound to */
 	tty_register_devfs (&bluetooth_tty_driver, 0, minor);
-	info("Bluetooth converter now attached to ttyBLUE%d (or usb/ttblue/%d for devfs)", minor, minor);
+	info("Bluetooth converter now attached to ttyUB%d (or usb/ttub/%d for devfs)", minor, minor);
 
 	bluetooth_table[minor] = bluetooth;
 
@@ -1145,7 +1184,7 @@
 			}
 		}
 		
-		info("Bluetooth converter now disconnected from ttyBLUE%d", bluetooth->minor);
+		info("Bluetooth converter now disconnected from ttyUB%d", bluetooth->minor);
 
 		bluetooth_table[bluetooth->minor] = NULL;
 
@@ -1163,7 +1202,7 @@
 static struct tty_driver bluetooth_tty_driver = {
 	magic:			TTY_DRIVER_MAGIC,
 	driver_name:		"usb-bluetooth",
-	name:			"usb/ttblue/%d",
+	name:			"usb/ttub/%d",
 	major:			BLUETOOTH_TTY_MAJOR,
 	minor_start:		0,
 	num:			BLUETOOTH_TTY_MINORS,