From: Johan Hedberg Date: Fri, 30 Jan 2015 08:58:54 +0000 (+0200) Subject: Bluetooth: btusb: Fix race when waiting for BTUSB_DOWNLOADING X-Git-Tag: fixes-v4.0-rc1~150^2~73^2~20 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a087a98e0767cf6c4f2480e6de5441497c9ba5b7;p=pandora-kernel.git Bluetooth: btusb: Fix race when waiting for BTUSB_DOWNLOADING The test for BTUSB_DOWNLOADING must be after adding to the wait queue and setting the TASK_INTERRUPTIBLE state. Otherwise the flag may get cleared after we test for it and we end up getting a timeout since schedule_timeout() waits for the full duration. This patch uses a wait_on_bit_timeout() + wake_up_bit(). To perform the task both race-free as well as in a much simpler way. Since there's no global wait_on_bit_timeout() helper yet (even though all the building blocks for it are in place) this patch creates a temporary local btusb copy of it until the global one has made it to upstream trees. Signed-off-by: Johan Hedberg Signed-off-by: Marcel Holtmann --- Reading git-diff-tree failed