diff options
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r-- | drivers/bluetooth/bcm203x.c | 2 | ||||
-rw-r--r-- | drivers/bluetooth/bfusb.c | 317 | ||||
-rw-r--r-- | drivers/bluetooth/bluecard_cs.c | 2 | ||||
-rw-r--r-- | drivers/bluetooth/bpa10x.c | 1 | ||||
-rw-r--r-- | drivers/bluetooth/bt3c_cs.c | 2 | ||||
-rw-r--r-- | drivers/bluetooth/btuart_cs.c | 2 | ||||
-rw-r--r-- | drivers/bluetooth/dtl1_cs.c | 5 | ||||
-rw-r--r-- | drivers/bluetooth/hci_bcsp.c | 1 | ||||
-rw-r--r-- | drivers/bluetooth/hci_h4.c | 1 | ||||
-rw-r--r-- | drivers/bluetooth/hci_ldisc.c | 18 | ||||
-rw-r--r-- | drivers/bluetooth/hci_usb.c | 103 | ||||
-rw-r--r-- | drivers/bluetooth/hci_usb.h | 1 | ||||
-rw-r--r-- | drivers/bluetooth/hci_vhci.c | 101 |
13 files changed, 325 insertions, 231 deletions
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c index 3e7a067cc087..13ba729cdd57 100644 --- a/drivers/bluetooth/bcm203x.c +++ b/drivers/bluetooth/bcm203x.c | |||
@@ -22,7 +22,6 @@ | |||
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <linux/config.h> | ||
26 | #include <linux/module.h> | 25 | #include <linux/module.h> |
27 | 26 | ||
28 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
@@ -235,6 +234,7 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id | |||
235 | data->fw_data = kmalloc(firmware->size, GFP_KERNEL); | 234 | data->fw_data = kmalloc(firmware->size, GFP_KERNEL); |
236 | if (!data->fw_data) { | 235 | if (!data->fw_data) { |
237 | BT_ERR("Can't allocate memory for firmware image"); | 236 | BT_ERR("Can't allocate memory for firmware image"); |
237 | release_firmware(firmware); | ||
238 | usb_free_urb(data->urb); | 238 | usb_free_urb(data->urb); |
239 | kfree(data->buffer); | 239 | kfree(data->buffer); |
240 | kfree(data); | 240 | kfree(data); |
diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c index 8947c8837dac..efcc28ec9d9a 100644 --- a/drivers/bluetooth/bfusb.c +++ b/drivers/bluetooth/bfusb.c | |||
@@ -2,7 +2,7 @@ | |||
2 | * | 2 | * |
3 | * AVM BlueFRITZ! USB driver | 3 | * AVM BlueFRITZ! USB driver |
4 | * | 4 | * |
5 | * Copyright (C) 2003 Marcel Holtmann <marcel@holtmann.org> | 5 | * Copyright (C) 2003-2006 Marcel Holtmann <marcel@holtmann.org> |
6 | * | 6 | * |
7 | * | 7 | * |
8 | * This program is free software; you can redistribute it and/or modify | 8 | * This program is free software; you can redistribute it and/or modify |
@@ -21,7 +21,6 @@ | |||
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/module.h> | 24 | #include <linux/module.h> |
26 | 25 | ||
27 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
@@ -60,7 +59,6 @@ static struct usb_device_id bfusb_table[] = { | |||
60 | 59 | ||
61 | MODULE_DEVICE_TABLE(usb, bfusb_table); | 60 | MODULE_DEVICE_TABLE(usb, bfusb_table); |
62 | 61 | ||
63 | |||
64 | #define BFUSB_MAX_BLOCK_SIZE 256 | 62 | #define BFUSB_MAX_BLOCK_SIZE 256 |
65 | 63 | ||
66 | #define BFUSB_BLOCK_TIMEOUT 3000 | 64 | #define BFUSB_BLOCK_TIMEOUT 3000 |
@@ -71,7 +69,7 @@ MODULE_DEVICE_TABLE(usb, bfusb_table); | |||
71 | #define BFUSB_MAX_BULK_TX 2 | 69 | #define BFUSB_MAX_BULK_TX 2 |
72 | #define BFUSB_MAX_BULK_RX 2 | 70 | #define BFUSB_MAX_BULK_RX 2 |
73 | 71 | ||
74 | struct bfusb { | 72 | struct bfusb_data { |
75 | struct hci_dev *hdev; | 73 | struct hci_dev *hdev; |
76 | 74 | ||
77 | unsigned long state; | 75 | unsigned long state; |
@@ -93,137 +91,136 @@ struct bfusb { | |||
93 | struct sk_buff_head completed_q; | 91 | struct sk_buff_head completed_q; |
94 | }; | 92 | }; |
95 | 93 | ||
96 | struct bfusb_scb { | 94 | struct bfusb_data_scb { |
97 | struct urb *urb; | 95 | struct urb *urb; |
98 | }; | 96 | }; |
99 | 97 | ||
100 | static void bfusb_tx_complete(struct urb *urb, struct pt_regs *regs); | 98 | static void bfusb_tx_complete(struct urb *urb, struct pt_regs *regs); |
101 | static void bfusb_rx_complete(struct urb *urb, struct pt_regs *regs); | 99 | static void bfusb_rx_complete(struct urb *urb, struct pt_regs *regs); |
102 | 100 | ||
103 | static struct urb *bfusb_get_completed(struct bfusb *bfusb) | 101 | static struct urb *bfusb_get_completed(struct bfusb_data *data) |
104 | { | 102 | { |
105 | struct sk_buff *skb; | 103 | struct sk_buff *skb; |
106 | struct urb *urb = NULL; | 104 | struct urb *urb = NULL; |
107 | 105 | ||
108 | BT_DBG("bfusb %p", bfusb); | 106 | BT_DBG("bfusb %p", data); |
109 | 107 | ||
110 | skb = skb_dequeue(&bfusb->completed_q); | 108 | skb = skb_dequeue(&data->completed_q); |
111 | if (skb) { | 109 | if (skb) { |
112 | urb = ((struct bfusb_scb *) skb->cb)->urb; | 110 | urb = ((struct bfusb_data_scb *) skb->cb)->urb; |
113 | kfree_skb(skb); | 111 | kfree_skb(skb); |
114 | } | 112 | } |
115 | 113 | ||
116 | return urb; | 114 | return urb; |
117 | } | 115 | } |
118 | 116 | ||
119 | static void bfusb_unlink_urbs(struct bfusb *bfusb) | 117 | static void bfusb_unlink_urbs(struct bfusb_data *data) |
120 | { | 118 | { |
121 | struct sk_buff *skb; | 119 | struct sk_buff *skb; |
122 | struct urb *urb; | 120 | struct urb *urb; |
123 | 121 | ||
124 | BT_DBG("bfusb %p", bfusb); | 122 | BT_DBG("bfusb %p", data); |
125 | 123 | ||
126 | while ((skb = skb_dequeue(&bfusb->pending_q))) { | 124 | while ((skb = skb_dequeue(&data->pending_q))) { |
127 | urb = ((struct bfusb_scb *) skb->cb)->urb; | 125 | urb = ((struct bfusb_data_scb *) skb->cb)->urb; |
128 | usb_kill_urb(urb); | 126 | usb_kill_urb(urb); |
129 | skb_queue_tail(&bfusb->completed_q, skb); | 127 | skb_queue_tail(&data->completed_q, skb); |
130 | } | 128 | } |
131 | 129 | ||
132 | while ((urb = bfusb_get_completed(bfusb))) | 130 | while ((urb = bfusb_get_completed(data))) |
133 | usb_free_urb(urb); | 131 | usb_free_urb(urb); |
134 | } | 132 | } |
135 | 133 | ||
136 | 134 | static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb) | |
137 | static int bfusb_send_bulk(struct bfusb *bfusb, struct sk_buff *skb) | ||
138 | { | 135 | { |
139 | struct bfusb_scb *scb = (void *) skb->cb; | 136 | struct bfusb_data_scb *scb = (void *) skb->cb; |
140 | struct urb *urb = bfusb_get_completed(bfusb); | 137 | struct urb *urb = bfusb_get_completed(data); |
141 | int err, pipe; | 138 | int err, pipe; |
142 | 139 | ||
143 | BT_DBG("bfusb %p skb %p len %d", bfusb, skb, skb->len); | 140 | BT_DBG("bfusb %p skb %p len %d", data, skb, skb->len); |
144 | 141 | ||
145 | if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC))) | 142 | if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC))) |
146 | return -ENOMEM; | 143 | return -ENOMEM; |
147 | 144 | ||
148 | pipe = usb_sndbulkpipe(bfusb->udev, bfusb->bulk_out_ep); | 145 | pipe = usb_sndbulkpipe(data->udev, data->bulk_out_ep); |
149 | 146 | ||
150 | usb_fill_bulk_urb(urb, bfusb->udev, pipe, skb->data, skb->len, | 147 | usb_fill_bulk_urb(urb, data->udev, pipe, skb->data, skb->len, |
151 | bfusb_tx_complete, skb); | 148 | bfusb_tx_complete, skb); |
152 | 149 | ||
153 | scb->urb = urb; | 150 | scb->urb = urb; |
154 | 151 | ||
155 | skb_queue_tail(&bfusb->pending_q, skb); | 152 | skb_queue_tail(&data->pending_q, skb); |
156 | 153 | ||
157 | err = usb_submit_urb(urb, GFP_ATOMIC); | 154 | err = usb_submit_urb(urb, GFP_ATOMIC); |
158 | if (err) { | 155 | if (err) { |
159 | BT_ERR("%s bulk tx submit failed urb %p err %d", | 156 | BT_ERR("%s bulk tx submit failed urb %p err %d", |
160 | bfusb->hdev->name, urb, err); | 157 | data->hdev->name, urb, err); |
161 | skb_unlink(skb, &bfusb->pending_q); | 158 | skb_unlink(skb, &data->pending_q); |
162 | usb_free_urb(urb); | 159 | usb_free_urb(urb); |
163 | } else | 160 | } else |
164 | atomic_inc(&bfusb->pending_tx); | 161 | atomic_inc(&data->pending_tx); |
165 | 162 | ||
166 | return err; | 163 | return err; |
167 | } | 164 | } |
168 | 165 | ||
169 | static void bfusb_tx_wakeup(struct bfusb *bfusb) | 166 | static void bfusb_tx_wakeup(struct bfusb_data *data) |
170 | { | 167 | { |
171 | struct sk_buff *skb; | 168 | struct sk_buff *skb; |
172 | 169 | ||
173 | BT_DBG("bfusb %p", bfusb); | 170 | BT_DBG("bfusb %p", data); |
174 | 171 | ||
175 | if (test_and_set_bit(BFUSB_TX_PROCESS, &bfusb->state)) { | 172 | if (test_and_set_bit(BFUSB_TX_PROCESS, &data->state)) { |
176 | set_bit(BFUSB_TX_WAKEUP, &bfusb->state); | 173 | set_bit(BFUSB_TX_WAKEUP, &data->state); |
177 | return; | 174 | return; |
178 | } | 175 | } |
179 | 176 | ||
180 | do { | 177 | do { |
181 | clear_bit(BFUSB_TX_WAKEUP, &bfusb->state); | 178 | clear_bit(BFUSB_TX_WAKEUP, &data->state); |
182 | 179 | ||
183 | while ((atomic_read(&bfusb->pending_tx) < BFUSB_MAX_BULK_TX) && | 180 | while ((atomic_read(&data->pending_tx) < BFUSB_MAX_BULK_TX) && |
184 | (skb = skb_dequeue(&bfusb->transmit_q))) { | 181 | (skb = skb_dequeue(&data->transmit_q))) { |
185 | if (bfusb_send_bulk(bfusb, skb) < 0) { | 182 | if (bfusb_send_bulk(data, skb) < 0) { |
186 | skb_queue_head(&bfusb->transmit_q, skb); | 183 | skb_queue_head(&data->transmit_q, skb); |
187 | break; | 184 | break; |
188 | } | 185 | } |
189 | } | 186 | } |
190 | 187 | ||
191 | } while (test_bit(BFUSB_TX_WAKEUP, &bfusb->state)); | 188 | } while (test_bit(BFUSB_TX_WAKEUP, &data->state)); |
192 | 189 | ||
193 | clear_bit(BFUSB_TX_PROCESS, &bfusb->state); | 190 | clear_bit(BFUSB_TX_PROCESS, &data->state); |
194 | } | 191 | } |
195 | 192 | ||
196 | static void bfusb_tx_complete(struct urb *urb, struct pt_regs *regs) | 193 | static void bfusb_tx_complete(struct urb *urb, struct pt_regs *regs) |
197 | { | 194 | { |
198 | struct sk_buff *skb = (struct sk_buff *) urb->context; | 195 | struct sk_buff *skb = (struct sk_buff *) urb->context; |
199 | struct bfusb *bfusb = (struct bfusb *) skb->dev; | 196 | struct bfusb_data *data = (struct bfusb_data *) skb->dev; |
200 | 197 | ||
201 | BT_DBG("bfusb %p urb %p skb %p len %d", bfusb, urb, skb, skb->len); | 198 | BT_DBG("bfusb %p urb %p skb %p len %d", data, urb, skb, skb->len); |
202 | 199 | ||
203 | atomic_dec(&bfusb->pending_tx); | 200 | atomic_dec(&data->pending_tx); |
204 | 201 | ||
205 | if (!test_bit(HCI_RUNNING, &bfusb->hdev->flags)) | 202 | if (!test_bit(HCI_RUNNING, &data->hdev->flags)) |
206 | return; | 203 | return; |
207 | 204 | ||
208 | if (!urb->status) | 205 | if (!urb->status) |
209 | bfusb->hdev->stat.byte_tx += skb->len; | 206 | data->hdev->stat.byte_tx += skb->len; |
210 | else | 207 | else |
211 | bfusb->hdev->stat.err_tx++; | 208 | data->hdev->stat.err_tx++; |
212 | 209 | ||
213 | read_lock(&bfusb->lock); | 210 | read_lock(&data->lock); |
214 | 211 | ||
215 | skb_unlink(skb, &bfusb->pending_q); | 212 | skb_unlink(skb, &data->pending_q); |
216 | skb_queue_tail(&bfusb->completed_q, skb); | 213 | skb_queue_tail(&data->completed_q, skb); |
217 | 214 | ||
218 | bfusb_tx_wakeup(bfusb); | 215 | bfusb_tx_wakeup(data); |
219 | 216 | ||
220 | read_unlock(&bfusb->lock); | 217 | read_unlock(&data->lock); |
221 | } | 218 | } |
222 | 219 | ||
223 | 220 | ||
224 | static int bfusb_rx_submit(struct bfusb *bfusb, struct urb *urb) | 221 | static int bfusb_rx_submit(struct bfusb_data *data, struct urb *urb) |
225 | { | 222 | { |
226 | struct bfusb_scb *scb; | 223 | struct bfusb_data_scb *scb; |
227 | struct sk_buff *skb; | 224 | struct sk_buff *skb; |
228 | int err, pipe, size = HCI_MAX_FRAME_SIZE + 32; | 225 | int err, pipe, size = HCI_MAX_FRAME_SIZE + 32; |
229 | 226 | ||
@@ -232,28 +229,29 @@ static int bfusb_rx_submit(struct bfusb *bfusb, struct urb *urb) | |||
232 | if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC))) | 229 | if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC))) |
233 | return -ENOMEM; | 230 | return -ENOMEM; |
234 | 231 | ||
235 | if (!(skb = bt_skb_alloc(size, GFP_ATOMIC))) { | 232 | skb = bt_skb_alloc(size, GFP_ATOMIC); |
233 | if (!skb) { | ||
236 | usb_free_urb(urb); | 234 | usb_free_urb(urb); |
237 | return -ENOMEM; | 235 | return -ENOMEM; |
238 | } | 236 | } |
239 | 237 | ||
240 | skb->dev = (void *) bfusb; | 238 | skb->dev = (void *) data; |
241 | 239 | ||
242 | scb = (struct bfusb_scb *) skb->cb; | 240 | scb = (struct bfusb_data_scb *) skb->cb; |
243 | scb->urb = urb; | 241 | scb->urb = urb; |
244 | 242 | ||
245 | pipe = usb_rcvbulkpipe(bfusb->udev, bfusb->bulk_in_ep); | 243 | pipe = usb_rcvbulkpipe(data->udev, data->bulk_in_ep); |
246 | 244 | ||
247 | usb_fill_bulk_urb(urb, bfusb->udev, pipe, skb->data, size, | 245 | usb_fill_bulk_urb(urb, data->udev, pipe, skb->data, size, |
248 | bfusb_rx_complete, skb); | 246 | bfusb_rx_complete, skb); |
249 | 247 | ||
250 | skb_queue_tail(&bfusb->pending_q, skb); | 248 | skb_queue_tail(&data->pending_q, skb); |
251 | 249 | ||
252 | err = usb_submit_urb(urb, GFP_ATOMIC); | 250 | err = usb_submit_urb(urb, GFP_ATOMIC); |
253 | if (err) { | 251 | if (err) { |
254 | BT_ERR("%s bulk rx submit failed urb %p err %d", | 252 | BT_ERR("%s bulk rx submit failed urb %p err %d", |
255 | bfusb->hdev->name, urb, err); | 253 | data->hdev->name, urb, err); |
256 | skb_unlink(skb, &bfusb->pending_q); | 254 | skb_unlink(skb, &data->pending_q); |
257 | kfree_skb(skb); | 255 | kfree_skb(skb); |
258 | usb_free_urb(urb); | 256 | usb_free_urb(urb); |
259 | } | 257 | } |
@@ -261,15 +259,15 @@ static int bfusb_rx_submit(struct bfusb *bfusb, struct urb *urb) | |||
261 | return err; | 259 | return err; |
262 | } | 260 | } |
263 | 261 | ||
264 | static inline int bfusb_recv_block(struct bfusb *bfusb, int hdr, unsigned char *data, int len) | 262 | static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned char *buf, int len) |
265 | { | 263 | { |
266 | BT_DBG("bfusb %p hdr 0x%02x data %p len %d", bfusb, hdr, data, len); | 264 | BT_DBG("bfusb %p hdr 0x%02x data %p len %d", data, hdr, buf, len); |
267 | 265 | ||
268 | if (hdr & 0x10) { | 266 | if (hdr & 0x10) { |
269 | BT_ERR("%s error in block", bfusb->hdev->name); | 267 | BT_ERR("%s error in block", data->hdev->name); |
270 | if (bfusb->reassembly) | 268 | if (data->reassembly) |
271 | kfree_skb(bfusb->reassembly); | 269 | kfree_skb(data->reassembly); |
272 | bfusb->reassembly = NULL; | 270 | data->reassembly = NULL; |
273 | return -EIO; | 271 | return -EIO; |
274 | } | 272 | } |
275 | 273 | ||
@@ -278,46 +276,46 @@ static inline int bfusb_recv_block(struct bfusb *bfusb, int hdr, unsigned char * | |||
278 | unsigned char pkt_type; | 276 | unsigned char pkt_type; |
279 | int pkt_len = 0; | 277 | int pkt_len = 0; |
280 | 278 | ||
281 | if (bfusb->reassembly) { | 279 | if (data->reassembly) { |
282 | BT_ERR("%s unexpected start block", bfusb->hdev->name); | 280 | BT_ERR("%s unexpected start block", data->hdev->name); |
283 | kfree_skb(bfusb->reassembly); | 281 | kfree_skb(data->reassembly); |
284 | bfusb->reassembly = NULL; | 282 | data->reassembly = NULL; |
285 | } | 283 | } |
286 | 284 | ||
287 | if (len < 1) { | 285 | if (len < 1) { |
288 | BT_ERR("%s no packet type found", bfusb->hdev->name); | 286 | BT_ERR("%s no packet type found", data->hdev->name); |
289 | return -EPROTO; | 287 | return -EPROTO; |
290 | } | 288 | } |
291 | 289 | ||
292 | pkt_type = *data++; len--; | 290 | pkt_type = *buf++; len--; |
293 | 291 | ||
294 | switch (pkt_type) { | 292 | switch (pkt_type) { |
295 | case HCI_EVENT_PKT: | 293 | case HCI_EVENT_PKT: |
296 | if (len >= HCI_EVENT_HDR_SIZE) { | 294 | if (len >= HCI_EVENT_HDR_SIZE) { |
297 | struct hci_event_hdr *hdr = (struct hci_event_hdr *) data; | 295 | struct hci_event_hdr *hdr = (struct hci_event_hdr *) buf; |
298 | pkt_len = HCI_EVENT_HDR_SIZE + hdr->plen; | 296 | pkt_len = HCI_EVENT_HDR_SIZE + hdr->plen; |
299 | } else { | 297 | } else { |
300 | BT_ERR("%s event block is too short", bfusb->hdev->name); | 298 | BT_ERR("%s event block is too short", data->hdev->name); |
301 | return -EILSEQ; | 299 | return -EILSEQ; |
302 | } | 300 | } |
303 | break; | 301 | break; |
304 | 302 | ||
305 | case HCI_ACLDATA_PKT: | 303 | case HCI_ACLDATA_PKT: |
306 | if (len >= HCI_ACL_HDR_SIZE) { | 304 | if (len >= HCI_ACL_HDR_SIZE) { |
307 | struct hci_acl_hdr *hdr = (struct hci_acl_hdr *) data; | 305 | struct hci_acl_hdr *hdr = (struct hci_acl_hdr *) buf; |
308 | pkt_len = HCI_ACL_HDR_SIZE + __le16_to_cpu(hdr->dlen); | 306 | pkt_len = HCI_ACL_HDR_SIZE + __le16_to_cpu(hdr->dlen); |
309 | } else { | 307 | } else { |
310 | BT_ERR("%s data block is too short", bfusb->hdev->name); | 308 | BT_ERR("%s data block is too short", data->hdev->name); |
311 | return -EILSEQ; | 309 | return -EILSEQ; |
312 | } | 310 | } |
313 | break; | 311 | break; |
314 | 312 | ||
315 | case HCI_SCODATA_PKT: | 313 | case HCI_SCODATA_PKT: |
316 | if (len >= HCI_SCO_HDR_SIZE) { | 314 | if (len >= HCI_SCO_HDR_SIZE) { |
317 | struct hci_sco_hdr *hdr = (struct hci_sco_hdr *) data; | 315 | struct hci_sco_hdr *hdr = (struct hci_sco_hdr *) buf; |
318 | pkt_len = HCI_SCO_HDR_SIZE + hdr->dlen; | 316 | pkt_len = HCI_SCO_HDR_SIZE + hdr->dlen; |
319 | } else { | 317 | } else { |
320 | BT_ERR("%s audio block is too short", bfusb->hdev->name); | 318 | BT_ERR("%s audio block is too short", data->hdev->name); |
321 | return -EILSEQ; | 319 | return -EILSEQ; |
322 | } | 320 | } |
323 | break; | 321 | break; |
@@ -325,27 +323,27 @@ static inline int bfusb_recv_block(struct bfusb *bfusb, int hdr, unsigned char * | |||
325 | 323 | ||
326 | skb = bt_skb_alloc(pkt_len, GFP_ATOMIC); | 324 | skb = bt_skb_alloc(pkt_len, GFP_ATOMIC); |
327 | if (!skb) { | 325 | if (!skb) { |
328 | BT_ERR("%s no memory for the packet", bfusb->hdev->name); | 326 | BT_ERR("%s no memory for the packet", data->hdev->name); |
329 | return -ENOMEM; | 327 | return -ENOMEM; |
330 | } | 328 | } |
331 | 329 | ||
332 | skb->dev = (void *) bfusb->hdev; | 330 | skb->dev = (void *) data->hdev; |
333 | bt_cb(skb)->pkt_type = pkt_type; | 331 | bt_cb(skb)->pkt_type = pkt_type; |
334 | 332 | ||
335 | bfusb->reassembly = skb; | 333 | data->reassembly = skb; |
336 | } else { | 334 | } else { |
337 | if (!bfusb->reassembly) { | 335 | if (!data->reassembly) { |
338 | BT_ERR("%s unexpected continuation block", bfusb->hdev->name); | 336 | BT_ERR("%s unexpected continuation block", data->hdev->name); |
339 | return -EIO; | 337 | return -EIO; |
340 | } | 338 | } |
341 | } | 339 | } |
342 | 340 | ||
343 | if (len > 0) | 341 | if (len > 0) |
344 | memcpy(skb_put(bfusb->reassembly, len), data, len); | 342 | memcpy(skb_put(data->reassembly, len), buf, len); |
345 | 343 | ||
346 | if (hdr & 0x08) { | 344 | if (hdr & 0x08) { |
347 | hci_recv_frame(bfusb->reassembly); | 345 | hci_recv_frame(data->reassembly); |
348 | bfusb->reassembly = NULL; | 346 | data->reassembly = NULL; |
349 | } | 347 | } |
350 | 348 | ||
351 | return 0; | 349 | return 0; |
@@ -354,22 +352,22 @@ static inline int bfusb_recv_block(struct bfusb *bfusb, int hdr, unsigned char * | |||
354 | static void bfusb_rx_complete(struct urb *urb, struct pt_regs *regs) | 352 | static void bfusb_rx_complete(struct urb *urb, struct pt_regs *regs) |
355 | { | 353 | { |
356 | struct sk_buff *skb = (struct sk_buff *) urb->context; | 354 | struct sk_buff *skb = (struct sk_buff *) urb->context; |
357 | struct bfusb *bfusb = (struct bfusb *) skb->dev; | 355 | struct bfusb_data *data = (struct bfusb_data *) skb->dev; |
358 | unsigned char *buf = urb->transfer_buffer; | 356 | unsigned char *buf = urb->transfer_buffer; |
359 | int count = urb->actual_length; | 357 | int count = urb->actual_length; |
360 | int err, hdr, len; | 358 | int err, hdr, len; |
361 | 359 | ||
362 | BT_DBG("bfusb %p urb %p skb %p len %d", bfusb, urb, skb, skb->len); | 360 | BT_DBG("bfusb %p urb %p skb %p len %d", bfusb, urb, skb, skb->len); |
363 | 361 | ||
364 | read_lock(&bfusb->lock); | 362 | read_lock(&data->lock); |
365 | 363 | ||
366 | if (!test_bit(HCI_RUNNING, &bfusb->hdev->flags)) | 364 | if (!test_bit(HCI_RUNNING, &data->hdev->flags)) |
367 | goto unlock; | 365 | goto unlock; |
368 | 366 | ||
369 | if (urb->status || !count) | 367 | if (urb->status || !count) |
370 | goto resubmit; | 368 | goto resubmit; |
371 | 369 | ||
372 | bfusb->hdev->stat.byte_rx += count; | 370 | data->hdev->stat.byte_rx += count; |
373 | 371 | ||
374 | skb_put(skb, count); | 372 | skb_put(skb, count); |
375 | 373 | ||
@@ -388,90 +386,89 @@ static void bfusb_rx_complete(struct urb *urb, struct pt_regs *regs) | |||
388 | 386 | ||
389 | if (count < len) { | 387 | if (count < len) { |
390 | BT_ERR("%s block extends over URB buffer ranges", | 388 | BT_ERR("%s block extends over URB buffer ranges", |
391 | bfusb->hdev->name); | 389 | data->hdev->name); |
392 | } | 390 | } |
393 | 391 | ||
394 | if ((hdr & 0xe1) == 0xc1) | 392 | if ((hdr & 0xe1) == 0xc1) |
395 | bfusb_recv_block(bfusb, hdr, buf, len); | 393 | bfusb_recv_block(data, hdr, buf, len); |
396 | 394 | ||
397 | count -= len; | 395 | count -= len; |
398 | buf += len; | 396 | buf += len; |
399 | } | 397 | } |
400 | 398 | ||
401 | skb_unlink(skb, &bfusb->pending_q); | 399 | skb_unlink(skb, &data->pending_q); |
402 | kfree_skb(skb); | 400 | kfree_skb(skb); |
403 | 401 | ||
404 | bfusb_rx_submit(bfusb, urb); | 402 | bfusb_rx_submit(data, urb); |
405 | 403 | ||
406 | read_unlock(&bfusb->lock); | 404 | read_unlock(&data->lock); |
407 | 405 | ||
408 | return; | 406 | return; |
409 | 407 | ||
410 | resubmit: | 408 | resubmit: |
411 | urb->dev = bfusb->udev; | 409 | urb->dev = data->udev; |
412 | 410 | ||
413 | err = usb_submit_urb(urb, GFP_ATOMIC); | 411 | err = usb_submit_urb(urb, GFP_ATOMIC); |
414 | if (err) { | 412 | if (err) { |
415 | BT_ERR("%s bulk resubmit failed urb %p err %d", | 413 | BT_ERR("%s bulk resubmit failed urb %p err %d", |
416 | bfusb->hdev->name, urb, err); | 414 | data->hdev->name, urb, err); |
417 | } | 415 | } |
418 | 416 | ||
419 | unlock: | 417 | unlock: |
420 | read_unlock(&bfusb->lock); | 418 | read_unlock(&data->lock); |
421 | } | 419 | } |
422 | 420 | ||
423 | |||
424 | static int bfusb_open(struct hci_dev *hdev) | 421 | static int bfusb_open(struct hci_dev *hdev) |
425 | { | 422 | { |
426 | struct bfusb *bfusb = (struct bfusb *) hdev->driver_data; | 423 | struct bfusb_data *data = hdev->driver_data; |
427 | unsigned long flags; | 424 | unsigned long flags; |
428 | int i, err; | 425 | int i, err; |
429 | 426 | ||
430 | BT_DBG("hdev %p bfusb %p", hdev, bfusb); | 427 | BT_DBG("hdev %p bfusb %p", hdev, data); |
431 | 428 | ||
432 | if (test_and_set_bit(HCI_RUNNING, &hdev->flags)) | 429 | if (test_and_set_bit(HCI_RUNNING, &hdev->flags)) |
433 | return 0; | 430 | return 0; |
434 | 431 | ||
435 | write_lock_irqsave(&bfusb->lock, flags); | 432 | write_lock_irqsave(&data->lock, flags); |
436 | 433 | ||
437 | err = bfusb_rx_submit(bfusb, NULL); | 434 | err = bfusb_rx_submit(data, NULL); |
438 | if (!err) { | 435 | if (!err) { |
439 | for (i = 1; i < BFUSB_MAX_BULK_RX; i++) | 436 | for (i = 1; i < BFUSB_MAX_BULK_RX; i++) |
440 | bfusb_rx_submit(bfusb, NULL); | 437 | bfusb_rx_submit(data, NULL); |
441 | } else { | 438 | } else { |
442 | clear_bit(HCI_RUNNING, &hdev->flags); | 439 | clear_bit(HCI_RUNNING, &hdev->flags); |
443 | } | 440 | } |
444 | 441 | ||
445 | write_unlock_irqrestore(&bfusb->lock, flags); | 442 | write_unlock_irqrestore(&data->lock, flags); |
446 | 443 | ||
447 | return err; | 444 | return err; |
448 | } | 445 | } |
449 | 446 | ||
450 | static int bfusb_flush(struct hci_dev *hdev) | 447 | static int bfusb_flush(struct hci_dev *hdev) |
451 | { | 448 | { |
452 | struct bfusb *bfusb = (struct bfusb *) hdev->driver_data; | 449 | struct bfusb_data *data = hdev->driver_data; |
453 | 450 | ||
454 | BT_DBG("hdev %p bfusb %p", hdev, bfusb); | 451 | BT_DBG("hdev %p bfusb %p", hdev, data); |
455 | 452 | ||
456 | skb_queue_purge(&bfusb->transmit_q); | 453 | skb_queue_purge(&data->transmit_q); |
457 | 454 | ||
458 | return 0; | 455 | return 0; |
459 | } | 456 | } |
460 | 457 | ||
461 | static int bfusb_close(struct hci_dev *hdev) | 458 | static int bfusb_close(struct hci_dev *hdev) |
462 | { | 459 | { |
463 | struct bfusb *bfusb = (struct bfusb *) hdev->driver_data; | 460 | struct bfusb_data *data = hdev->driver_data; |
464 | unsigned long flags; | 461 | unsigned long flags; |
465 | 462 | ||
466 | BT_DBG("hdev %p bfusb %p", hdev, bfusb); | 463 | BT_DBG("hdev %p bfusb %p", hdev, data); |
467 | 464 | ||
468 | if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) | 465 | if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) |
469 | return 0; | 466 | return 0; |
470 | 467 | ||
471 | write_lock_irqsave(&bfusb->lock, flags); | 468 | write_lock_irqsave(&data->lock, flags); |
472 | write_unlock_irqrestore(&bfusb->lock, flags); | 469 | write_unlock_irqrestore(&data->lock, flags); |
473 | 470 | ||
474 | bfusb_unlink_urbs(bfusb); | 471 | bfusb_unlink_urbs(data); |
475 | bfusb_flush(hdev); | 472 | bfusb_flush(hdev); |
476 | 473 | ||
477 | return 0; | 474 | return 0; |
@@ -480,7 +477,7 @@ static int bfusb_close(struct hci_dev *hdev) | |||
480 | static int bfusb_send_frame(struct sk_buff *skb) | 477 | static int bfusb_send_frame(struct sk_buff *skb) |
481 | { | 478 | { |
482 | struct hci_dev *hdev = (struct hci_dev *) skb->dev; | 479 | struct hci_dev *hdev = (struct hci_dev *) skb->dev; |
483 | struct bfusb *bfusb; | 480 | struct bfusb_data *data; |
484 | struct sk_buff *nskb; | 481 | struct sk_buff *nskb; |
485 | unsigned char buf[3]; | 482 | unsigned char buf[3]; |
486 | int sent = 0, size, count; | 483 | int sent = 0, size, count; |
@@ -495,7 +492,7 @@ static int bfusb_send_frame(struct sk_buff *skb) | |||
495 | if (!test_bit(HCI_RUNNING, &hdev->flags)) | 492 | if (!test_bit(HCI_RUNNING, &hdev->flags)) |
496 | return -EBUSY; | 493 | return -EBUSY; |
497 | 494 | ||
498 | bfusb = (struct bfusb *) hdev->driver_data; | 495 | data = hdev->driver_data; |
499 | 496 | ||
500 | switch (bt_cb(skb)->pkt_type) { | 497 | switch (bt_cb(skb)->pkt_type) { |
501 | case HCI_COMMAND_PKT: | 498 | case HCI_COMMAND_PKT: |
@@ -515,12 +512,13 @@ static int bfusb_send_frame(struct sk_buff *skb) | |||
515 | count = skb->len; | 512 | count = skb->len; |
516 | 513 | ||
517 | /* Max HCI frame size seems to be 1511 + 1 */ | 514 | /* Max HCI frame size seems to be 1511 + 1 */ |
518 | if (!(nskb = bt_skb_alloc(count + 32, GFP_ATOMIC))) { | 515 | nskb = bt_skb_alloc(count + 32, GFP_ATOMIC); |
516 | if (!nskb) { | ||
519 | BT_ERR("Can't allocate memory for new packet"); | 517 | BT_ERR("Can't allocate memory for new packet"); |
520 | return -ENOMEM; | 518 | return -ENOMEM; |
521 | } | 519 | } |
522 | 520 | ||
523 | nskb->dev = (void *) bfusb; | 521 | nskb->dev = (void *) data; |
524 | 522 | ||
525 | while (count) { | 523 | while (count) { |
526 | size = min_t(uint, count, BFUSB_MAX_BLOCK_SIZE); | 524 | size = min_t(uint, count, BFUSB_MAX_BLOCK_SIZE); |
@@ -537,18 +535,18 @@ static int bfusb_send_frame(struct sk_buff *skb) | |||
537 | } | 535 | } |
538 | 536 | ||
539 | /* Don't send frame with multiple size of bulk max packet */ | 537 | /* Don't send frame with multiple size of bulk max packet */ |
540 | if ((nskb->len % bfusb->bulk_pkt_size) == 0) { | 538 | if ((nskb->len % data->bulk_pkt_size) == 0) { |
541 | buf[0] = 0xdd; | 539 | buf[0] = 0xdd; |
542 | buf[1] = 0x00; | 540 | buf[1] = 0x00; |
543 | memcpy(skb_put(nskb, 2), buf, 2); | 541 | memcpy(skb_put(nskb, 2), buf, 2); |
544 | } | 542 | } |
545 | 543 | ||
546 | read_lock(&bfusb->lock); | 544 | read_lock(&data->lock); |
547 | 545 | ||
548 | skb_queue_tail(&bfusb->transmit_q, nskb); | 546 | skb_queue_tail(&data->transmit_q, nskb); |
549 | bfusb_tx_wakeup(bfusb); | 547 | bfusb_tx_wakeup(data); |
550 | 548 | ||
551 | read_unlock(&bfusb->lock); | 549 | read_unlock(&data->lock); |
552 | 550 | ||
553 | kfree_skb(skb); | 551 | kfree_skb(skb); |
554 | 552 | ||
@@ -557,11 +555,11 @@ static int bfusb_send_frame(struct sk_buff *skb) | |||
557 | 555 | ||
558 | static void bfusb_destruct(struct hci_dev *hdev) | 556 | static void bfusb_destruct(struct hci_dev *hdev) |
559 | { | 557 | { |
560 | struct bfusb *bfusb = (struct bfusb *) hdev->driver_data; | 558 | struct bfusb_data *data = hdev->driver_data; |
561 | 559 | ||
562 | BT_DBG("hdev %p bfusb %p", hdev, bfusb); | 560 | BT_DBG("hdev %p bfusb %p", hdev, data); |
563 | 561 | ||
564 | kfree(bfusb); | 562 | kfree(data); |
565 | } | 563 | } |
566 | 564 | ||
567 | static int bfusb_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg) | 565 | static int bfusb_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg) |
@@ -569,25 +567,24 @@ static int bfusb_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg | |||
569 | return -ENOIOCTLCMD; | 567 | return -ENOIOCTLCMD; |
570 | } | 568 | } |
571 | 569 | ||
572 | 570 | static int bfusb_load_firmware(struct bfusb_data *data, unsigned char *firmware, int count) | |
573 | static int bfusb_load_firmware(struct bfusb *bfusb, unsigned char *firmware, int count) | ||
574 | { | 571 | { |
575 | unsigned char *buf; | 572 | unsigned char *buf; |
576 | int err, pipe, len, size, sent = 0; | 573 | int err, pipe, len, size, sent = 0; |
577 | 574 | ||
578 | BT_DBG("bfusb %p udev %p", bfusb, bfusb->udev); | 575 | BT_DBG("bfusb %p udev %p", data, data->udev); |
579 | 576 | ||
580 | BT_INFO("BlueFRITZ! USB loading firmware"); | 577 | BT_INFO("BlueFRITZ! USB loading firmware"); |
581 | 578 | ||
582 | pipe = usb_sndctrlpipe(bfusb->udev, 0); | 579 | pipe = usb_sndctrlpipe(data->udev, 0); |
583 | 580 | ||
584 | if (usb_control_msg(bfusb->udev, pipe, USB_REQ_SET_CONFIGURATION, | 581 | if (usb_control_msg(data->udev, pipe, USB_REQ_SET_CONFIGURATION, |
585 | 0, 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT) < 0) { | 582 | 0, 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT) < 0) { |
586 | BT_ERR("Can't change to loading configuration"); | 583 | BT_ERR("Can't change to loading configuration"); |
587 | return -EBUSY; | 584 | return -EBUSY; |
588 | } | 585 | } |
589 | 586 | ||
590 | bfusb->udev->toggle[0] = bfusb->udev->toggle[1] = 0; | 587 | data->udev->toggle[0] = data->udev->toggle[1] = 0; |
591 | 588 | ||
592 | buf = kmalloc(BFUSB_MAX_BLOCK_SIZE + 3, GFP_ATOMIC); | 589 | buf = kmalloc(BFUSB_MAX_BLOCK_SIZE + 3, GFP_ATOMIC); |
593 | if (!buf) { | 590 | if (!buf) { |
@@ -595,14 +592,14 @@ static int bfusb_load_firmware(struct bfusb *bfusb, unsigned char *firmware, int | |||
595 | return -ENOMEM; | 592 | return -ENOMEM; |
596 | } | 593 | } |
597 | 594 | ||
598 | pipe = usb_sndbulkpipe(bfusb->udev, bfusb->bulk_out_ep); | 595 | pipe = usb_sndbulkpipe(data->udev, data->bulk_out_ep); |
599 | 596 | ||
600 | while (count) { | 597 | while (count) { |
601 | size = min_t(uint, count, BFUSB_MAX_BLOCK_SIZE + 3); | 598 | size = min_t(uint, count, BFUSB_MAX_BLOCK_SIZE + 3); |
602 | 599 | ||
603 | memcpy(buf, firmware + sent, size); | 600 | memcpy(buf, firmware + sent, size); |
604 | 601 | ||
605 | err = usb_bulk_msg(bfusb->udev, pipe, buf, size, | 602 | err = usb_bulk_msg(data->udev, pipe, buf, size, |
606 | &len, BFUSB_BLOCK_TIMEOUT); | 603 | &len, BFUSB_BLOCK_TIMEOUT); |
607 | 604 | ||
608 | if (err || (len != size)) { | 605 | if (err || (len != size)) { |
@@ -614,21 +611,23 @@ static int bfusb_load_firmware(struct bfusb *bfusb, unsigned char *firmware, int | |||
614 | count -= size; | 611 | count -= size; |
615 | } | 612 | } |
616 | 613 | ||
617 | if ((err = usb_bulk_msg(bfusb->udev, pipe, NULL, 0, | 614 | err = usb_bulk_msg(data->udev, pipe, NULL, 0, |
618 | &len, BFUSB_BLOCK_TIMEOUT)) < 0) { | 615 | &len, BFUSB_BLOCK_TIMEOUT); |
616 | if (err < 0) { | ||
619 | BT_ERR("Error in null packet request"); | 617 | BT_ERR("Error in null packet request"); |
620 | goto error; | 618 | goto error; |
621 | } | 619 | } |
622 | 620 | ||
623 | pipe = usb_sndctrlpipe(bfusb->udev, 0); | 621 | pipe = usb_sndctrlpipe(data->udev, 0); |
624 | 622 | ||
625 | if ((err = usb_control_msg(bfusb->udev, pipe, USB_REQ_SET_CONFIGURATION, | 623 | err = usb_control_msg(data->udev, pipe, USB_REQ_SET_CONFIGURATION, |
626 | 0, 2, 0, NULL, 0, USB_CTRL_SET_TIMEOUT)) < 0) { | 624 | 0, 2, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); |
625 | if (err < 0) { | ||
627 | BT_ERR("Can't change to running configuration"); | 626 | BT_ERR("Can't change to running configuration"); |
628 | goto error; | 627 | goto error; |
629 | } | 628 | } |
630 | 629 | ||
631 | bfusb->udev->toggle[0] = bfusb->udev->toggle[1] = 0; | 630 | data->udev->toggle[0] = data->udev->toggle[1] = 0; |
632 | 631 | ||
633 | BT_INFO("BlueFRITZ! USB device ready"); | 632 | BT_INFO("BlueFRITZ! USB device ready"); |
634 | 633 | ||
@@ -638,9 +637,9 @@ static int bfusb_load_firmware(struct bfusb *bfusb, unsigned char *firmware, int | |||
638 | error: | 637 | error: |
639 | kfree(buf); | 638 | kfree(buf); |
640 | 639 | ||
641 | pipe = usb_sndctrlpipe(bfusb->udev, 0); | 640 | pipe = usb_sndctrlpipe(data->udev, 0); |
642 | 641 | ||
643 | usb_control_msg(bfusb->udev, pipe, USB_REQ_SET_CONFIGURATION, | 642 | usb_control_msg(data->udev, pipe, USB_REQ_SET_CONFIGURATION, |
644 | 0, 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); | 643 | 0, 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT); |
645 | 644 | ||
646 | return err; | 645 | return err; |
@@ -653,7 +652,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
653 | struct usb_host_endpoint *bulk_out_ep; | 652 | struct usb_host_endpoint *bulk_out_ep; |
654 | struct usb_host_endpoint *bulk_in_ep; | 653 | struct usb_host_endpoint *bulk_in_ep; |
655 | struct hci_dev *hdev; | 654 | struct hci_dev *hdev; |
656 | struct bfusb *bfusb; | 655 | struct bfusb_data *data; |
657 | 656 | ||
658 | BT_DBG("intf %p id %p", intf, id); | 657 | BT_DBG("intf %p id %p", intf, id); |
659 | 658 | ||
@@ -673,23 +672,24 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
673 | } | 672 | } |
674 | 673 | ||
675 | /* Initialize control structure and load firmware */ | 674 | /* Initialize control structure and load firmware */ |
676 | if (!(bfusb = kzalloc(sizeof(struct bfusb), GFP_KERNEL))) { | 675 | data = kzalloc(sizeof(struct bfusb_data), GFP_KERNEL); |
676 | if (!data) { | ||
677 | BT_ERR("Can't allocate memory for control structure"); | 677 | BT_ERR("Can't allocate memory for control structure"); |
678 | goto done; | 678 | goto done; |
679 | } | 679 | } |
680 | 680 | ||
681 | bfusb->udev = udev; | 681 | data->udev = udev; |
682 | bfusb->bulk_in_ep = bulk_in_ep->desc.bEndpointAddress; | 682 | data->bulk_in_ep = bulk_in_ep->desc.bEndpointAddress; |
683 | bfusb->bulk_out_ep = bulk_out_ep->desc.bEndpointAddress; | 683 | data->bulk_out_ep = bulk_out_ep->desc.bEndpointAddress; |
684 | bfusb->bulk_pkt_size = le16_to_cpu(bulk_out_ep->desc.wMaxPacketSize); | 684 | data->bulk_pkt_size = le16_to_cpu(bulk_out_ep->desc.wMaxPacketSize); |
685 | 685 | ||
686 | rwlock_init(&bfusb->lock); | 686 | rwlock_init(&data->lock); |
687 | 687 | ||
688 | bfusb->reassembly = NULL; | 688 | data->reassembly = NULL; |
689 | 689 | ||
690 | skb_queue_head_init(&bfusb->transmit_q); | 690 | skb_queue_head_init(&data->transmit_q); |
691 | skb_queue_head_init(&bfusb->pending_q); | 691 | skb_queue_head_init(&data->pending_q); |
692 | skb_queue_head_init(&bfusb->completed_q); | 692 | skb_queue_head_init(&data->completed_q); |
693 | 693 | ||
694 | if (request_firmware(&firmware, "bfubase.frm", &udev->dev) < 0) { | 694 | if (request_firmware(&firmware, "bfubase.frm", &udev->dev) < 0) { |
695 | BT_ERR("Firmware request failed"); | 695 | BT_ERR("Firmware request failed"); |
@@ -698,7 +698,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
698 | 698 | ||
699 | BT_DBG("firmware data %p size %d", firmware->data, firmware->size); | 699 | BT_DBG("firmware data %p size %d", firmware->data, firmware->size); |
700 | 700 | ||
701 | if (bfusb_load_firmware(bfusb, firmware->data, firmware->size) < 0) { | 701 | if (bfusb_load_firmware(data, firmware->data, firmware->size) < 0) { |
702 | BT_ERR("Firmware loading failed"); | 702 | BT_ERR("Firmware loading failed"); |
703 | goto release; | 703 | goto release; |
704 | } | 704 | } |
@@ -712,10 +712,10 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
712 | goto error; | 712 | goto error; |
713 | } | 713 | } |
714 | 714 | ||
715 | bfusb->hdev = hdev; | 715 | data->hdev = hdev; |
716 | 716 | ||
717 | hdev->type = HCI_USB; | 717 | hdev->type = HCI_USB; |
718 | hdev->driver_data = bfusb; | 718 | hdev->driver_data = data; |
719 | SET_HCIDEV_DEV(hdev, &intf->dev); | 719 | SET_HCIDEV_DEV(hdev, &intf->dev); |
720 | 720 | ||
721 | hdev->open = bfusb_open; | 721 | hdev->open = bfusb_open; |
@@ -733,7 +733,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i | |||
733 | goto error; | 733 | goto error; |
734 | } | 734 | } |
735 | 735 | ||
736 | usb_set_intfdata(intf, bfusb); | 736 | usb_set_intfdata(intf, data); |
737 | 737 | ||
738 | return 0; | 738 | return 0; |
739 | 739 | ||
@@ -741,7 +741,7 @@ release: | |||
741 | release_firmware(firmware); | 741 | release_firmware(firmware); |
742 | 742 | ||
743 | error: | 743 | error: |
744 | kfree(bfusb); | 744 | kfree(data); |
745 | 745 | ||
746 | done: | 746 | done: |
747 | return -EIO; | 747 | return -EIO; |
@@ -749,8 +749,8 @@ done: | |||
749 | 749 | ||
750 | static void bfusb_disconnect(struct usb_interface *intf) | 750 | static void bfusb_disconnect(struct usb_interface *intf) |
751 | { | 751 | { |
752 | struct bfusb *bfusb = usb_get_intfdata(intf); | 752 | struct bfusb_data *data = usb_get_intfdata(intf); |
753 | struct hci_dev *hdev = bfusb->hdev; | 753 | struct hci_dev *hdev = data->hdev; |
754 | 754 | ||
755 | BT_DBG("intf %p", intf); | 755 | BT_DBG("intf %p", intf); |
756 | 756 | ||
@@ -780,7 +780,8 @@ static int __init bfusb_init(void) | |||
780 | 780 | ||
781 | BT_INFO("BlueFRITZ! USB driver ver %s", VERSION); | 781 | BT_INFO("BlueFRITZ! USB driver ver %s", VERSION); |
782 | 782 | ||
783 | if ((err = usb_register(&bfusb_driver)) < 0) | 783 | err = usb_register(&bfusb_driver); |
784 | if (err < 0) | ||
784 | BT_ERR("Failed to register BlueFRITZ! USB driver"); | 785 | BT_ERR("Failed to register BlueFRITZ! USB driver"); |
785 | 786 | ||
786 | return err; | 787 | return err; |
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index 473a13b22b29..8eebf9ca3786 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c | |||
@@ -20,7 +20,6 @@ | |||
20 | * | 20 | * |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/config.h> | ||
24 | #include <linux/module.h> | 23 | #include <linux/module.h> |
25 | 24 | ||
26 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
@@ -740,6 +739,7 @@ static int bluecard_open(bluecard_info_t *info) | |||
740 | 739 | ||
741 | hdev->type = HCI_PCCARD; | 740 | hdev->type = HCI_PCCARD; |
742 | hdev->driver_data = info; | 741 | hdev->driver_data = info; |
742 | SET_HCIDEV_DEV(hdev, &info->p_dev->dev); | ||
743 | 743 | ||
744 | hdev->open = bluecard_hci_open; | 744 | hdev->open = bluecard_hci_open; |
745 | hdev->close = bluecard_hci_close; | 745 | hdev->close = bluecard_hci_close; |
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c index 9446960ac742..e0231dc2cb1a 100644 --- a/drivers/bluetooth/bpa10x.c +++ b/drivers/bluetooth/bpa10x.c | |||
@@ -21,7 +21,6 @@ | |||
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/module.h> | 24 | #include <linux/module.h> |
26 | 25 | ||
27 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c index b94ac2f9f7ba..df7bb016df49 100644 --- a/drivers/bluetooth/bt3c_cs.c +++ b/drivers/bluetooth/bt3c_cs.c | |||
@@ -21,7 +21,6 @@ | |||
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/config.h> | ||
25 | #include <linux/module.h> | 24 | #include <linux/module.h> |
26 | 25 | ||
27 | #include <linux/kernel.h> | 26 | #include <linux/kernel.h> |
@@ -583,6 +582,7 @@ static int bt3c_open(bt3c_info_t *info) | |||
583 | 582 | ||
584 | hdev->type = HCI_PCCARD; | 583 | hdev->type = HCI_PCCARD; |
585 | hdev->driver_data = info; | 584 | hdev->driver_data = info; |
585 | SET_HCIDEV_DEV(hdev, &info->p_dev->dev); | ||
586 | 586 | ||
587 | hdev->open = bt3c_hci_open; | 587 | hdev->open = bt3c_hci_open; |
588 | hdev->close = bt3c_hci_close; | 588 | hdev->close = bt3c_hci_close; |
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index 9ce4c93467e5..746ccca97f6f 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c | |||
@@ -20,7 +20,6 @@ | |||
20 | * | 20 | * |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/config.h> | ||
24 | #include <linux/module.h> | 23 | #include <linux/module.h> |
25 | 24 | ||
26 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
@@ -503,6 +502,7 @@ static int btuart_open(btuart_info_t *info) | |||
503 | 502 | ||
504 | hdev->type = HCI_PCCARD; | 503 | hdev->type = HCI_PCCARD; |
505 | hdev->driver_data = info; | 504 | hdev->driver_data = info; |
505 | SET_HCIDEV_DEV(hdev, &info->p_dev->dev); | ||
506 | 506 | ||
507 | hdev->open = btuart_hci_open; | 507 | hdev->open = btuart_hci_open; |
508 | hdev->close = btuart_hci_close; | 508 | hdev->close = btuart_hci_close; |
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c index a71a240611e0..0e99def8a1e3 100644 --- a/drivers/bluetooth/dtl1_cs.c +++ b/drivers/bluetooth/dtl1_cs.c | |||
@@ -20,7 +20,6 @@ | |||
20 | * | 20 | * |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/config.h> | ||
24 | #include <linux/module.h> | 23 | #include <linux/module.h> |
25 | 24 | ||
26 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
@@ -423,6 +422,9 @@ static int dtl1_hci_send_frame(struct sk_buff *skb) | |||
423 | nsh.len = skb->len; | 422 | nsh.len = skb->len; |
424 | 423 | ||
425 | s = bt_skb_alloc(NSHL + skb->len + 1, GFP_ATOMIC); | 424 | s = bt_skb_alloc(NSHL + skb->len + 1, GFP_ATOMIC); |
425 | if (!s) | ||
426 | return -ENOMEM; | ||
427 | |||
426 | skb_reserve(s, NSHL); | 428 | skb_reserve(s, NSHL); |
427 | memcpy(skb_put(s, skb->len), skb->data, skb->len); | 429 | memcpy(skb_put(s, skb->len), skb->data, skb->len); |
428 | if (skb->len & 0x0001) | 430 | if (skb->len & 0x0001) |
@@ -482,6 +484,7 @@ static int dtl1_open(dtl1_info_t *info) | |||
482 | 484 | ||
483 | hdev->type = HCI_PCCARD; | 485 | hdev->type = HCI_PCCARD; |
484 | hdev->driver_data = info; | 486 | hdev->driver_data = info; |
487 | SET_HCIDEV_DEV(hdev, &info->p_dev->dev); | ||
485 | 488 | ||
486 | hdev->open = dtl1_hci_open; | 489 | hdev->open = dtl1_hci_open; |
487 | hdev->close = dtl1_hci_close; | 490 | hdev->close = dtl1_hci_close; |
diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c index 7bd4ef904115..d0cface535fb 100644 --- a/drivers/bluetooth/hci_bcsp.c +++ b/drivers/bluetooth/hci_bcsp.c | |||
@@ -22,7 +22,6 @@ | |||
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <linux/config.h> | ||
26 | #include <linux/module.h> | 25 | #include <linux/module.h> |
27 | 26 | ||
28 | #include <linux/kernel.h> | 27 | #include <linux/kernel.h> |
diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c index 4804d474dc87..ad62abbbb739 100644 --- a/drivers/bluetooth/hci_h4.c +++ b/drivers/bluetooth/hci_h4.c | |||
@@ -23,7 +23,6 @@ | |||
23 | * | 23 | * |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/config.h> | ||
27 | #include <linux/module.h> | 26 | #include <linux/module.h> |
28 | 27 | ||
29 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index 613673b12fa6..420b645c4c9f 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c | |||
@@ -23,7 +23,6 @@ | |||
23 | * | 23 | * |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/config.h> | ||
27 | #include <linux/module.h> | 26 | #include <linux/module.h> |
28 | 27 | ||
29 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
@@ -192,7 +191,7 @@ static int hci_uart_flush(struct hci_dev *hdev) | |||
192 | 191 | ||
193 | /* Flush any pending characters in the driver and discipline. */ | 192 | /* Flush any pending characters in the driver and discipline. */ |
194 | tty_ldisc_flush(tty); | 193 | tty_ldisc_flush(tty); |
195 | if (tty->driver->flush_buffer) | 194 | if (tty->driver && tty->driver->flush_buffer) |
196 | tty->driver->flush_buffer(tty); | 195 | tty->driver->flush_buffer(tty); |
197 | 196 | ||
198 | if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) | 197 | if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) |
@@ -242,15 +241,11 @@ static int hci_uart_send_frame(struct sk_buff *skb) | |||
242 | 241 | ||
243 | static void hci_uart_destruct(struct hci_dev *hdev) | 242 | static void hci_uart_destruct(struct hci_dev *hdev) |
244 | { | 243 | { |
245 | struct hci_uart *hu; | ||
246 | |||
247 | if (!hdev) | 244 | if (!hdev) |
248 | return; | 245 | return; |
249 | 246 | ||
250 | BT_DBG("%s", hdev->name); | 247 | BT_DBG("%s", hdev->name); |
251 | 248 | kfree(hdev->driver_data); | |
252 | hu = (struct hci_uart *) hdev->driver_data; | ||
253 | kfree(hu); | ||
254 | } | 249 | } |
255 | 250 | ||
256 | /* ------ LDISC part ------ */ | 251 | /* ------ LDISC part ------ */ |
@@ -273,7 +268,7 @@ static int hci_uart_tty_open(struct tty_struct *tty) | |||
273 | return -EEXIST; | 268 | return -EEXIST; |
274 | 269 | ||
275 | if (!(hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL))) { | 270 | if (!(hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL))) { |
276 | BT_ERR("Can't allocate controll structure"); | 271 | BT_ERR("Can't allocate control structure"); |
277 | return -ENFILE; | 272 | return -ENFILE; |
278 | } | 273 | } |
279 | 274 | ||
@@ -291,7 +286,7 @@ static int hci_uart_tty_open(struct tty_struct *tty) | |||
291 | if (tty->ldisc.flush_buffer) | 286 | if (tty->ldisc.flush_buffer) |
292 | tty->ldisc.flush_buffer(tty); | 287 | tty->ldisc.flush_buffer(tty); |
293 | 288 | ||
294 | if (tty->driver->flush_buffer) | 289 | if (tty->driver && tty->driver->flush_buffer) |
295 | tty->driver->flush_buffer(tty); | 290 | tty->driver->flush_buffer(tty); |
296 | 291 | ||
297 | return 0; | 292 | return 0; |
@@ -361,7 +356,7 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty) | |||
361 | * | 356 | * |
362 | * Return Value: None | 357 | * Return Value: None |
363 | */ | 358 | */ |
364 | static void hci_uart_tty_receive(struct tty_struct *tty, const __u8 *data, char *flags, int count) | 359 | static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, char *flags, int count) |
365 | { | 360 | { |
366 | struct hci_uart *hu = (void *)tty->disc_data; | 361 | struct hci_uart *hu = (void *)tty->disc_data; |
367 | 362 | ||
@@ -376,7 +371,8 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const __u8 *data, char | |||
376 | hu->hdev->stat.byte_rx += count; | 371 | hu->hdev->stat.byte_rx += count; |
377 | spin_unlock(&hu->rx_lock); | 372 | spin_unlock(&hu->rx_lock); |
378 | 373 | ||
379 | if (test_and_clear_bit(TTY_THROTTLED,&tty->flags) && tty->driver->unthrottle) | 374 | if (test_and_clear_bit(TTY_THROTTLED, &tty->flags) && |
375 | tty->driver->unthrottle) | ||
380 | tty->driver->unthrottle(tty); | 376 | tty->driver->unthrottle(tty); |
381 | } | 377 | } |
382 | 378 | ||
diff --git a/drivers/bluetooth/hci_usb.c b/drivers/bluetooth/hci_usb.c index 92382e823285..0801af4ad2b9 100644 --- a/drivers/bluetooth/hci_usb.c +++ b/drivers/bluetooth/hci_usb.c | |||
@@ -31,7 +31,6 @@ | |||
31 | * | 31 | * |
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <linux/config.h> | ||
35 | #include <linux/module.h> | 34 | #include <linux/module.h> |
36 | 35 | ||
37 | #include <linux/kernel.h> | 36 | #include <linux/kernel.h> |
@@ -68,6 +67,8 @@ static int ignore = 0; | |||
68 | static int ignore_dga = 0; | 67 | static int ignore_dga = 0; |
69 | static int ignore_csr = 0; | 68 | static int ignore_csr = 0; |
70 | static int ignore_sniffer = 0; | 69 | static int ignore_sniffer = 0; |
70 | static int disable_scofix = 0; | ||
71 | static int force_scofix = 0; | ||
71 | static int reset = 0; | 72 | static int reset = 0; |
72 | 73 | ||
73 | #ifdef CONFIG_BT_HCIUSB_SCO | 74 | #ifdef CONFIG_BT_HCIUSB_SCO |
@@ -95,6 +96,9 @@ static struct usb_device_id bluetooth_ids[] = { | |||
95 | /* Ericsson with non-standard id */ | 96 | /* Ericsson with non-standard id */ |
96 | { USB_DEVICE(0x0bdb, 0x1002) }, | 97 | { USB_DEVICE(0x0bdb, 0x1002) }, |
97 | 98 | ||
99 | /* Canyon CN-BTU1 with HID interfaces */ | ||
100 | { USB_DEVICE(0x0c10, 0x0000), .driver_info = HCI_RESET }, | ||
101 | |||
98 | { } /* Terminating entry */ | 102 | { } /* Terminating entry */ |
99 | }; | 103 | }; |
100 | 104 | ||
@@ -108,9 +112,12 @@ static struct usb_device_id blacklist_ids[] = { | |||
108 | { USB_DEVICE(0x0a5c, 0x2033), .driver_info = HCI_IGNORE }, | 112 | { USB_DEVICE(0x0a5c, 0x2033), .driver_info = HCI_IGNORE }, |
109 | 113 | ||
110 | /* Broadcom BCM2035 */ | 114 | /* Broadcom BCM2035 */ |
111 | { USB_DEVICE(0x0a5c, 0x200a), .driver_info = HCI_RESET | HCI_BROKEN_ISOC }, | 115 | { USB_DEVICE(0x0a5c, 0x200a), .driver_info = HCI_RESET | HCI_WRONG_SCO_MTU }, |
112 | { USB_DEVICE(0x0a5c, 0x2009), .driver_info = HCI_BCM92035 }, | 116 | { USB_DEVICE(0x0a5c, 0x2009), .driver_info = HCI_BCM92035 }, |
113 | 117 | ||
118 | /* IBM/Lenovo ThinkPad with Broadcom chip */ | ||
119 | { USB_DEVICE(0x0a5c, 0x201e), .driver_info = HCI_WRONG_SCO_MTU }, | ||
120 | |||
114 | /* Microsoft Wireless Transceiver for Bluetooth 2.0 */ | 121 | /* Microsoft Wireless Transceiver for Bluetooth 2.0 */ |
115 | { USB_DEVICE(0x045e, 0x009c), .driver_info = HCI_RESET }, | 122 | { USB_DEVICE(0x045e, 0x009c), .driver_info = HCI_RESET }, |
116 | 123 | ||
@@ -120,8 +127,13 @@ static struct usb_device_id blacklist_ids[] = { | |||
120 | /* ISSC Bluetooth Adapter v3.1 */ | 127 | /* ISSC Bluetooth Adapter v3.1 */ |
121 | { USB_DEVICE(0x1131, 0x1001), .driver_info = HCI_RESET }, | 128 | { USB_DEVICE(0x1131, 0x1001), .driver_info = HCI_RESET }, |
122 | 129 | ||
123 | /* RTX Telecom based adapter with buggy SCO support */ | 130 | /* RTX Telecom based adapters with buggy SCO support */ |
124 | { USB_DEVICE(0x0400, 0x0807), .driver_info = HCI_BROKEN_ISOC }, | 131 | { USB_DEVICE(0x0400, 0x0807), .driver_info = HCI_BROKEN_ISOC }, |
132 | { USB_DEVICE(0x0400, 0x080a), .driver_info = HCI_BROKEN_ISOC }, | ||
133 | |||
134 | /* Belkin F8T012 and F8T013 devices */ | ||
135 | { USB_DEVICE(0x050d, 0x0012), .driver_info = HCI_WRONG_SCO_MTU }, | ||
136 | { USB_DEVICE(0x050d, 0x0013), .driver_info = HCI_WRONG_SCO_MTU }, | ||
125 | 137 | ||
126 | /* Digianswer devices */ | 138 | /* Digianswer devices */ |
127 | { USB_DEVICE(0x08fd, 0x0001), .driver_info = HCI_DIGIANSWER }, | 139 | { USB_DEVICE(0x08fd, 0x0001), .driver_info = HCI_DIGIANSWER }, |
@@ -130,6 +142,9 @@ static struct usb_device_id blacklist_ids[] = { | |||
130 | /* CSR BlueCore Bluetooth Sniffer */ | 142 | /* CSR BlueCore Bluetooth Sniffer */ |
131 | { USB_DEVICE(0x0a12, 0x0002), .driver_info = HCI_SNIFFER }, | 143 | { USB_DEVICE(0x0a12, 0x0002), .driver_info = HCI_SNIFFER }, |
132 | 144 | ||
145 | /* Frontline ComProbe Bluetooth Sniffer */ | ||
146 | { USB_DEVICE(0x16d3, 0x0002), .driver_info = HCI_SNIFFER }, | ||
147 | |||
133 | { } /* Terminating entry */ | 148 | { } /* Terminating entry */ |
134 | }; | 149 | }; |
135 | 150 | ||
@@ -985,6 +1000,11 @@ static int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id | |||
985 | if (reset || id->driver_info & HCI_RESET) | 1000 | if (reset || id->driver_info & HCI_RESET) |
986 | set_bit(HCI_QUIRK_RESET_ON_INIT, &hdev->quirks); | 1001 | set_bit(HCI_QUIRK_RESET_ON_INIT, &hdev->quirks); |
987 | 1002 | ||
1003 | if (force_scofix || id->driver_info & HCI_WRONG_SCO_MTU) { | ||
1004 | if (!disable_scofix) | ||
1005 | set_bit(HCI_QUIRK_FIXUP_BUFFER_SIZE, &hdev->quirks); | ||
1006 | } | ||
1007 | |||
988 | if (id->driver_info & HCI_SNIFFER) { | 1008 | if (id->driver_info & HCI_SNIFFER) { |
989 | if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x997) | 1009 | if (le16_to_cpu(udev->descriptor.bcdDevice) > 0x997) |
990 | set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); | 1010 | set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); |
@@ -1043,10 +1063,81 @@ static void hci_usb_disconnect(struct usb_interface *intf) | |||
1043 | hci_free_dev(hdev); | 1063 | hci_free_dev(hdev); |
1044 | } | 1064 | } |
1045 | 1065 | ||
1066 | static int hci_usb_suspend(struct usb_interface *intf, pm_message_t message) | ||
1067 | { | ||
1068 | struct hci_usb *husb = usb_get_intfdata(intf); | ||
1069 | struct list_head killed; | ||
1070 | unsigned long flags; | ||
1071 | int i; | ||
1072 | |||
1073 | if (!husb || intf == husb->isoc_iface) | ||
1074 | return 0; | ||
1075 | |||
1076 | hci_suspend_dev(husb->hdev); | ||
1077 | |||
1078 | INIT_LIST_HEAD(&killed); | ||
1079 | |||
1080 | for (i = 0; i < 4; i++) { | ||
1081 | struct _urb_queue *q = &husb->pending_q[i]; | ||
1082 | struct _urb *_urb, *_tmp; | ||
1083 | |||
1084 | while ((_urb = _urb_dequeue(q))) { | ||
1085 | /* reset queue since _urb_dequeue sets it to NULL */ | ||
1086 | _urb->queue = q; | ||
1087 | usb_kill_urb(&_urb->urb); | ||
1088 | list_add(&_urb->list, &killed); | ||
1089 | } | ||
1090 | |||
1091 | spin_lock_irqsave(&q->lock, flags); | ||
1092 | |||
1093 | list_for_each_entry_safe(_urb, _tmp, &killed, list) { | ||
1094 | list_move_tail(&_urb->list, &q->head); | ||
1095 | } | ||
1096 | |||
1097 | spin_unlock_irqrestore(&q->lock, flags); | ||
1098 | } | ||
1099 | |||
1100 | return 0; | ||
1101 | } | ||
1102 | |||
1103 | static int hci_usb_resume(struct usb_interface *intf) | ||
1104 | { | ||
1105 | struct hci_usb *husb = usb_get_intfdata(intf); | ||
1106 | unsigned long flags; | ||
1107 | int i, err = 0; | ||
1108 | |||
1109 | if (!husb || intf == husb->isoc_iface) | ||
1110 | return 0; | ||
1111 | |||
1112 | for (i = 0; i < 4; i++) { | ||
1113 | struct _urb_queue *q = &husb->pending_q[i]; | ||
1114 | struct _urb *_urb; | ||
1115 | |||
1116 | spin_lock_irqsave(&q->lock, flags); | ||
1117 | |||
1118 | list_for_each_entry(_urb, &q->head, list) { | ||
1119 | err = usb_submit_urb(&_urb->urb, GFP_ATOMIC); | ||
1120 | if (err) | ||
1121 | break; | ||
1122 | } | ||
1123 | |||
1124 | spin_unlock_irqrestore(&q->lock, flags); | ||
1125 | |||
1126 | if (err) | ||
1127 | return -EIO; | ||
1128 | } | ||
1129 | |||
1130 | hci_resume_dev(husb->hdev); | ||
1131 | |||
1132 | return 0; | ||
1133 | } | ||
1134 | |||
1046 | static struct usb_driver hci_usb_driver = { | 1135 | static struct usb_driver hci_usb_driver = { |
1047 | .name = "hci_usb", | 1136 | .name = "hci_usb", |
1048 | .probe = hci_usb_probe, | 1137 | .probe = hci_usb_probe, |
1049 | .disconnect = hci_usb_disconnect, | 1138 | .disconnect = hci_usb_disconnect, |
1139 | .suspend = hci_usb_suspend, | ||
1140 | .resume = hci_usb_resume, | ||
1050 | .id_table = bluetooth_ids, | 1141 | .id_table = bluetooth_ids, |
1051 | }; | 1142 | }; |
1052 | 1143 | ||
@@ -1082,6 +1173,12 @@ MODULE_PARM_DESC(ignore_csr, "Ignore devices with id 0a12:0001"); | |||
1082 | module_param(ignore_sniffer, bool, 0644); | 1173 | module_param(ignore_sniffer, bool, 0644); |
1083 | MODULE_PARM_DESC(ignore_sniffer, "Ignore devices with id 0a12:0002"); | 1174 | MODULE_PARM_DESC(ignore_sniffer, "Ignore devices with id 0a12:0002"); |
1084 | 1175 | ||
1176 | module_param(disable_scofix, bool, 0644); | ||
1177 | MODULE_PARM_DESC(disable_scofix, "Disable fixup of wrong SCO buffer size"); | ||
1178 | |||
1179 | module_param(force_scofix, bool, 0644); | ||
1180 | MODULE_PARM_DESC(force_scofix, "Force fixup of wrong SCO buffers size"); | ||
1181 | |||
1085 | module_param(reset, bool, 0644); | 1182 | module_param(reset, bool, 0644); |
1086 | MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); | 1183 | MODULE_PARM_DESC(reset, "Send HCI reset command on initialization"); |
1087 | 1184 | ||
diff --git a/drivers/bluetooth/hci_usb.h b/drivers/bluetooth/hci_usb.h index 37100a6ea1a8..963fc55cdc85 100644 --- a/drivers/bluetooth/hci_usb.h +++ b/drivers/bluetooth/hci_usb.h | |||
@@ -35,6 +35,7 @@ | |||
35 | #define HCI_SNIFFER 0x10 | 35 | #define HCI_SNIFFER 0x10 |
36 | #define HCI_BCM92035 0x20 | 36 | #define HCI_BCM92035 0x20 |
37 | #define HCI_BROKEN_ISOC 0x40 | 37 | #define HCI_BROKEN_ISOC 0x40 |
38 | #define HCI_WRONG_SCO_MTU 0x80 | ||
38 | 39 | ||
39 | #define HCI_MAX_IFACE_NUM 3 | 40 | #define HCI_MAX_IFACE_NUM 3 |
40 | 41 | ||
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c index 85738223ff0c..a278d98a9151 100644 --- a/drivers/bluetooth/hci_vhci.c +++ b/drivers/bluetooth/hci_vhci.c | |||
@@ -2,9 +2,9 @@ | |||
2 | * | 2 | * |
3 | * Bluetooth virtual HCI driver | 3 | * Bluetooth virtual HCI driver |
4 | * | 4 | * |
5 | * Copyright (C) 2000-2001 Qualcomm Incorporated | 5 | * Copyright (C) 2000-2001 Qualcomm Incorporated |
6 | * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com> | 6 | * Copyright (C) 2002-2003 Maxim Krasnyansky <maxk@qualcomm.com> |
7 | * Copyright (C) 2004-2005 Marcel Holtmann <marcel@holtmann.org> | 7 | * Copyright (C) 2004-2006 Marcel Holtmann <marcel@holtmann.org> |
8 | * | 8 | * |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or modify | 10 | * This program is free software; you can redistribute it and/or modify |
@@ -23,7 +23,6 @@ | |||
23 | * | 23 | * |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include <linux/config.h> | ||
27 | #include <linux/module.h> | 26 | #include <linux/module.h> |
28 | 27 | ||
29 | #include <linux/kernel.h> | 28 | #include <linux/kernel.h> |
@@ -73,21 +72,21 @@ static int vhci_open_dev(struct hci_dev *hdev) | |||
73 | 72 | ||
74 | static int vhci_close_dev(struct hci_dev *hdev) | 73 | static int vhci_close_dev(struct hci_dev *hdev) |
75 | { | 74 | { |
76 | struct vhci_data *vhci = hdev->driver_data; | 75 | struct vhci_data *data = hdev->driver_data; |
77 | 76 | ||
78 | if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) | 77 | if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) |
79 | return 0; | 78 | return 0; |
80 | 79 | ||
81 | skb_queue_purge(&vhci->readq); | 80 | skb_queue_purge(&data->readq); |
82 | 81 | ||
83 | return 0; | 82 | return 0; |
84 | } | 83 | } |
85 | 84 | ||
86 | static int vhci_flush(struct hci_dev *hdev) | 85 | static int vhci_flush(struct hci_dev *hdev) |
87 | { | 86 | { |
88 | struct vhci_data *vhci = hdev->driver_data; | 87 | struct vhci_data *data = hdev->driver_data; |
89 | 88 | ||
90 | skb_queue_purge(&vhci->readq); | 89 | skb_queue_purge(&data->readq); |
91 | 90 | ||
92 | return 0; | 91 | return 0; |
93 | } | 92 | } |
@@ -95,7 +94,7 @@ static int vhci_flush(struct hci_dev *hdev) | |||
95 | static int vhci_send_frame(struct sk_buff *skb) | 94 | static int vhci_send_frame(struct sk_buff *skb) |
96 | { | 95 | { |
97 | struct hci_dev* hdev = (struct hci_dev *) skb->dev; | 96 | struct hci_dev* hdev = (struct hci_dev *) skb->dev; |
98 | struct vhci_data *vhci; | 97 | struct vhci_data *data; |
99 | 98 | ||
100 | if (!hdev) { | 99 | if (!hdev) { |
101 | BT_ERR("Frame for unknown HCI device (hdev=NULL)"); | 100 | BT_ERR("Frame for unknown HCI device (hdev=NULL)"); |
@@ -105,15 +104,15 @@ static int vhci_send_frame(struct sk_buff *skb) | |||
105 | if (!test_bit(HCI_RUNNING, &hdev->flags)) | 104 | if (!test_bit(HCI_RUNNING, &hdev->flags)) |
106 | return -EBUSY; | 105 | return -EBUSY; |
107 | 106 | ||
108 | vhci = hdev->driver_data; | 107 | data = hdev->driver_data; |
109 | 108 | ||
110 | memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1); | 109 | memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1); |
111 | skb_queue_tail(&vhci->readq, skb); | 110 | skb_queue_tail(&data->readq, skb); |
112 | 111 | ||
113 | if (vhci->flags & VHCI_FASYNC) | 112 | if (data->flags & VHCI_FASYNC) |
114 | kill_fasync(&vhci->fasync, SIGIO, POLL_IN); | 113 | kill_fasync(&data->fasync, SIGIO, POLL_IN); |
115 | 114 | ||
116 | wake_up_interruptible(&vhci->read_wait); | 115 | wake_up_interruptible(&data->read_wait); |
117 | 116 | ||
118 | return 0; | 117 | return 0; |
119 | } | 118 | } |
@@ -123,7 +122,7 @@ static void vhci_destruct(struct hci_dev *hdev) | |||
123 | kfree(hdev->driver_data); | 122 | kfree(hdev->driver_data); |
124 | } | 123 | } |
125 | 124 | ||
126 | static inline ssize_t vhci_get_user(struct vhci_data *vhci, | 125 | static inline ssize_t vhci_get_user(struct vhci_data *data, |
127 | const char __user *buf, size_t count) | 126 | const char __user *buf, size_t count) |
128 | { | 127 | { |
129 | struct sk_buff *skb; | 128 | struct sk_buff *skb; |
@@ -140,7 +139,7 @@ static inline ssize_t vhci_get_user(struct vhci_data *vhci, | |||
140 | return -EFAULT; | 139 | return -EFAULT; |
141 | } | 140 | } |
142 | 141 | ||
143 | skb->dev = (void *) vhci->hdev; | 142 | skb->dev = (void *) data->hdev; |
144 | bt_cb(skb)->pkt_type = *((__u8 *) skb->data); | 143 | bt_cb(skb)->pkt_type = *((__u8 *) skb->data); |
145 | skb_pull(skb, 1); | 144 | skb_pull(skb, 1); |
146 | 145 | ||
@@ -149,7 +148,7 @@ static inline ssize_t vhci_get_user(struct vhci_data *vhci, | |||
149 | return count; | 148 | return count; |
150 | } | 149 | } |
151 | 150 | ||
152 | static inline ssize_t vhci_put_user(struct vhci_data *vhci, | 151 | static inline ssize_t vhci_put_user(struct vhci_data *data, |
153 | struct sk_buff *skb, char __user *buf, int count) | 152 | struct sk_buff *skb, char __user *buf, int count) |
154 | { | 153 | { |
155 | char __user *ptr = buf; | 154 | char __user *ptr = buf; |
@@ -162,42 +161,43 @@ static inline ssize_t vhci_put_user(struct vhci_data *vhci, | |||
162 | 161 | ||
163 | total += len; | 162 | total += len; |
164 | 163 | ||
165 | vhci->hdev->stat.byte_tx += len; | 164 | data->hdev->stat.byte_tx += len; |
166 | 165 | ||
167 | switch (bt_cb(skb)->pkt_type) { | 166 | switch (bt_cb(skb)->pkt_type) { |
168 | case HCI_COMMAND_PKT: | 167 | case HCI_COMMAND_PKT: |
169 | vhci->hdev->stat.cmd_tx++; | 168 | data->hdev->stat.cmd_tx++; |
170 | break; | 169 | break; |
171 | 170 | ||
172 | case HCI_ACLDATA_PKT: | 171 | case HCI_ACLDATA_PKT: |
173 | vhci->hdev->stat.acl_tx++; | 172 | data->hdev->stat.acl_tx++; |
174 | break; | 173 | break; |
175 | 174 | ||
176 | case HCI_SCODATA_PKT: | 175 | case HCI_SCODATA_PKT: |
177 | vhci->hdev->stat.cmd_tx++; | 176 | data->hdev->stat.cmd_tx++; |
178 | break; | 177 | break; |
179 | }; | 178 | }; |
180 | 179 | ||
181 | return total; | 180 | return total; |
182 | } | 181 | } |
183 | 182 | ||
184 | static loff_t vhci_llseek(struct file * file, loff_t offset, int origin) | 183 | static loff_t vhci_llseek(struct file *file, loff_t offset, int origin) |
185 | { | 184 | { |
186 | return -ESPIPE; | 185 | return -ESPIPE; |
187 | } | 186 | } |
188 | 187 | ||
189 | static ssize_t vhci_read(struct file * file, char __user * buf, size_t count, loff_t *pos) | 188 | static ssize_t vhci_read(struct file *file, |
189 | char __user *buf, size_t count, loff_t *pos) | ||
190 | { | 190 | { |
191 | DECLARE_WAITQUEUE(wait, current); | 191 | DECLARE_WAITQUEUE(wait, current); |
192 | struct vhci_data *vhci = file->private_data; | 192 | struct vhci_data *data = file->private_data; |
193 | struct sk_buff *skb; | 193 | struct sk_buff *skb; |
194 | ssize_t ret = 0; | 194 | ssize_t ret = 0; |
195 | 195 | ||
196 | add_wait_queue(&vhci->read_wait, &wait); | 196 | add_wait_queue(&data->read_wait, &wait); |
197 | while (count) { | 197 | while (count) { |
198 | set_current_state(TASK_INTERRUPTIBLE); | 198 | set_current_state(TASK_INTERRUPTIBLE); |
199 | 199 | ||
200 | skb = skb_dequeue(&vhci->readq); | 200 | skb = skb_dequeue(&data->readq); |
201 | if (!skb) { | 201 | if (!skb) { |
202 | if (file->f_flags & O_NONBLOCK) { | 202 | if (file->f_flags & O_NONBLOCK) { |
203 | ret = -EAGAIN; | 203 | ret = -EAGAIN; |
@@ -214,7 +214,7 @@ static ssize_t vhci_read(struct file * file, char __user * buf, size_t count, lo | |||
214 | } | 214 | } |
215 | 215 | ||
216 | if (access_ok(VERIFY_WRITE, buf, count)) | 216 | if (access_ok(VERIFY_WRITE, buf, count)) |
217 | ret = vhci_put_user(vhci, skb, buf, count); | 217 | ret = vhci_put_user(data, skb, buf, count); |
218 | else | 218 | else |
219 | ret = -EFAULT; | 219 | ret = -EFAULT; |
220 | 220 | ||
@@ -222,7 +222,7 @@ static ssize_t vhci_read(struct file * file, char __user * buf, size_t count, lo | |||
222 | break; | 222 | break; |
223 | } | 223 | } |
224 | set_current_state(TASK_RUNNING); | 224 | set_current_state(TASK_RUNNING); |
225 | remove_wait_queue(&vhci->read_wait, &wait); | 225 | remove_wait_queue(&data->read_wait, &wait); |
226 | 226 | ||
227 | return ret; | 227 | return ret; |
228 | } | 228 | } |
@@ -230,21 +230,21 @@ static ssize_t vhci_read(struct file * file, char __user * buf, size_t count, lo | |||
230 | static ssize_t vhci_write(struct file *file, | 230 | static ssize_t vhci_write(struct file *file, |
231 | const char __user *buf, size_t count, loff_t *pos) | 231 | const char __user *buf, size_t count, loff_t *pos) |
232 | { | 232 | { |
233 | struct vhci_data *vhci = file->private_data; | 233 | struct vhci_data *data = file->private_data; |
234 | 234 | ||
235 | if (!access_ok(VERIFY_READ, buf, count)) | 235 | if (!access_ok(VERIFY_READ, buf, count)) |
236 | return -EFAULT; | 236 | return -EFAULT; |
237 | 237 | ||
238 | return vhci_get_user(vhci, buf, count); | 238 | return vhci_get_user(data, buf, count); |
239 | } | 239 | } |
240 | 240 | ||
241 | static unsigned int vhci_poll(struct file *file, poll_table *wait) | 241 | static unsigned int vhci_poll(struct file *file, poll_table *wait) |
242 | { | 242 | { |
243 | struct vhci_data *vhci = file->private_data; | 243 | struct vhci_data *data = file->private_data; |
244 | 244 | ||
245 | poll_wait(file, &vhci->read_wait, wait); | 245 | poll_wait(file, &data->read_wait, wait); |
246 | 246 | ||
247 | if (!skb_queue_empty(&vhci->readq)) | 247 | if (!skb_queue_empty(&data->readq)) |
248 | return POLLIN | POLLRDNORM; | 248 | return POLLIN | POLLRDNORM; |
249 | 249 | ||
250 | return POLLOUT | POLLWRNORM; | 250 | return POLLOUT | POLLWRNORM; |
@@ -258,27 +258,26 @@ static int vhci_ioctl(struct inode *inode, struct file *file, | |||
258 | 258 | ||
259 | static int vhci_open(struct inode *inode, struct file *file) | 259 | static int vhci_open(struct inode *inode, struct file *file) |
260 | { | 260 | { |
261 | struct vhci_data *vhci; | 261 | struct vhci_data *data; |
262 | struct hci_dev *hdev; | 262 | struct hci_dev *hdev; |
263 | 263 | ||
264 | vhci = kzalloc(sizeof(struct vhci_data), GFP_KERNEL); | 264 | data = kzalloc(sizeof(struct vhci_data), GFP_KERNEL); |
265 | if (!vhci) | 265 | if (!data) |
266 | return -ENOMEM; | 266 | return -ENOMEM; |
267 | 267 | ||
268 | skb_queue_head_init(&vhci->readq); | 268 | skb_queue_head_init(&data->readq); |
269 | init_waitqueue_head(&vhci->read_wait); | 269 | init_waitqueue_head(&data->read_wait); |
270 | 270 | ||
271 | hdev = hci_alloc_dev(); | 271 | hdev = hci_alloc_dev(); |
272 | if (!hdev) { | 272 | if (!hdev) { |
273 | kfree(vhci); | 273 | kfree(data); |
274 | return -ENOMEM; | 274 | return -ENOMEM; |
275 | } | 275 | } |
276 | 276 | ||
277 | vhci->hdev = hdev; | 277 | data->hdev = hdev; |
278 | 278 | ||
279 | hdev->type = HCI_VHCI; | 279 | hdev->type = HCI_VIRTUAL; |
280 | hdev->driver_data = vhci; | 280 | hdev->driver_data = data; |
281 | SET_HCIDEV_DEV(hdev, vhci_miscdev.dev); | ||
282 | 281 | ||
283 | hdev->open = vhci_open_dev; | 282 | hdev->open = vhci_open_dev; |
284 | hdev->close = vhci_close_dev; | 283 | hdev->close = vhci_close_dev; |
@@ -290,20 +289,20 @@ static int vhci_open(struct inode *inode, struct file *file) | |||
290 | 289 | ||
291 | if (hci_register_dev(hdev) < 0) { | 290 | if (hci_register_dev(hdev) < 0) { |
292 | BT_ERR("Can't register HCI device"); | 291 | BT_ERR("Can't register HCI device"); |
293 | kfree(vhci); | 292 | kfree(data); |
294 | hci_free_dev(hdev); | 293 | hci_free_dev(hdev); |
295 | return -EBUSY; | 294 | return -EBUSY; |
296 | } | 295 | } |
297 | 296 | ||
298 | file->private_data = vhci; | 297 | file->private_data = data; |
299 | 298 | ||
300 | return nonseekable_open(inode, file); | 299 | return nonseekable_open(inode, file); |
301 | } | 300 | } |
302 | 301 | ||
303 | static int vhci_release(struct inode *inode, struct file *file) | 302 | static int vhci_release(struct inode *inode, struct file *file) |
304 | { | 303 | { |
305 | struct vhci_data *vhci = file->private_data; | 304 | struct vhci_data *data = file->private_data; |
306 | struct hci_dev *hdev = vhci->hdev; | 305 | struct hci_dev *hdev = data->hdev; |
307 | 306 | ||
308 | if (hci_unregister_dev(hdev) < 0) { | 307 | if (hci_unregister_dev(hdev) < 0) { |
309 | BT_ERR("Can't unregister HCI device %s", hdev->name); | 308 | BT_ERR("Can't unregister HCI device %s", hdev->name); |
@@ -318,17 +317,17 @@ static int vhci_release(struct inode *inode, struct file *file) | |||
318 | 317 | ||
319 | static int vhci_fasync(int fd, struct file *file, int on) | 318 | static int vhci_fasync(int fd, struct file *file, int on) |
320 | { | 319 | { |
321 | struct vhci_data *vhci = file->private_data; | 320 | struct vhci_data *data = file->private_data; |
322 | int err; | 321 | int err; |
323 | 322 | ||
324 | err = fasync_helper(fd, file, on, &vhci->fasync); | 323 | err = fasync_helper(fd, file, on, &data->fasync); |
325 | if (err < 0) | 324 | if (err < 0) |
326 | return err; | 325 | return err; |
327 | 326 | ||
328 | if (on) | 327 | if (on) |
329 | vhci->flags |= VHCI_FASYNC; | 328 | data->flags |= VHCI_FASYNC; |
330 | else | 329 | else |
331 | vhci->flags &= ~VHCI_FASYNC; | 330 | data->flags &= ~VHCI_FASYNC; |
332 | 331 | ||
333 | return 0; | 332 | return 0; |
334 | } | 333 | } |