From: "Henrik Rydberg" <rydberg@euromail.se>
To: Benjamin Tissoires <benjamin.tissoires@enac.fr>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Jiri Kosina <jkosina@suse.cz>,
Stephane Chatty <chatty@lii-enac.fr>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/4] hid-multitouch: Auto detection of maxcontacts
Date: Thu, 10 Mar 2011 13:45:30 +0100 [thread overview]
Message-ID: <20110310124530.GA3378@polaris.bitmath.org> (raw)
In-Reply-To: <1299686450-5475-2-git-send-email-benjamin.tissoires@enac.fr>
Hi Benjamin,
thanks for this, just a couple of things...
> @@ -126,9 +127,19 @@ struct mt_class mt_classes[] = {
> static void mt_feature_mapping(struct hid_device *hdev,
> struct hid_field *field, struct hid_usage *usage)
> {
> - if (usage->hid == HID_DG_INPUTMODE) {
> - struct mt_device *td = hid_get_drvdata(hdev);
> + struct mt_device *td = hid_get_drvdata(hdev);
> +
> + switch (usage->hid) {
> + case HID_DG_INPUTMODE:
> td->inputmode = field->report->id;
> + break;
> + case HID_DG_CONTACTMAX:
> + td->maxcontacts = *(field->value);
field->value[0] seems more standard-ish
> + if (td->mtclass->maxcontacts > td->maxcontacts)
> + /* check if the maxcontacts is given by the class */
> + td->maxcontacts = td->mtclass->maxcontacts;
> +
> + break;
> }
> }
>
> @@ -317,7 +327,7 @@ static int mt_event(struct hid_device *hid, struct hid_field *field,
> struct mt_device *td = hid_get_drvdata(hid);
> __s32 quirks = td->mtclass->quirks;
>
> - if (hid->claimed & HID_CLAIMED_INPUT) {
> + if (hid->claimed & HID_CLAIMED_INPUT && td->slots) {
The extra test could in principle be placed after the usage switch, which would prevent partially filled contact data, should this ever occur. Something like
if (!td->slots)
break;
> switch (usage->hid) {
> case HID_DG_INRANGE:
> if (quirks & MT_QUIRK_VALID_IS_INRANGE)
> @@ -415,9 +425,7 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
> */
> hdev->quirks |= HID_QUIRK_NO_INPUT_SYNC;
>
> - td = kzalloc(sizeof(struct mt_device) +
> - mtclass->maxcontacts * sizeof(struct mt_slot),
> - GFP_KERNEL);
> + td = kzalloc(sizeof(struct mt_device), GFP_KERNEL);
> if (!td) {
> dev_err(&hdev->dev, "cannot allocate multitouch data\n");
> return -ENOMEM;
> @@ -434,6 +442,14 @@ static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
> if (ret)
> goto fail;
>
> + td->slots = kzalloc(td->maxcontacts * sizeof(struct mt_slot),
> + GFP_KERNEL);
> + if (!td->slots) {
> + dev_err(&hdev->dev, "cannot allocate multitouch slots\n");
> + ret = -ENOMEM;
> + goto fail;
This exit leaves the device running.
> + }
> +
> mt_set_input_mode(hdev);
>
> return 0;
> @@ -455,6 +471,7 @@ static void mt_remove(struct hid_device *hdev)
> {
> struct mt_device *td = hid_get_drvdata(hdev);
> hid_hw_stop(hdev);
> + kfree(td->slots);
> kfree(td);
> hid_set_drvdata(hdev, NULL);
> }
> --
> 1.7.4
>
Thanks,
Henrik
next prev parent reply other threads:[~2011-03-10 12:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-09 16:00 [PATCH 0/4] Migrations to hid-multitouch, round 2 Benjamin Tissoires
2011-03-09 16:00 ` [PATCH v2 1/4] hid-multitouch: Auto detection of maxcontacts Benjamin Tissoires
2011-03-10 12:45 ` Henrik Rydberg [this message]
2011-03-11 7:07 ` Benjamin Tissoires
2011-03-09 16:00 ` [PATCH v2 2/4] hid-multitouch: migrate support for Stantum panels to the unified driver Benjamin Tissoires
2011-03-09 16:00 ` [PATCH v2 3/4] hid-multitouch: migrate Cando dual touch panels to hid-multitouch Benjamin Tissoires
2011-03-09 16:00 ` [PATCH v2 4/4] hid-multitouch: migrate 3M PCT touch screens " Benjamin Tissoires
2011-03-10 15:52 ` Henrik Rydberg
2011-03-11 7:26 ` Benjamin Tissoires
2011-03-11 11:07 ` Henrik Rydberg
2011-03-14 12:08 ` [PATCH 0/4] Migrations to hid-multitouch, round 2 Jiri Kosina
2011-03-14 13:10 ` Benjamin Tissoires
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=20110310124530.GA3378@polaris.bitmath.org \
--to=rydberg@euromail.se \
--cc=benjamin.tissoires@enac.fr \
--cc=chatty@lii-enac.fr \
--cc=dmitry.torokhov@gmail.com \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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
Powered by JetHome