linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btusb: Use USB_INTERFACE_INFO to do device matching
@ 2011-11-15  4:53 Yao, Costa
  2011-11-16  1:16 ` Marcel Holtmann
  0 siblings, 1 reply; 12+ messages in thread
From: Yao, Costa @ 2011-11-15  4:53 UTC (permalink / raw)
  To: marcel@holtmann.org, padovan@profusion.mobi,
	linux-bluetooth@vger.kernel.org

1 Use USB_INTERFACE_INFO to do device matching, other than USB_DEVICE_INFO.
2 Delete desc.bInterfaceNumber != 0 check.

Signed-off-by: Costa Yao <cqyao@qca.qualcomm.com>
---
 drivers/bluetooth/btusb.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 2bd87d4..fbac911 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -57,8 +57,8 @@ static struct usb_driver btusb_driver;
 #define BTUSB_ATH3012		0x80
 
 static struct usb_device_id btusb_table[] = {
-	/* Generic Bluetooth USB device */
-	{ USB_DEVICE_INFO(0xe0, 0x01, 0x01) },
+	/* Bluetooth USB interface */
+	{ USB_INTERFACE_INFO(0xe0, 0x01, 0x01) },
 
 	/* Broadcom SoftSailing reporting vendor specific */
 	{ USB_DEVICE(0x05ac, 0x21e1) },
@@ -918,10 +918,6 @@ static int btusb_probe(struct usb_interface *intf,
 
 	BT_DBG("intf %p id %p", intf, id);
 
-	/* interface numbers are hardcoded in the spec */
-	if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
-		return -ENODEV;
-
 	if (!id->driver_info) {
 		const struct usb_device_id *match;
 		match = usb_match_id(intf, blacklist_table);
@@ -1017,8 +1013,12 @@ static int btusb_probe(struct usb_interface *intf,
 
 	hdev->owner = THIS_MODULE;
 
-	/* Interface numbers are hardcoded in the specification */
-	data->isoc = usb_ifnum_to_if(data->udev, 1);
+	/* According to HCI-USB specification, the interface for
+	 * SCO data endpoint follows the interface for commands,
+	 * events and ACL data
+	 */
+	data->isoc = usb_ifnum_to_if(data->udev,
+		intf->cur_altsetting->desc.bInterfaceNumber + 1);
 
 	if (!reset)
 		set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [PATCH] Bluetooth: btusb: Use USB_INTERFACE_INFO to do device matching
@ 2011-11-14 11:37 Yao, Costa
  2011-11-15  2:23 ` Marcel Holtmann
  0 siblings, 1 reply; 12+ messages in thread
From: Yao, Costa @ 2011-11-14 11:37 UTC (permalink / raw)
  To: marcel@holtmann.org, padovan@profusion.mobi,
	linux-bluetooth@vger.kernel.org

Subject: [PATCH] Bluetooth: btusb: Use USB_INTERFACE_INFO to do device matching.

1 Use USB_INTERFACE_INFO to do device matching, other than USB_DEVICE_INFO.
2 And we try to find the first interface containing the interrupt endpoint.

Signed-off-by: Costa Yao <cqyao@qca.qualcomm.com>
---
 drivers/bluetooth/btusb.c |   63 ++++++++++++++++++++++++--------------------
 1 files changed, 34 insertions(+), 29 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 2bd87d4..2575256 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -57,8 +57,8 @@ static struct usb_driver btusb_driver;
 #define BTUSB_ATH3012		0x80
 
 static struct usb_device_id btusb_table[] = {
-	/* Generic Bluetooth USB device */
-	{ USB_DEVICE_INFO(0xe0, 0x01, 0x01) },
+	/* Bluetooth USB interface */
+	{ USB_INTERFACE_INFO(0xe0, 0x01, 0x01) },
 
 	/* Broadcom SoftSailing reporting vendor specific */
 	{ USB_DEVICE(0x05ac, 0x21e1) },
@@ -912,14 +912,35 @@ static int btusb_probe(struct usb_interface *intf,
 				const struct usb_device_id *id)
 {
 	struct usb_endpoint_descriptor *ep_desc;
+	struct usb_endpoint_descriptor *intr_ep = NULL;
+	struct usb_endpoint_descriptor *bulk_tx_ep = NULL;
+	struct usb_endpoint_descriptor *bulk_rx_ep = NULL;
 	struct btusb_data *data;
 	struct hci_dev *hdev;
 	int i, err;
 
 	BT_DBG("intf %p id %p", intf, id);
 
-	/* interface numbers are hardcoded in the spec */
-	if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
+	for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
+		ep_desc = &intf->cur_altsetting->endpoint[i].desc;
+
+		if (usb_endpoint_is_int_in(ep_desc)) {
+			intr_ep = ep_desc;
+			continue;
+		}
+
+		if (usb_endpoint_is_bulk_out(ep_desc)) {
+			bulk_tx_ep = ep_desc;
+			continue;
+		}
+
+		if (usb_endpoint_is_bulk_in(ep_desc)) {
+			bulk_rx_ep = ep_desc;
+			continue;
+		}
+	}
+
+	if (!intr_ep || !bulk_tx_ep || !bulk_rx_ep)
 		return -ENODEV;
 
 	if (!id->driver_info) {
@@ -954,29 +975,9 @@ static int btusb_probe(struct usb_interface *intf,
 	if (!data)
 		return -ENOMEM;
 
-	for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
-		ep_desc = &intf->cur_altsetting->endpoint[i].desc;
-
-		if (!data->intr_ep && usb_endpoint_is_int_in(ep_desc)) {
-			data->intr_ep = ep_desc;
-			continue;
-		}
-
-		if (!data->bulk_tx_ep && usb_endpoint_is_bulk_out(ep_desc)) {
-			data->bulk_tx_ep = ep_desc;
-			continue;
-		}
-
-		if (!data->bulk_rx_ep && usb_endpoint_is_bulk_in(ep_desc)) {
-			data->bulk_rx_ep = ep_desc;
-			continue;
-		}
-	}
-
-	if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) {
-		kfree(data);
-		return -ENODEV;
-	}
+	data->intr_ep = intr_ep;
+	data->bulk_tx_ep = bulk_tx_ep;
+	data->bulk_rx_ep = bulk_rx_ep;
 
 	data->cmdreq_type = USB_TYPE_CLASS;
 
@@ -1017,8 +1018,12 @@ static int btusb_probe(struct usb_interface *intf,
 
 	hdev->owner = THIS_MODULE;
 
-	/* Interface numbers are hardcoded in the specification */
-	data->isoc = usb_ifnum_to_if(data->udev, 1);
+	/* Note: As HCI-USB description,
+	 * We can expect isoc interface to be bInterfaceNumber + 1.
+	 * Or it is better to check all interfaces to look for isoc.
+	 */
+	data->isoc = usb_ifnum_to_if(data->udev,
+		intf->cur_altsetting->desc.bInterfaceNumber + 1);
 
 	if (!reset)
 		set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks);
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [PATCH] Bluetooth: btusb: Use USB_INTERFACE_INFO to do device matching
@ 2011-11-14  6:34 Yao, Costa
  2011-11-14  9:32 ` Marcel Holtmann
  0 siblings, 1 reply; 12+ messages in thread
From: Yao, Costa @ 2011-11-14  6:34 UTC (permalink / raw)
  To: marcel@holtmann.org, padovan@profusion.mobi,
	linux-bluetooth@vger.kernel.org


1 Use USB_INTERFACE_INFO to do device matching, other than USB_DEVICE_INFO.
2 And we try to find the first interface containing the interrupt endpoint.

Signed-off-by: Costa Yao <cqyao@qca.qualcomm.com>
---
 drivers/bluetooth/btusb.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 9db2476..80d7e2d 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -58,7 +58,7 @@ static struct usb_driver btusb_driver;
 
 static struct usb_device_id btusb_table[] = {
 	/* Generic Bluetooth USB device */
-	{ USB_DEVICE_INFO(0xe0, 0x01, 0x01) },
+	{ USB_INTERFACE_INFO(0xe0, 0x01, 0x01) },
 
 	/* Broadcom SoftSailing reporting vendor specific */
 	{ USB_DEVICE(0x05ac, 0x21e1) },
@@ -915,9 +915,14 @@ static int btusb_probe(struct usb_interface *intf,
 
 	BT_DBG("intf %p id %p", intf, id);
 
-	/* interface numbers are hardcoded in the spec */
-	if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
+	for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; i++) {
+		ep_desc = &intf->cur_altsetting->endpoint[i].desc;
+
+		if (usb_endpoint_is_int_in(ep_desc))
+			break;
+
 		return -ENODEV;
+	}
 
 	if (!id->driver_info) {
 		const struct usb_device_id *match;
@@ -1014,8 +1019,9 @@ static int btusb_probe(struct usb_interface *intf,
 
 	hdev->owner = THIS_MODULE;
 
-	/* Interface numbers are hardcoded in the specification */
-	data->isoc = usb_ifnum_to_if(data->udev, 1);
+
+	data->isoc = usb_ifnum_to_if(data->udev,
+		1+intf->cur_altsetting->desc.bInterfaceNumber);
 
 	if (!reset)
 		set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks);
-- 
1.7.4.1

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

end of thread, other threads:[~2011-11-16 20:24 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-15  4:53 [PATCH] Bluetooth: btusb: Use USB_INTERFACE_INFO to do device matching Yao, Costa
2011-11-16  1:16 ` Marcel Holtmann
2011-11-16  2:14   ` Yao, Costa
2011-11-16  5:45     ` Marcel Holtmann
2011-11-16 20:24     ` Gustavo Padovan
  -- strict thread matches above, loose matches on Subject: below --
2011-11-14 11:37 Yao, Costa
2011-11-15  2:23 ` Marcel Holtmann
2011-11-14  6:34 Yao, Costa
2011-11-14  9:32 ` Marcel Holtmann
2011-11-14 10:20   ` Yao, Costa
2011-11-16  8:29   ` Yao, Costa
2011-11-16  9:14     ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).