From: Jaikumar Ganesh <jaikumarg@gmail.com>
To: Jaikumar Ganesh <jaikumarg@android.com>
Cc: linux-input@vger.kernel.org, mdpoole@troilus.org
Subject: Re: [PATCH] HID: magicmouse: Fix race in input mapping.
Date: Tue, 20 Sep 2011 13:58:53 -0700 [thread overview]
Message-ID: <CACMz=xi2SCmTU9=n4jjj2=J4K2Re1s5yZvSYCv1_LYE_j50EqA@mail.gmail.com> (raw)
In-Reply-To: <1316211154-9436-1-git-send-email-jaikumarg@android.com>
Hello
On Fri, Sep 16, 2011 at 3:12 PM, Jaikumar Ganesh <jaikumarg@android.com> wrote:
> magicmouse_select_input was being called after device
> registration. Hence, any thread scanning "/dev" for new
> devices will see the input bits change on an open file
> descriptor. Fix this by calling select_input inside
> input_mapping.
>
> Based on discussions with Michael Poole <mdpoole@troilus.org>
>
> Change-Id: I289a37a850977c2cbbc9eb76fbf6c9a28d1833c5
> Signed-off-by: Jaikumar Ganesh <jaikumarg@android.com>
> ---
> drivers/hid/hid-magicmouse.c | 13 +++++++------
> 1 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/hid/hid-magicmouse.c b/drivers/hid/hid-magicmouse.c
> index 56d0539..1175452 100644
> --- a/drivers/hid/hid-magicmouse.c
> +++ b/drivers/hid/hid-magicmouse.c
> @@ -98,6 +98,7 @@ struct magicmouse_sc {
> int ntouches;
> int scroll_accel;
> unsigned long scroll_jiffies;
> + bool setup_input;
>
> struct {
> short x;
> @@ -437,6 +438,11 @@ static int magicmouse_input_mapping(struct hid_device *hdev,
> if (!msc->input)
> msc->input = hi->input;
>
> + if (!msc->setup_input) {
> + magicmouse_setup_input(msc->input, hdev);
> + msc->setup_input = true;
> + }
> +
> /* Magic Trackpad does not give relative data after switching to MT */
> if (hi->input->id.product == USB_DEVICE_ID_APPLE_MAGICTRACKPAD &&
> field->flags & HID_MAIN_ITEM_RELATIVE)
> @@ -465,6 +471,7 @@ static int magicmouse_probe(struct hid_device *hdev,
> hid_set_drvdata(hdev, msc);
>
> msc->single_touch_id = NO_TOUCHES;
> + msc->setup_input = false;
>
> ret = hid_parse(hdev);
> if (ret) {
> @@ -478,12 +485,6 @@ static int magicmouse_probe(struct hid_device *hdev,
> goto err_free;
> }
>
> - /* We do this after hid-input is done parsing reports so that
> - * hid-input uses the most natural button and axis IDs.
> - */
> - if (msc->input)
> - magicmouse_setup_input(msc->input, hdev);
> -
> if (id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE)
> report = hid_register_report(hdev, HID_INPUT_REPORT,
> MOUSE_REPORT_ID);
> --
> 1.7.3.1
>
Ping for review.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-09-20 20:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-16 22:12 [PATCH] HID: magicmouse: Fix race in input mapping Jaikumar Ganesh
2011-09-20 20:58 ` Jaikumar Ganesh [this message]
2011-09-20 22:43 ` David Herrmann
2011-09-20 22:57 ` Jaikumar Ganesh
2011-09-21 0:14 ` Jaikumar Ganesh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACMz=xi2SCmTU9=n4jjj2=J4K2Re1s5yZvSYCv1_LYE_j50EqA@mail.gmail.com' \
--to=jaikumarg@gmail.com \
--cc=jaikumarg@android.com \
--cc=linux-input@vger.kernel.org \
--cc=mdpoole@troilus.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).