- Cancelling pending transfers at close hook while it is still plugged preventing any resubmittion, this is related ticket 2353

- Free device in correct hook

This allows closing and reopening the bluetooth_server keeping bluetooth functionality



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31053 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes 2009-06-14 19:51:29 +00:00
parent c2e9f2a697
commit 3ae24dffb1
2 changed files with 29 additions and 18 deletions

View File

@ -374,23 +374,21 @@ device_removed(void* cookie)
flowf("Cancelling queues...\n");
if (bdev->intr_in_ep != NULL) {
usb->cancel_queued_transfers(bdev->intr_in_ep->handle);
flowf("Cancelling impossible EVENTS\n");
flowf("Cancelling possible EVENTS\n");
}
if (bdev->bulk_in_ep!=NULL) {
usb->cancel_queued_transfers(bdev->bulk_in_ep->handle);
flowf("Cancelling impossible ACL in\n");
flowf("Cancelling possible ACL in\n");
}
if (bdev->bulk_out_ep!=NULL) {
usb->cancel_queued_transfers(bdev->bulk_out_ep->handle);
flowf("Cancelling impossible ACL out\n");
flowf("Cancelling possible ACL out\n");
}
bdev->connected = false;
// TODO: place this in the appropiated hook
// kill_device(bdev);
return B_OK;
}
@ -533,6 +531,24 @@ device_close(void *cookie)
// Clean queues
if (bdev->connected == true) {
flowf("Cancelling queues...\n");
if (bdev->intr_in_ep != NULL) {
usb->cancel_queued_transfers(bdev->intr_in_ep->handle);
flowf("Cancelling possible EVENTS\n");
}
if (bdev->bulk_in_ep!=NULL) {
usb->cancel_queued_transfers(bdev->bulk_in_ep->handle);
flowf("Cancelling possible ACL in\n");
}
if (bdev->bulk_out_ep!=NULL) {
usb->cancel_queued_transfers(bdev->bulk_out_ep->handle);
flowf("Cancelling possible ACL out\n");
}
}
// TX
for (i = 0; i < BT_DRIVER_TXCOVERAGE; i++) {
if (i == BT_COMMAND)
@ -578,14 +594,9 @@ device_free (void *cookie)
debugf("device_free() called on %s \n",BLUETOOTH_DEVICE_PATH);
if (--bdev->open_count == 0) {
/* GotoLowPower */
// interesting .....
} else {
/* The last client has closed, and the device is no longer
connected, so remove it from the list. */
if (!bdev->connected) {
flowf("Device not present can be killed\n");
kill_device(bdev);
}
return err;

View File

@ -164,12 +164,12 @@ event_complete(void* cookie, status_t status, void* data, size_t actual_len)
//bt_usb_dev* bdev = fetch_device(cookie, 0); -> safer/slower option
status_t error;
debugf("cookie@%p status=%ld len=%ld\n", cookie, status, actual_len);
debugf("cookie@%p status=%s len=%ld\n", cookie, strerror(status), actual_len);
if (bdev == NULL)
return;
if (status == B_CANCELED) // or not running anymore...
if (status == B_CANCELED || status == B_DEV_CRC_ERROR) // or not running anymore...
return;
if (status != B_OK || actual_len == 0)
@ -210,7 +210,7 @@ acl_rx_complete(void* cookie, status_t status, void* data, size_t actual_len)
if (bdev == NULL)
return;
if (status == B_CANCELED) // or not running anymore...
if (status == B_CANCELED || status == B_DEV_CRC_ERROR) // or not running anymore...
return;
if (status != B_OK || actual_len == 0)
@ -312,7 +312,7 @@ command_complete(void* cookie, status_t status, void* data, size_t actual_len)
snet_buffer* snbuf = (snet_buffer*)cookie;
bt_usb_dev* bdev = snb_cookie(snbuf);
debugf("len = %ld @%p\n", actual_len, data);
debugf("status = %ld len = %ld @%p\n", status, actual_len, data);
if (status == B_OK) {
bdev->stat.successfulTX++;
@ -379,7 +379,7 @@ submit_tx_command(bt_usb_dev* bdev, snet_buffer* snbuf)
snb_set_cookie(snbuf, bdev);
debugf("@%p\n", snb_get(snbuf));
error = usb->queue_request(bdev->dev, bRequestType, bRequest,
value, wIndex, wLength, snb_get(snbuf),
#ifndef HAIKU_TARGET_PLATFORM_HAIKU