diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2013-04-10 11:11:35 -0400 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2013-04-11 15:34:10 -0400 |
commit | 9f8f962c85461324d18dcb2b1b94a932494d2cc5 (patch) | |
tree | b22a3535959205a4a0ecaa36173f6a8d0da2f4e0 | |
parent | b3916db32c4a3124eee9f3742a2f4723731d7602 (diff) |
Bluetooth: Use separate function for BCM92035 vendor setup
Trying to squeeze every single vendor setup routine into the same function
and have it assigned all the time is actually a bad idea. Especially since
the core can handle the absence of a setup routine perfectly fine.
To make this a lot simpler for future additions of vendor setup code,
split the BCM92035 setup into its own function and only assign it when
this specific device has been detected.
Doing it like this has the nice side benefit that we do not have to keep
a copy of the driver_info around.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
-rw-r--r-- | drivers/bluetooth/btusb.c | 52 |
1 files changed, 24 insertions, 28 deletions
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 35c967f5b9fc..3d684d20b584 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c | |||
@@ -246,7 +246,6 @@ struct btusb_data { | |||
246 | struct usb_endpoint_descriptor *isoc_rx_ep; | 246 | struct usb_endpoint_descriptor *isoc_rx_ep; |
247 | 247 | ||
248 | __u8 cmdreq_type; | 248 | __u8 cmdreq_type; |
249 | unsigned long driver_info; | ||
250 | 249 | ||
251 | unsigned int sco_num; | 250 | unsigned int sco_num; |
252 | int isoc_altsetting; | 251 | int isoc_altsetting; |
@@ -700,26 +699,6 @@ static int btusb_flush(struct hci_dev *hdev) | |||
700 | return 0; | 699 | return 0; |
701 | } | 700 | } |
702 | 701 | ||
703 | static int btusb_setup(struct hci_dev *hdev) | ||
704 | { | ||
705 | struct btusb_data *data = hci_get_drvdata(hdev); | ||
706 | |||
707 | BT_DBG("%s", hdev->name); | ||
708 | |||
709 | if (data->driver_info & BTUSB_BCM92035) { | ||
710 | struct sk_buff *skb; | ||
711 | __u8 val = 0x00; | ||
712 | |||
713 | skb = __hci_cmd_sync(hdev, 0xfc3b, 1, &val, HCI_INIT_TIMEOUT); | ||
714 | if (IS_ERR(skb)) | ||
715 | BT_ERR("BCM92035 command failed (%ld)", -PTR_ERR(skb)); | ||
716 | else | ||
717 | kfree_skb(skb); | ||
718 | } | ||
719 | |||
720 | return 0; | ||
721 | } | ||
722 | |||
723 | static int btusb_send_frame(struct sk_buff *skb) | 702 | static int btusb_send_frame(struct sk_buff *skb) |
724 | { | 703 | { |
725 | struct hci_dev *hdev = (struct hci_dev *) skb->dev; | 704 | struct hci_dev *hdev = (struct hci_dev *) skb->dev; |
@@ -948,6 +927,22 @@ static void btusb_waker(struct work_struct *work) | |||
948 | usb_autopm_put_interface(data->intf); | 927 | usb_autopm_put_interface(data->intf); |
949 | } | 928 | } |
950 | 929 | ||
930 | static int btusb_setup_bcm92035(struct hci_dev *hdev) | ||
931 | { | ||
932 | struct sk_buff *skb; | ||
933 | u8 val = 0x00; | ||
934 | |||
935 | BT_DBG("%s", hdev->name); | ||
936 | |||
937 | skb = __hci_cmd_sync(hdev, 0xfc3b, 1, &val, HCI_INIT_TIMEOUT); | ||
938 | if (IS_ERR(skb)) | ||
939 | BT_ERR("BCM92035 command failed (%ld)", -PTR_ERR(skb)); | ||
940 | else | ||
941 | kfree_skb(skb); | ||
942 | |||
943 | return 0; | ||
944 | } | ||
945 | |||
951 | static int btusb_probe(struct usb_interface *intf, | 946 | static int btusb_probe(struct usb_interface *intf, |
952 | const struct usb_device_id *id) | 947 | const struct usb_device_id *id) |
953 | { | 948 | { |
@@ -1017,7 +1012,6 @@ static int btusb_probe(struct usb_interface *intf, | |||
1017 | return -ENODEV; | 1012 | return -ENODEV; |
1018 | 1013 | ||
1019 | data->cmdreq_type = USB_TYPE_CLASS; | 1014 | data->cmdreq_type = USB_TYPE_CLASS; |
1020 | data->driver_info = id->driver_info; | ||
1021 | 1015 | ||
1022 | data->udev = interface_to_usbdev(intf); | 1016 | data->udev = interface_to_usbdev(intf); |
1023 | data->intf = intf; | 1017 | data->intf = intf; |
@@ -1045,12 +1039,14 @@ static int btusb_probe(struct usb_interface *intf, | |||
1045 | 1039 | ||
1046 | SET_HCIDEV_DEV(hdev, &intf->dev); | 1040 | SET_HCIDEV_DEV(hdev, &intf->dev); |
1047 | 1041 | ||
1048 | hdev->open = btusb_open; | 1042 | hdev->open = btusb_open; |
1049 | hdev->close = btusb_close; | 1043 | hdev->close = btusb_close; |
1050 | hdev->flush = btusb_flush; | 1044 | hdev->flush = btusb_flush; |
1051 | hdev->setup = btusb_setup; | 1045 | hdev->send = btusb_send_frame; |
1052 | hdev->send = btusb_send_frame; | 1046 | hdev->notify = btusb_notify; |
1053 | hdev->notify = btusb_notify; | 1047 | |
1048 | if (id->driver_info & BTUSB_BCM92035) | ||
1049 | hdev->setup = btusb_setup_bcm92035; | ||
1054 | 1050 | ||
1055 | /* Interface numbers are hardcoded in the specification */ | 1051 | /* Interface numbers are hardcoded in the specification */ |
1056 | data->isoc = usb_ifnum_to_if(data->udev, 1); | 1052 | data->isoc = usb_ifnum_to_if(data->udev, 1); |