All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH, RFC] Bluetooth: btusb, hci_intel: Fix wait_on_bit_timeout() return value checks
@ 2016-08-11 23:02 Bart Van Assche
  2016-08-12  9:12 ` Johan Hedberg
  2016-08-15  8:09 ` Johan Hedberg
  0 siblings, 2 replies; 4+ messages in thread
From: Bart Van Assche @ 2016-08-11 23:02 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: Gustavo Padovan, Johan Hedberg, linux-bluetooth

wait_on_bit_timeout() returns one of the following three values:
* 0 to indicate success.
* -EINTR to indicate that a signal has been received;
* -EAGAIN to indicate timeout;
Make the wait_on_bit_timeout() callers check for these values.
This patch has not yet been tested.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
---
 drivers/bluetooth/btusb.c     | 5 ++---
 drivers/bluetooth/hci_intel.c | 6 +++---
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index a3be65e..8df720a 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2213,9 +2213,8 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
 	err = wait_on_bit_timeout(&data->flags, BTUSB_DOWNLOADING,
 				  TASK_INTERRUPTIBLE,
 				  msecs_to_jiffies(5000));
-	if (err == 1) {
+	if (err == -EINTR) {
 		BT_ERR("%s: Firmware loading interrupted", hdev->name);
-		err = -EINTR;
 		goto done;
 	}
 
@@ -2267,7 +2266,7 @@ done:
 				  TASK_INTERRUPTIBLE,
 				  msecs_to_jiffies(1000));
 
-	if (err == 1) {
+	if (err == -EINTR) {
 		BT_ERR("%s: Device boot interrupted", hdev->name);
 		return -EINTR;
 	}
diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c
index f6f2b01..533fec3 100644
--- a/drivers/bluetooth/hci_intel.c
+++ b/drivers/bluetooth/hci_intel.c
@@ -128,7 +128,7 @@ static int intel_wait_booting(struct hci_uart *hu)
 				  TASK_INTERRUPTIBLE,
 				  msecs_to_jiffies(1000));
 
-	if (err == 1) {
+	if (err == -EINTR) {
 		bt_dev_err(hu->hdev, "Device boot interrupted");
 		return -EINTR;
 	}
@@ -151,7 +151,7 @@ static int intel_wait_lpm_transaction(struct hci_uart *hu)
 				  TASK_INTERRUPTIBLE,
 				  msecs_to_jiffies(1000));
 
-	if (err == 1) {
+	if (err == -EINTR) {
 		bt_dev_err(hu->hdev, "LPM transaction interrupted");
 		return -EINTR;
 	}
@@ -815,7 +815,7 @@ static int intel_setup(struct hci_uart *hu)
 	err = wait_on_bit_timeout(&intel->flags, STATE_DOWNLOADING,
 				  TASK_INTERRUPTIBLE,
 				  msecs_to_jiffies(5000));
-	if (err == 1) {
+	if (err == -EINTR) {
 		bt_dev_err(hdev, "Firmware loading interrupted");
 		err = -EINTR;
 		goto done;
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH, RFC] Bluetooth: btusb, hci_intel: Fix wait_on_bit_timeout() return value checks
  2016-08-11 23:02 [PATCH, RFC] Bluetooth: btusb, hci_intel: Fix wait_on_bit_timeout() return value checks Bart Van Assche
@ 2016-08-12  9:12 ` Johan Hedberg
  2016-08-12 16:17   ` Bart Van Assche
  2016-08-15  8:09 ` Johan Hedberg
  1 sibling, 1 reply; 4+ messages in thread
From: Johan Hedberg @ 2016-08-12  9:12 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Marcel Holtmann, linux-bluetooth

Hi Bart,

On Thu, Aug 11, 2016, Bart Van Assche wrote:
> wait_on_bit_timeout() returns one of the following three values:
> * 0 to indicate success.
> * -EINTR to indicate that a signal has been received;
> * -EAGAIN to indicate timeout;
> Make the wait_on_bit_timeout() callers check for these values.
> This patch has not yet been tested.
> 
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Marcel Holtmann <marcel@holtmann.org>
> Cc: Gustavo Padovan <gustavo@padovan.org>
> Cc: Johan Hedberg <johan.hedberg@gmail.com>
> ---
>  drivers/bluetooth/btusb.c     | 5 ++---
>  drivers/bluetooth/hci_intel.c | 6 +++---
>  2 files changed, 5 insertions(+), 6 deletions(-)

Good catch. It seems the API was changed not to return 1 by this commit
(which failed to update any users of of it):

  commit 68985633bccb6066bf1803e316fbc6c1f5b796d6
  Author: Peter Zijlstra <peterz@infradead.org>
  Date:   Tue Dec 1 14:04:04 2015 +0100

      sched/wait: Fix signal handling in bit wait helpers

Do you have some doubts about your fix? You put "RFC" in the subject
which usually means the author isn't completely sure about it.

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH, RFC] Bluetooth: btusb, hci_intel: Fix wait_on_bit_timeout() return value checks
  2016-08-12  9:12 ` Johan Hedberg
@ 2016-08-12 16:17   ` Bart Van Assche
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2016-08-12 16:17 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: Marcel Holtmann, linux-bluetooth

On 08/12/2016 02:12 AM, Johan Hedberg wrote:
> On Thu, Aug 11, 2016, Bart Van Assche wrote:
>> wait_on_bit_timeout() returns one of the following three values:
>> * 0 to indicate success.
>> * -EINTR to indicate that a signal has been received;
>> * -EAGAIN to indicate timeout;
>> Make the wait_on_bit_timeout() callers check for these values.
>> This patch has not yet been tested.
>>
>> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
>> Cc: Marcel Holtmann <marcel@holtmann.org>
>> Cc: Gustavo Padovan <gustavo@padovan.org>
>> Cc: Johan Hedberg <johan.hedberg@gmail.com>
>> ---
>>  drivers/bluetooth/btusb.c     | 5 ++---
>>  drivers/bluetooth/hci_intel.c | 6 +++---
>>  2 files changed, 5 insertions(+), 6 deletions(-)
>
> Good catch. It seems the API was changed not to return 1 by this commit
> (which failed to update any users of of it):
>
>   commit 68985633bccb6066bf1803e316fbc6c1f5b796d6
>   Author: Peter Zijlstra <peterz@infradead.org>
>   Date:   Tue Dec 1 14:04:04 2015 +0100
>
>       sched/wait: Fix signal handling in bit wait helpers
>
> Do you have some doubts about your fix? You put "RFC" in the subject
> which usually means the author isn't completely sure about it.

Hello Johan,

The reason I put "RFC" in the subject is because I wouldn't like this 
patch to be accepted upstream without having been tested first. 
Mentioning "RFC" makes people think twice before applying a patch. 
That's the only reason.

Bart.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH, RFC] Bluetooth: btusb, hci_intel: Fix wait_on_bit_timeout() return value checks
  2016-08-11 23:02 [PATCH, RFC] Bluetooth: btusb, hci_intel: Fix wait_on_bit_timeout() return value checks Bart Van Assche
  2016-08-12  9:12 ` Johan Hedberg
@ 2016-08-15  8:09 ` Johan Hedberg
  1 sibling, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2016-08-15  8:09 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Marcel Holtmann, linux-bluetooth

Hi Bart,

On Thu, Aug 11, 2016, Bart Van Assche wrote:
> wait_on_bit_timeout() returns one of the following three values:
> * 0 to indicate success.
> * -EINTR to indicate that a signal has been received;
> * -EAGAIN to indicate timeout;
> Make the wait_on_bit_timeout() callers check for these values.
> This patch has not yet been tested.
> 
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Marcel Holtmann <marcel@holtmann.org>
> Cc: Gustavo Padovan <gustavo@padovan.org>
> Cc: Johan Hedberg <johan.hedberg@gmail.com>
> ---
>  drivers/bluetooth/btusb.c     | 5 ++---
>  drivers/bluetooth/hci_intel.c | 6 +++---
>  2 files changed, 5 insertions(+), 6 deletions(-)

The patch has now been applied to bluetooth-next. Thanks.

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-15  8:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-11 23:02 [PATCH, RFC] Bluetooth: btusb, hci_intel: Fix wait_on_bit_timeout() return value checks Bart Van Assche
2016-08-12  9:12 ` Johan Hedberg
2016-08-12 16:17   ` Bart Van Assche
2016-08-15  8:09 ` Johan Hedberg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.