From patchwork Thu Jan 27 10:35:47 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 511001 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0RAaeB5011281 for ; Thu, 27 Jan 2011 10:36:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754403Ab1A0KgC (ORCPT ); Thu, 27 Jan 2011 05:36:02 -0500 Received: from 89-230.252-81.static-ip.oleane.fr ([81.252.230.89]:33440 "EHLO smtp.lii-enac.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754387Ab1A0KgB (ORCPT ); Thu, 27 Jan 2011 05:36:01 -0500 Received: from gloupti.lii-enac.fr (unknown [10.0.0.110]) by smtp.lii-enac.fr (DoorWays) with ESMTP id 5F4D495264; Thu, 27 Jan 2011 11:35:58 +0100 (CET) From: Benjamin Tissoires To: Dmitry Torokhov , Henrik Rydberg , Ping Cheng , Benjamin Tissoires , Jiri Kosina , Chris Bagwell , Rafi Rubin , Stephane Chatty , Peter Hutterer , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC 2/2] input: evdev: Add EVIOC mechanism to extract the MT slot state Date: Thu, 27 Jan 2011 11:35:47 +0100 Message-Id: <1296124547-3323-3-git-send-email-benjamin.tissoires@enac.fr> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1296124547-3323-1-git-send-email-benjamin.tissoires@enac.fr> References: <1296124547-3323-1-git-send-email-benjamin.tissoires@enac.fr> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 27 Jan 2011 10:36:46 +0000 (UTC) diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index c8471a2..a689079 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "input-compat.h" struct evdev { @@ -45,6 +46,7 @@ struct evdev_client { struct fasync_struct *fasync; struct evdev *evdev; struct list_head node; + int slot; /* used to extract MT events via EVIOC */ int bufsize; struct input_event buffer[]; }; @@ -741,7 +743,7 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, return -EINVAL; t = _IOC_NR(cmd) & ABS_MAX; - abs = dev->absinfo[t]; + abs = input_mt_get_absinfo(dev, t, client->slot); if (copy_to_user(p, &abs, min_t(size_t, size, sizeof(struct input_absinfo)))) @@ -767,9 +769,10 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd, if (size < sizeof(struct input_absinfo)) abs.resolution = 0; - /* We can't change number of reserved MT slots */ - if (t == ABS_MT_SLOT) - return -EINVAL; + if (t == ABS_MT_SLOT) { + client->slot = abs.value; + return 0; + } /* * Take event lock to ensure that we are not