Bluetooth: btusb: Use wait_on_bit_timeout() for BTUSB_BOOTING
The wait_on_bit_timeout() is a simpler and race-free way of waiting for a bit to be cleared than the current code in btusb.c. This patch updates the code to use the helper function (its btusb copy - to be later updated to use a global one). Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
This commit is contained in:
parent
a087a98e07
commit
fad7097228
|
@ -1822,8 +1822,10 @@ static int btusb_recv_event_intel(struct hci_dev *hdev, struct sk_buff *skb)
|
||||||
*/
|
*/
|
||||||
if (skb->len == 9 && hdr->evt == 0xff && hdr->plen == 0x07 &&
|
if (skb->len == 9 && hdr->evt == 0xff && hdr->plen == 0x07 &&
|
||||||
skb->data[2] == 0x02) {
|
skb->data[2] == 0x02) {
|
||||||
if (test_and_clear_bit(BTUSB_BOOTING, &data->flags))
|
if (test_and_clear_bit(BTUSB_BOOTING, &data->flags)) {
|
||||||
wake_up_interruptible(&hdev->req_wait_q);
|
smp_mb__after_atomic();
|
||||||
|
wake_up_bit(&data->flags, BTUSB_BOOTING);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2236,34 +2238,26 @@ done:
|
||||||
|
|
||||||
/* The bootloader will not indicate when the device is ready. This
|
/* The bootloader will not indicate when the device is ready. This
|
||||||
* is done by the operational firmware sending bootup notification.
|
* is done by the operational firmware sending bootup notification.
|
||||||
|
*
|
||||||
|
* Booting into operational firmware should not take longer than
|
||||||
|
* 1 second. However if that happens, then just fail the setup
|
||||||
|
* since something went wrong.
|
||||||
*/
|
*/
|
||||||
if (test_bit(BTUSB_BOOTING, &data->flags)) {
|
|
||||||
DECLARE_WAITQUEUE(wait, current);
|
|
||||||
signed long timeout;
|
|
||||||
|
|
||||||
BT_INFO("%s: Waiting for device to boot", hdev->name);
|
BT_INFO("%s: Waiting for device to boot", hdev->name);
|
||||||
|
|
||||||
add_wait_queue(&hdev->req_wait_q, &wait);
|
err = btusb_wait_on_bit_timeout(&data->flags, BTUSB_BOOTING,
|
||||||
set_current_state(TASK_INTERRUPTIBLE);
|
msecs_to_jiffies(1000),
|
||||||
|
TASK_INTERRUPTIBLE);
|
||||||
|
|
||||||
/* Booting into operational firmware should not take
|
if (err == 1) {
|
||||||
* longer than 1 second. However if that happens, then
|
|
||||||
* just fail the setup since something went wrong.
|
|
||||||
*/
|
|
||||||
timeout = schedule_timeout(msecs_to_jiffies(1000));
|
|
||||||
|
|
||||||
remove_wait_queue(&hdev->req_wait_q, &wait);
|
|
||||||
|
|
||||||
if (signal_pending(current)) {
|
|
||||||
BT_ERR("%s: Device boot interrupted", hdev->name);
|
BT_ERR("%s: Device boot interrupted", hdev->name);
|
||||||
return -EINTR;
|
return -EINTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!timeout) {
|
if (err) {
|
||||||
BT_ERR("%s: Device boot timeout", hdev->name);
|
BT_ERR("%s: Device boot timeout", hdev->name);
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
rettime = ktime_get();
|
rettime = ktime_get();
|
||||||
delta = ktime_sub(rettime, calltime);
|
delta = ktime_sub(rettime, calltime);
|
||||||
|
|
Loading…
Reference in New Issue