aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@intel.com>2015-01-30 03:58:55 -0500
committerMarcel Holtmann <marcel@holtmann.org>2015-01-30 05:03:20 -0500
commitfad7097228496c2ce0c6bef2fec87f8b74d5f6dd (patch)
tree8d355487b7fb90c6c70a93c06dabe661cb80a036 /drivers/bluetooth
parenta087a98e0767cf6c4f2480e6de5441497c9ba5b7 (diff)
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>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r--drivers/bluetooth/btusb.c44
1 files changed, 19 insertions, 25 deletions
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 98341a463f30..a3a47c50f6bc 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1822,8 +1822,10 @@ static int btusb_recv_event_intel(struct hci_dev *hdev, struct sk_buff *skb)
1822 */ 1822 */
1823 if (skb->len == 9 && hdr->evt == 0xff && hdr->plen == 0x07 && 1823 if (skb->len == 9 && hdr->evt == 0xff && hdr->plen == 0x07 &&
1824 skb->data[2] == 0x02) { 1824 skb->data[2] == 0x02) {
1825 if (test_and_clear_bit(BTUSB_BOOTING, &data->flags)) 1825 if (test_and_clear_bit(BTUSB_BOOTING, &data->flags)) {
1826 wake_up_interruptible(&hdev->req_wait_q); 1826 smp_mb__after_atomic();
1827 wake_up_bit(&data->flags, BTUSB_BOOTING);
1828 }
1827 } 1829 }
1828 } 1830 }
1829 1831
@@ -2236,33 +2238,25 @@ done:
2236 2238
2237 /* The bootloader will not indicate when the device is ready. This 2239 /* The bootloader will not indicate when the device is ready. This
2238 * is done by the operational firmware sending bootup notification. 2240 * is done by the operational firmware sending bootup notification.
2241 *
2242 * Booting into operational firmware should not take longer than
2243 * 1 second. However if that happens, then just fail the setup
2244 * since something went wrong.
2239 */ 2245 */
2240 if (test_bit(BTUSB_BOOTING, &data->flags)) { 2246 BT_INFO("%s: Waiting for device to boot", hdev->name);
2241 DECLARE_WAITQUEUE(wait, current);
2242 signed long timeout;
2243
2244 BT_INFO("%s: Waiting for device to boot", hdev->name);
2245
2246 add_wait_queue(&hdev->req_wait_q, &wait);
2247 set_current_state(TASK_INTERRUPTIBLE);
2248
2249 /* Booting into operational firmware should not take
2250 * longer than 1 second. However if that happens, then
2251 * just fail the setup since something went wrong.
2252 */
2253 timeout = schedule_timeout(msecs_to_jiffies(1000));
2254 2247
2255 remove_wait_queue(&hdev->req_wait_q, &wait); 2248 err = btusb_wait_on_bit_timeout(&data->flags, BTUSB_BOOTING,
2249 msecs_to_jiffies(1000),
2250 TASK_INTERRUPTIBLE);
2256 2251
2257 if (signal_pending(current)) { 2252 if (err == 1) {
2258 BT_ERR("%s: Device boot interrupted", hdev->name); 2253 BT_ERR("%s: Device boot interrupted", hdev->name);
2259 return -EINTR; 2254 return -EINTR;
2260 } 2255 }
2261 2256
2262 if (!timeout) { 2257 if (err) {
2263 BT_ERR("%s: Device boot timeout", hdev->name); 2258 BT_ERR("%s: Device boot timeout", hdev->name);
2264 return -ETIMEDOUT; 2259 return -ETIMEDOUT;
2265 }
2266 } 2260 }
2267 2261
2268 rettime = ktime_get(); 2262 rettime = ktime_get();