diff --git a/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c b/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c index 63b0ca36bf..8deb11924f 100644 --- a/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c +++ b/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2generic.c @@ -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; diff --git a/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c b/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c index 2cba1946e5..f4574769f4 100644 --- a/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c +++ b/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2transactions.c @@ -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