diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2008-11-30 06:17:10 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2008-11-30 06:17:10 -0500 |
commit | 2eda66f4a0b9803c6a85d5e5ccd8e802bd23b998 (patch) | |
tree | f1ddb75becaa51df08c66e0038a436d9a5a4950c /drivers/bluetooth | |
parent | 25f13048bce61f33f6a102e0bf377fd3922ed364 (diff) |
Bluetooth: Add fine grained mem_flags usage to btusb driver
The URB submission routines need more fine grained control for the
mem_flags used by kmalloc(), usb_alloc_urb() and usb_submit_urb() to
better support different caller situations. Add a mem_flags parameter
and give the caller full control.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r-- | drivers/bluetooth/btusb.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index af472e052732..3c85f9b078b5 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c | |||
@@ -236,7 +236,7 @@ static void btusb_intr_complete(struct urb *urb) | |||
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | static int btusb_submit_intr_urb(struct hci_dev *hdev) | 239 | static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags) |
240 | { | 240 | { |
241 | struct btusb_data *data = hdev->driver_data; | 241 | struct btusb_data *data = hdev->driver_data; |
242 | struct urb *urb; | 242 | struct urb *urb; |
@@ -249,13 +249,13 @@ static int btusb_submit_intr_urb(struct hci_dev *hdev) | |||
249 | if (!data->intr_ep) | 249 | if (!data->intr_ep) |
250 | return -ENODEV; | 250 | return -ENODEV; |
251 | 251 | ||
252 | urb = usb_alloc_urb(0, GFP_ATOMIC); | 252 | urb = usb_alloc_urb(0, mem_flags); |
253 | if (!urb) | 253 | if (!urb) |
254 | return -ENOMEM; | 254 | return -ENOMEM; |
255 | 255 | ||
256 | size = le16_to_cpu(data->intr_ep->wMaxPacketSize); | 256 | size = le16_to_cpu(data->intr_ep->wMaxPacketSize); |
257 | 257 | ||
258 | buf = kmalloc(size, GFP_ATOMIC); | 258 | buf = kmalloc(size, mem_flags); |
259 | if (!buf) { | 259 | if (!buf) { |
260 | usb_free_urb(urb); | 260 | usb_free_urb(urb); |
261 | return -ENOMEM; | 261 | return -ENOMEM; |
@@ -271,7 +271,7 @@ static int btusb_submit_intr_urb(struct hci_dev *hdev) | |||
271 | 271 | ||
272 | usb_anchor_urb(urb, &data->intr_anchor); | 272 | usb_anchor_urb(urb, &data->intr_anchor); |
273 | 273 | ||
274 | err = usb_submit_urb(urb, GFP_ATOMIC); | 274 | err = usb_submit_urb(urb, mem_flags); |
275 | if (err < 0) { | 275 | if (err < 0) { |
276 | BT_ERR("%s urb %p submission failed (%d)", | 276 | BT_ERR("%s urb %p submission failed (%d)", |
277 | hdev->name, urb, -err); | 277 | hdev->name, urb, -err); |
@@ -319,7 +319,7 @@ static void btusb_bulk_complete(struct urb *urb) | |||
319 | } | 319 | } |
320 | } | 320 | } |
321 | 321 | ||
322 | static int btusb_submit_bulk_urb(struct hci_dev *hdev) | 322 | static int btusb_submit_bulk_urb(struct hci_dev *hdev, gfp_t mem_flags) |
323 | { | 323 | { |
324 | struct btusb_data *data = hdev->driver_data; | 324 | struct btusb_data *data = hdev->driver_data; |
325 | struct urb *urb; | 325 | struct urb *urb; |
@@ -332,13 +332,13 @@ static int btusb_submit_bulk_urb(struct hci_dev *hdev) | |||
332 | if (!data->bulk_rx_ep) | 332 | if (!data->bulk_rx_ep) |
333 | return -ENODEV; | 333 | return -ENODEV; |
334 | 334 | ||
335 | urb = usb_alloc_urb(0, GFP_KERNEL); | 335 | urb = usb_alloc_urb(0, mem_flags); |
336 | if (!urb) | 336 | if (!urb) |
337 | return -ENOMEM; | 337 | return -ENOMEM; |
338 | 338 | ||
339 | size = le16_to_cpu(data->bulk_rx_ep->wMaxPacketSize); | 339 | size = le16_to_cpu(data->bulk_rx_ep->wMaxPacketSize); |
340 | 340 | ||
341 | buf = kmalloc(size, GFP_KERNEL); | 341 | buf = kmalloc(size, mem_flags); |
342 | if (!buf) { | 342 | if (!buf) { |
343 | usb_free_urb(urb); | 343 | usb_free_urb(urb); |
344 | return -ENOMEM; | 344 | return -ENOMEM; |
@@ -353,7 +353,7 @@ static int btusb_submit_bulk_urb(struct hci_dev *hdev) | |||
353 | 353 | ||
354 | usb_anchor_urb(urb, &data->bulk_anchor); | 354 | usb_anchor_urb(urb, &data->bulk_anchor); |
355 | 355 | ||
356 | err = usb_submit_urb(urb, GFP_KERNEL); | 356 | err = usb_submit_urb(urb, mem_flags); |
357 | if (err < 0) { | 357 | if (err < 0) { |
358 | BT_ERR("%s urb %p submission failed (%d)", | 358 | BT_ERR("%s urb %p submission failed (%d)", |
359 | hdev->name, urb, -err); | 359 | hdev->name, urb, -err); |
@@ -430,7 +430,7 @@ static void inline __fill_isoc_descriptor(struct urb *urb, int len, int mtu) | |||
430 | urb->number_of_packets = i; | 430 | urb->number_of_packets = i; |
431 | } | 431 | } |
432 | 432 | ||
433 | static int btusb_submit_isoc_urb(struct hci_dev *hdev) | 433 | static int btusb_submit_isoc_urb(struct hci_dev *hdev, gfp_t mem_flags) |
434 | { | 434 | { |
435 | struct btusb_data *data = hdev->driver_data; | 435 | struct btusb_data *data = hdev->driver_data; |
436 | struct urb *urb; | 436 | struct urb *urb; |
@@ -443,14 +443,14 @@ static int btusb_submit_isoc_urb(struct hci_dev *hdev) | |||
443 | if (!data->isoc_rx_ep) | 443 | if (!data->isoc_rx_ep) |
444 | return -ENODEV; | 444 | return -ENODEV; |
445 | 445 | ||
446 | urb = usb_alloc_urb(BTUSB_MAX_ISOC_FRAMES, GFP_KERNEL); | 446 | urb = usb_alloc_urb(BTUSB_MAX_ISOC_FRAMES, mem_flags); |
447 | if (!urb) | 447 | if (!urb) |
448 | return -ENOMEM; | 448 | return -ENOMEM; |
449 | 449 | ||
450 | size = le16_to_cpu(data->isoc_rx_ep->wMaxPacketSize) * | 450 | size = le16_to_cpu(data->isoc_rx_ep->wMaxPacketSize) * |
451 | BTUSB_MAX_ISOC_FRAMES; | 451 | BTUSB_MAX_ISOC_FRAMES; |
452 | 452 | ||
453 | buf = kmalloc(size, GFP_KERNEL); | 453 | buf = kmalloc(size, mem_flags); |
454 | if (!buf) { | 454 | if (!buf) { |
455 | usb_free_urb(urb); | 455 | usb_free_urb(urb); |
456 | return -ENOMEM; | 456 | return -ENOMEM; |
@@ -473,7 +473,7 @@ static int btusb_submit_isoc_urb(struct hci_dev *hdev) | |||
473 | 473 | ||
474 | usb_anchor_urb(urb, &data->isoc_anchor); | 474 | usb_anchor_urb(urb, &data->isoc_anchor); |
475 | 475 | ||
476 | err = usb_submit_urb(urb, GFP_KERNEL); | 476 | err = usb_submit_urb(urb, mem_flags); |
477 | if (err < 0) { | 477 | if (err < 0) { |
478 | BT_ERR("%s urb %p submission failed (%d)", | 478 | BT_ERR("%s urb %p submission failed (%d)", |
479 | hdev->name, urb, -err); | 479 | hdev->name, urb, -err); |
@@ -520,7 +520,7 @@ static int btusb_open(struct hci_dev *hdev) | |||
520 | if (test_and_set_bit(BTUSB_INTR_RUNNING, &data->flags)) | 520 | if (test_and_set_bit(BTUSB_INTR_RUNNING, &data->flags)) |
521 | return 0; | 521 | return 0; |
522 | 522 | ||
523 | err = btusb_submit_intr_urb(hdev); | 523 | err = btusb_submit_intr_urb(hdev, GFP_KERNEL); |
524 | if (err < 0) { | 524 | if (err < 0) { |
525 | clear_bit(BTUSB_INTR_RUNNING, &data->flags); | 525 | clear_bit(BTUSB_INTR_RUNNING, &data->flags); |
526 | clear_bit(HCI_RUNNING, &hdev->flags); | 526 | clear_bit(HCI_RUNNING, &hdev->flags); |
@@ -734,10 +734,10 @@ static void btusb_work(struct work_struct *work) | |||
734 | 734 | ||
735 | if (hdev->conn_hash.acl_num > 0) { | 735 | if (hdev->conn_hash.acl_num > 0) { |
736 | if (!test_and_set_bit(BTUSB_BULK_RUNNING, &data->flags)) { | 736 | if (!test_and_set_bit(BTUSB_BULK_RUNNING, &data->flags)) { |
737 | if (btusb_submit_bulk_urb(hdev) < 0) | 737 | if (btusb_submit_bulk_urb(hdev, GFP_KERNEL) < 0) |
738 | clear_bit(BTUSB_BULK_RUNNING, &data->flags); | 738 | clear_bit(BTUSB_BULK_RUNNING, &data->flags); |
739 | else | 739 | else |
740 | btusb_submit_bulk_urb(hdev); | 740 | btusb_submit_bulk_urb(hdev, GFP_KERNEL); |
741 | } | 741 | } |
742 | } else { | 742 | } else { |
743 | clear_bit(BTUSB_BULK_RUNNING, &data->flags); | 743 | clear_bit(BTUSB_BULK_RUNNING, &data->flags); |
@@ -754,10 +754,10 @@ static void btusb_work(struct work_struct *work) | |||
754 | } | 754 | } |
755 | 755 | ||
756 | if (!test_and_set_bit(BTUSB_ISOC_RUNNING, &data->flags)) { | 756 | if (!test_and_set_bit(BTUSB_ISOC_RUNNING, &data->flags)) { |
757 | if (btusb_submit_isoc_urb(hdev) < 0) | 757 | if (btusb_submit_isoc_urb(hdev, GFP_KERNEL) < 0) |
758 | clear_bit(BTUSB_ISOC_RUNNING, &data->flags); | 758 | clear_bit(BTUSB_ISOC_RUNNING, &data->flags); |
759 | else | 759 | else |
760 | btusb_submit_isoc_urb(hdev); | 760 | btusb_submit_isoc_urb(hdev, GFP_KERNEL); |
761 | } | 761 | } |
762 | } else { | 762 | } else { |
763 | clear_bit(BTUSB_ISOC_RUNNING, &data->flags); | 763 | clear_bit(BTUSB_ISOC_RUNNING, &data->flags); |