linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Tissoires <benjamin.tissoires@enac.fr>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Henrik Rydberg <rydberg@euromail.se>,
	Benjamin Tissoires <benjamin.tissoires@gmail.com>,
	Jiri Kosina <jkosina@suse.cz>, Stephane Chatty <chatty@enac.fr>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Benjamin Tissoires <benjamin.tissoires@enac.fr>
Subject: [PATCH 2/3] HID: multitouch: use input_register callback
Date: Tue, 29 Nov 2011 13:13:11 +0100	[thread overview]
Message-ID: <1322568792-4432-3-git-send-email-benjamin.tissoires@enac.fr> (raw)
In-Reply-To: <1322568792-4432-1-git-send-email-benjamin.tissoires@enac.fr>

Use the input_register mechanism to avoid a race in which the device
may emit events before the slots are ready.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
---
 drivers/hid/hid-multitouch.c |   37 ++++++++++++++++++++++++-------------
 1 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 91c13bc..bd6e410 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -574,6 +574,29 @@ static void mt_set_input_mode(struct hid_device *hdev)
 	}
 }
 
+static int mt_input_register(struct hid_device *hdev,
+		struct hid_input *hidinput)
+{
+	int ret;
+	struct mt_device *td = hid_get_drvdata(hdev);
+
+	td->slots = kzalloc(td->maxcontacts * sizeof(struct mt_slot),
+				GFP_KERNEL);
+	if (!td->slots) {
+		dev_err(&hdev->dev, "cannot allocate multitouch slots\n");
+		return -ENOMEM;
+	}
+
+	ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group);
+	if (ret)
+		hid_warn(hdev,
+			 "can't create sysfs quirks attribute err: %d\n", ret);
+
+	mt_set_input_mode(hdev);
+
+	return 0;
+}
+
 static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)
 {
 	int ret, i;
@@ -610,19 +633,6 @@ 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");
-		hid_hw_stop(hdev);
-		ret = -ENOMEM;
-		goto fail;
-	}
-
-	ret = sysfs_create_group(&hdev->dev.kobj, &mt_attribute_group);
-
-	mt_set_input_mode(hdev);
-
 	return 0;
 
 fail:
@@ -843,6 +853,7 @@ static struct hid_driver mt_driver = {
 	.input_mapping = mt_input_mapping,
 	.input_mapped = mt_input_mapped,
 	.feature_mapping = mt_feature_mapping,
+	.input_register = mt_input_register,
 	.usage_table = mt_grabbed_usages,
 	.event = mt_event,
 #ifdef CONFIG_PM
-- 
1.7.4.4

  parent reply	other threads:[~2011-11-29 12:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-29 12:13 [PATCH 0/3] last merge in hid-multitouch Benjamin Tissoires
2011-11-29 12:13 ` [PATCH 1/3] HID: multitouch: merge quanta driver into hid-multitouch Benjamin Tissoires
2011-11-30 14:41   ` Jiri Kosina
2011-11-29 12:13 ` Benjamin Tissoires [this message]
2011-11-30 14:37   ` [PATCH 2/3] HID: multitouch: use input_register callback Jiri Kosina
2011-11-30 14:56     ` Benjamin Tissoires
2011-11-29 12:13 ` [PATCH 3/3] hid-multitouch: add support for new Hanvon panels Benjamin Tissoires
2011-11-30 14:41   ` Jiri Kosina
2011-11-30  0:19 ` [PATCH 0/3] last merge in hid-multitouch Henrik Rydberg
2011-11-30  8:10   ` Stéphane Chatty

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=1322568792-4432-3-git-send-email-benjamin.tissoires@enac.fr \
    --to=benjamin.tissoires@enac.fr \
    --cc=benjamin.tissoires@gmail.com \
    --cc=chatty@enac.fr \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jkosina@suse.cz \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rydberg@euromail.se \
    /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).