* [PATCH] [input] Set up uinput device again, if it was previously closed.
@ 2012-03-05 3:44 Jeff Hansen
2012-03-05 5:11 ` Johan Hedberg
0 siblings, 1 reply; 2+ messages in thread
From: Jeff Hansen @ 2012-03-05 3:44 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Marcel Holtmann, Jeff Hansen
If you connect a PS3 controller to bluetoothd as an input device, then
take the batteries out of a PS3 controller, then put them back in and
push a few buttons, it will eventually cause an error which causes the
uinput socket to be closed. It will then re-connect to bluetoothd, but
the uinput socket fd will be -1, so it needs to be set up again after
the re-connect.
Signed-off-by: Jeff Hansen <x@jeffhansen.com>
---
input/fakehid.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/input/fakehid.c b/input/fakehid.c
index eebca05..a83f8c3 100644
--- a/input/fakehid.c
+++ b/input/fakehid.c
@@ -393,12 +393,15 @@ struct fake_input *fake_hid_connadd(struct fake_input *fake,
/* New device? Add it to the list of known devices,
* and create the uinput necessary */
- if (old == NULL) {
+ if (old == NULL || old->uinput == -1) {
if (fake_hid->setup_uinput(fake, fake_hid)) {
error("Error setting up uinput");
g_free(fake);
return NULL;
}
+ }
+
+ if (old == NULL) {
fake_hid->devices = g_list_append(fake_hid->devices, fake);
}
--
1.7.3.4
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] [input] Set up uinput device again, if it was previously closed.
2012-03-05 3:44 [PATCH] [input] Set up uinput device again, if it was previously closed Jeff Hansen
@ 2012-03-05 5:11 ` Johan Hedberg
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2012-03-05 5:11 UTC (permalink / raw)
To: Jeff Hansen; +Cc: linux-bluetooth, Marcel Holtmann
Hi Jeff,
On Sun, Mar 04, 2012, Jeff Hansen wrote:
> If you connect a PS3 controller to bluetoothd as an input device, then
> take the batteries out of a PS3 controller, then put them back in and
> push a few buttons, it will eventually cause an error which causes the
> uinput socket to be closed. It will then re-connect to bluetoothd, but
> the uinput socket fd will be -1, so it needs to be set up again after
> the re-connect.
>
> Signed-off-by: Jeff Hansen <x@jeffhansen.com>
> ---
> input/fakehid.c | 5 ++++-
> 1 files changed, 4 insertions(+), 1 deletions(-)
Thanks, the patch has been pushed upstream but there were a few minor
fixes I had to do before that. Firstly, we don't use signed-off-by for
user space patches. Then, a few stylistic issues with the code:
> + if (old == NULL || old->uinput == -1) {
We usually use < 0 for testing for an invalid fd.
> + if (old == NULL) {
> fake_hid->devices = g_list_append(fake_hid->devices, fake);
> }
Single-line branches do not need { }
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-03-05 5:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-05 3:44 [PATCH] [input] Set up uinput device again, if it was previously closed Jeff Hansen
2012-03-05 5:11 ` Johan Hedberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).