* [PATCH v2] hidp: Make hidp_get_raw_report abort if the session is terminating.
@ 2013-02-20 18:16 Karl Relton
2013-02-21 8:42 ` Karl Relton
2013-02-26 19:30 ` Gustavo Padovan
0 siblings, 2 replies; 3+ messages in thread
From: Karl Relton @ 2013-02-20 18:16 UTC (permalink / raw)
To: linux-bluetooth
Cc: dh.herrmann, Marcel Holtmann, Gustavo Padovan, Johan Hedberg
From: Karl Relton <karllinuxtest.relton@ntlworld.com>
After linux 3.2 the hid_destroy_device call in hidp_session
cleaning up invokes a hook to the power_supply code which
in turn tries to read the battery capacity. This read will
trigger a call to hidp_get_raw_report which is bound to fail
because the device is being taken away - so rather than
wait for the 5 second timeout failure this changes enables
it to fail straight away.
Signed-off-by: Karl Relton <karllinuxtest.relton@ntlworld.com>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
---
net/bluetooth/hidp/core.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index b2bcbe2..4b26ea7 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -311,6 +311,9 @@ static int hidp_get_raw_report(struct hid_device *hid,
int numbered_reports = hid->report_enum[report_type].numbered;
int ret;
+ if (atomic_read(&session->terminate))
+ return -EIO;
+
switch (report_type) {
case HID_FEATURE_REPORT:
report_type = HIDP_TRANS_GET_REPORT | HIDP_DATA_RTYPE_FEATURE;
@@ -722,6 +725,7 @@ static int hidp_session(void *arg)
set_current_state(TASK_INTERRUPTIBLE);
}
set_current_state(TASK_RUNNING);
+ atomic_inc(&session->terminate);
remove_wait_queue(sk_sleep(intr_sk), &intr_wait);
remove_wait_queue(sk_sleep(ctrl_sk), &ctrl_wait);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] hidp: Make hidp_get_raw_report abort if the session is terminating.
2013-02-20 18:16 [PATCH v2] hidp: Make hidp_get_raw_report abort if the session is terminating Karl Relton
@ 2013-02-21 8:42 ` Karl Relton
2013-02-26 19:30 ` Gustavo Padovan
1 sibling, 0 replies; 3+ messages in thread
From: Karl Relton @ 2013-02-21 8:42 UTC (permalink / raw)
To: linux-bluetooth
Cc: dh.herrmann, Marcel Holtmann, Gustavo Padovan, Johan Hedberg
On Wed, 2013-02-20 at 18:16 +0000, Karl Relton wrote:
> From: Karl Relton <karllinuxtest.relton@ntlworld.com>
>
> After linux 3.2 the hid_destroy_device call in hidp_session
> cleaning up invokes a hook to the power_supply code which
> in turn tries to read the battery capacity. This read will
> trigger a call to hidp_get_raw_report which is bound to fail
> because the device is being taken away - so rather than
> wait for the 5 second timeout failure this changes enables
> it to fail straight away.
>
> Signed-off-by: Karl Relton <karllinuxtest.relton@ntlworld.com>
> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
> ---
> net/bluetooth/hidp/core.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
> index b2bcbe2..4b26ea7 100644
> --- a/net/bluetooth/hidp/core.c
> +++ b/net/bluetooth/hidp/core.c
> @@ -311,6 +311,9 @@ static int hidp_get_raw_report(struct hid_device *hid,
> int numbered_reports = hid->report_enum[report_type].numbered;
> int ret;
>
> + if (atomic_read(&session->terminate))
> + return -EIO;
> +
> switch (report_type) {
Actually I've just realised that hidp_get_raw_report calls
__hidp_send_ctrl_message which already has the session->terminate test,
also returning -EIO on failure. So adding it again here is redundant.
> @@ -722,6 +725,7 @@ static int hidp_session(void *arg)
> set_current_state(TASK_INTERRUPTIBLE);
> }
> set_current_state(TASK_RUNNING);
> + atomic_inc(&session->terminate);
> remove_wait_queue(sk_sleep(intr_sk), &intr_wait);
> remove_wait_queue(sk_sleep(ctrl_sk), &ctrl_wait);
>
So its just this one single line we need - to ensure session->terminate
is non-zero, which will ensure calls to other things (like
hidp_get_raw_report) abort swiftly.
I'll change the patch and send v3 this evening (need to get back to the
day job!).
Karl
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] hidp: Make hidp_get_raw_report abort if the session is terminating.
2013-02-20 18:16 [PATCH v2] hidp: Make hidp_get_raw_report abort if the session is terminating Karl Relton
2013-02-21 8:42 ` Karl Relton
@ 2013-02-26 19:30 ` Gustavo Padovan
1 sibling, 0 replies; 3+ messages in thread
From: Gustavo Padovan @ 2013-02-26 19:30 UTC (permalink / raw)
To: Karl Relton; +Cc: linux-bluetooth, dh.herrmann, Marcel Holtmann, Johan Hedberg
Hi Karl,
* Karl Relton <karllinuxtest.relton@ntlworld.com> [2013-02-20 18:16:19 +0000]:
> From: Karl Relton <karllinuxtest.relton@ntlworld.com>
>
> After linux 3.2 the hid_destroy_device call in hidp_session
> cleaning up invokes a hook to the power_supply code which
> in turn tries to read the battery capacity. This read will
> trigger a call to hidp_get_raw_report which is bound to fail
> because the device is being taken away - so rather than
> wait for the 5 second timeout failure this changes enables
> it to fail straight away.
>
> Signed-off-by: Karl Relton <karllinuxtest.relton@ntlworld.com>
> Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
> ---
> net/bluetooth/hidp/core.c | 4 ++++
> 1 file changed, 4 insertions(+)
Patch has been applied to bluetooth-next. Thanks.
Gustavo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-02-26 19:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-20 18:16 [PATCH v2] hidp: Make hidp_get_raw_report abort if the session is terminating Karl Relton
2013-02-21 8:42 ` Karl Relton
2013-02-26 19:30 ` Gustavo Padovan
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.