From: Michael Poole <mdpoole-IZmAEv5cUt1AfugRpC6u6w@public.gmane.org>
To: Dmitry Torokhov
<dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: Jiri Kosina <jkosina-AlSwsSmVLrQ@public.gmane.org>,
linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Marcel Holtmann <marcel-kz+m5ild9QBg9hUCZPvPmw@public.gmane.org>,
linux-bluetooth-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH 2/2] Add a device driver for the Apple Magic Mouse.
Date: Wed, 10 Feb 2010 15:31:16 -0500 [thread overview]
Message-ID: <87d40cestn.fsf@troilus.org> (raw)
In-Reply-To: <20100210182024.GA29610-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org> (Dmitry Torokhov's message of "Wed, 10 Feb 2010 10:20:24 -0800")
I'll post a patch for these based on Jiri's for-next tree this evening.
Dmitry Torokhov writes:
> Hi Michael,
>
> On Tue, Feb 09, 2010 at 08:13:08AM -0500, Michael Poole wrote:
>> +
>> +static bool emulate_3button = 1;
>
> If it is a bool then values should be true/false.
Thanks.
>> +module_param(emulate_3button, bool, 0644);
>> +MODULE_PARM_DESC(emulate_3button, "Emulate a middle button");
>> +
>> +static int middle_button_start = -350;
>> +static int middle_button_stop = +350;
>> +
>> +static bool emulate_scroll_wheel = 1;
>> +module_param(emulate_scroll_wheel, bool, 0644);
>> +MODULE_PARM_DESC(emulate_scroll_wheel, "Emulate a scroll wheel");
>> +
>> +static bool report_touches = 1;
>> +module_param(report_touches, bool, 0644);
>> +MODULE_PARM_DESC(report_touches, "Emit touch records (otherwise, only use them for emulation)");
>> +
>> +static bool report_undeciphered = 0;
>
> No need to initialize statics to 0/false.
Okay, I'll remote that.
[snip]
>> + int last_state = test_bit(BTN_LEFT, msc->input->key) << 0 |
>> + test_bit(BTN_RIGHT, msc->input->key) << 1 |
>> + test_bit(BTN_MIDDLE, msc->input->key) << 2;
>
> Indented with spaces, we prefer tabs.
Whoops -- one of my machines must be misconfigured. I'll fix that.
[snip]
>> + if (report_undeciphered) {
>> + input_event(input, EV_MSC, MSC_RAW, tdata[7]);
>> + }
>
> No need for braces for single statement.
Okay.
[snip]
>> + if (emulate_scroll_wheel)
>> + set_bit(REL_WHEEL, input->relbit);
>
> I'd use __set_bit() instead, no need to lock the bus.
Okay. I wasn't aware of that semantic difference.
>> +
>> + if (report_touches) {
>> + set_bit(EV_ABS, input->evbit);
>> +
>> + set_bit(ABS_MT_TRACKING_ID, input->absbit);
>> + input->absmin[ABS_MT_TRACKING_ID] = 0;
>> + input->absmax[ABS_MT_TRACKING_ID] = 15;
>> + input->absfuzz[ABS_MT_TRACKING_ID] = 0;
>
> input_set_abs_params() is a bit more compact.
Thanks -- more idiomatic is always handy.
[snip]
>> + ret = hdev->hid_output_raw_report(hdev, feature_1, sizeof(feature_1),
>> + HID_FEATURE_REPORT);
>
> This will cause transmission of on-stack data through USB which it does
> not like.
Current Magic Mouse devices are Bluetooth-only. Is this an issue for
that stack as well? (hid-sony.c and hid-wacom.c also use
hid_output_raw_report() with on-stack buffers for Bluetooth devices --
if they need it too, I can write a patch for those. I have a PS3
controller that I can test with, but don't have a Wacom tablet.) Would
making those buffers static put them in an appropriate section, or does
the memory need to be allocated from a heap?
>> + if (ret != sizeof(feature_1)) {
>> + dev_err(&hdev->dev, "unable to request touch data (1:%d)\n",
>> + ret);
>> + goto err_free;
>> + }
>> + ret = hdev->hid_output_raw_report(hdev, feature_2,
>> + sizeof(feature_2), HID_FEATURE_REPORT);
>
> Same here.
>
>> + if (ret != sizeof(feature_2)) {
>> + dev_err(&hdev->dev, "unable to request touch data (2:%d)\n",
>> + ret);
>> + goto err_free;
>> + }
>> +
>> + input = input_allocate_device();
>> + if (!input) {
>> + dev_err(&hdev->dev, "can't alloc input device\n");
>> + ret = -ENOMEM;
>> + goto err_free;
>> + }
>> + magicmouse_setup_input(input, hdev);
>> +
>> + ret = input_register_device(input);
>> + if (ret) {
>> + dev_err(&hdev->dev, "input device registration failed\n");
>> + goto err_both;
>> + }
>> + msc->input = input;
>> +
>> + return 0;
>> + err_both:
>> + input_free_device(input);
>> + err_free:
>> + kfree(msc);
>> + return ret;
>
> hid_hw_stop() is missing in error path. Also see question about freeing
> report below.
Thanks, I'll add the hid_hw_stop().
>> +}
>> +
>> +static void magicmouse_remove(struct hid_device *hdev)
>> +{
>
> Do we need to unregister report (I am not that familiar with HID, who is
> responsible for cleaning report lists?)?
hid-core.c's hid_device_release() frees all the reports that registered
with hid_register_report().
Michael Poole
next prev parent reply other threads:[~2010-02-10 20:31 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <alpine.LNX.2.00.1001291515560.356@pobox.suse.cz>
[not found] ` <dd18b0c31002082322m4238a4a6m73fc30752ba30447@mail.gmail.com>
[not found] ` <1265710460.2383.5685.camel@localhost.localdomain>
[not found] ` <201002090736.55576.edt@aei.ca>
[not found] ` <alpine.LNX.2.00.1002091339190.30967@pobox.suse.cz>
[not found] ` <alpine.LNX.2.00.1002091339190.30967-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2010-02-09 13:10 ` [PATCH 0/2] Provide a driver for the Apple Magic Mouse Michael Poole
2010-02-09 13:13 ` [PATCH 2/2] Add a device " Michael Poole
[not found] ` <87pr4eeemz.fsf_-_-IZmAEv5cUt1AfugRpC6u6w@public.gmane.org>
2010-02-10 13:06 ` Jiri Kosina
[not found] ` <alpine.LNX.2.00.1002101404210.30967-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2010-02-10 13:58 ` Jiri Kosina
2010-02-11 3:05 ` Ed Tomlinson
[not found] ` <201002102205.58967.edt-Yad3+ZauZac@public.gmane.org>
2010-02-11 3:20 ` Michael Poole
2010-02-11 12:51 ` [PATCH 2/2] Add a device driver for the Apple Magic Mouse (2.6.32.8) Ed Tomlinson
2010-02-10 18:20 ` [PATCH 2/2] Add a device driver for the Apple Magic Mouse Dmitry Torokhov
[not found] ` <20100210182024.GA29610-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2010-02-10 20:31 ` Michael Poole [this message]
2010-02-11 5:32 ` [PATCH] hid-magicmouse: Coding style and probe failure fixes Michael Poole
[not found] ` <873a18e3qu.fsf_-_-IZmAEv5cUt1AfugRpC6u6w@public.gmane.org>
2010-02-11 6:55 ` Dmitry Torokhov
2010-02-11 10:26 ` Jiri Kosina
2010-02-11 23:10 ` Michael Poole
[not found] ` <87y6j2eeqv.fsf_-_-IZmAEv5cUt1AfugRpC6u6w@public.gmane.org>
2010-02-09 13:11 ` [PATCH 1/2] Provide a driver for the Apple Magic Mouse Michael Poole
2010-02-09 21:37 ` [PATCH 0/2] " Justin P. Mattock
2010-02-10 13:57 ` Jiri Kosina
2010-02-13 19:29 ` [PATCH 0/2] Provide a driver for the Apple Magic Mouse - opps Ed Tomlinson
2010-02-14 8:03 ` Dmitry Torokhov
[not found] ` <20100214080344.GA4423-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2010-02-14 14:22 ` Ed Tomlinson
2010-02-15 7:11 ` Dmitry Torokhov
[not found] ` <20100215071145.GA9135-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2010-02-15 12:42 ` Ed Tomlinson
2010-02-15 12:44 ` Ed Tomlinson
2010-02-16 12:57 ` Jiri Kosina
2010-02-16 12:34 ` Ed Tomlinson
2010-02-16 12:55 ` Jiri Kosina
[not found] ` <alpine.LNX.2.00.1002101456490.30967-ztGlSCb7Y1iN3ZZ/Hiejyg@public.gmane.org>
2010-02-14 22:24 ` [PATCH 1/1] Enable xy scrolling for Apple Magic Mouse Ed Tomlinson
2010-02-14 22:51 ` Michael Poole
[not found] ` <87zl3bbfdo.fsf-IZmAEv5cUt1AfugRpC6u6w@public.gmane.org>
2010-02-14 23:58 ` Ed Tomlinson
2010-02-15 7:18 ` Dmitry Torokhov
[not found] ` <20100215071850.GB9135-WlK9ik9hQGAhIp7JRqBPierSzoNAToWh@public.gmane.org>
2010-02-15 12:50 ` Ed Tomlinson
2010-02-15 0:18 ` Ed Tomlinson
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=87d40cestn.fsf@troilus.org \
--to=mdpoole-izmaev5cut1afugrpc6u6w@public.gmane.org \
--cc=dmitry.torokhov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=jkosina-AlSwsSmVLrQ@public.gmane.org \
--cc=linux-bluetooth-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-input-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=marcel-kz+m5ild9QBg9hUCZPvPmw@public.gmane.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).