From patchwork Mon Jul 15 13:37:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 2827521 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4E0CBC0AB2 for ; Mon, 15 Jul 2013 13:37:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 04BFF2018F for ; Mon, 15 Jul 2013 13:37:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 85ED12018B for ; Mon, 15 Jul 2013 13:37:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756791Ab3GONhR (ORCPT ); Mon, 15 Jul 2013 09:37:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35772 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756323Ab3GONhQ (ORCPT ); Mon, 15 Jul 2013 09:37:16 -0400 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r6FDbEqd004462 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 15 Jul 2013 09:37:14 -0400 Received: from t410.redhat.com (ovpn-116-94.ams2.redhat.com [10.36.116.94]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r6FDbCgZ031219; Mon, 15 Jul 2013 09:37:13 -0400 From: Benjamin Tissoires To: Dmitry Torokhov , Benjamin Tissoires , Peter Hutterer , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] input/uinput: support abs resolution Date: Mon, 15 Jul 2013 15:37:08 +0200 Message-Id: <1373895429-8846-1-git-send-email-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Hutterer Input resolution has been added in kernel v2.6.31 with commit ec20a022aa24fc63. However, uinput was never updated since, meaning that devices cannot be emulated in full. User-space processes that rely on the resolution to be accurate need this. Resolution is added in struct uinput_user_dev in a way it won't break current programs relying on the old implementation. Bump the UINPUT_VERSION number to 4 to aid detection of this in user-space. Signed-off-by: Peter Hutterer Signed-off-by: Benjamin Tissoires --- Sorry for that, I mixed up the "From:" field. This v2 contains the right From in the first patch , and this is the only difference... Cheers, Benjamin drivers/input/misc/uinput.c | 17 ++++++++++++----- include/linux/uinput.h | 2 ++ include/uapi/linux/uinput.h | 3 +++ 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index a0a4bba..7d518b4 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c @@ -20,6 +20,8 @@ * Author: Aristeu Sergio Rozanski Filho * * Changes/Revisions: + * 0.4 12/07/2013 (Peter Hutterer ) + * - update uinput_user_dev struct to allow abs resolution * 0.3 09/04/2006 (Anssi Hannula ) * - updated ff support for the changes in kernel interface * - added MODULE_VERSION @@ -364,9 +366,9 @@ static int uinput_setup_device(struct uinput_device *udev, struct input_dev *dev; int i; int retval; + size_t size; - if (count != sizeof(struct uinput_user_dev)) - return -EINVAL; + size = min_t(size_t, count, sizeof(struct uinput_user_dev)); if (!udev->dev) { retval = uinput_allocate_device(udev); @@ -376,9 +378,13 @@ static int uinput_setup_device(struct uinput_device *udev, dev = udev->dev; - user_dev = memdup_user(buffer, sizeof(struct uinput_user_dev)); - if (IS_ERR(user_dev)) - return PTR_ERR(user_dev); + user_dev = kzalloc(sizeof(struct uinput_user_dev), GFP_KERNEL); + if (!user_dev) + return -ENOMEM; + if (copy_from_user(user_dev, buffer, size)) { + retval = -EFAULT; + goto exit; + } udev->ff_effects_max = user_dev->ff_effects_max; @@ -406,6 +412,7 @@ static int uinput_setup_device(struct uinput_device *udev, input_abs_set_min(dev, i, user_dev->absmin[i]); input_abs_set_fuzz(dev, i, user_dev->absfuzz[i]); input_abs_set_flat(dev, i, user_dev->absflat[i]); + input_abs_set_res(dev, i, user_dev->absres[i]); } /* check if absmin/absmax/absfuzz/absflat are filled as diff --git a/include/linux/uinput.h b/include/linux/uinput.h index 0a4487d..6291a22 100644 --- a/include/linux/uinput.h +++ b/include/linux/uinput.h @@ -20,6 +20,8 @@ * Author: Aristeu Sergio Rozanski Filho * * Changes/Revisions: + * 0.4 12/07/2013 (Peter Hutterer ) + * - update uinput_user_dev struct to allow abs resolution * 0.3 24/05/2006 (Anssi Hannula ) * - update ff support for the changes in kernel interface * - add UINPUT_VERSION diff --git a/include/uapi/linux/uinput.h b/include/uapi/linux/uinput.h index fe46431..f6a393b 100644 --- a/include/uapi/linux/uinput.h +++ b/include/uapi/linux/uinput.h @@ -20,6 +20,8 @@ * Author: Aristeu Sergio Rozanski Filho * * Changes/Revisions: + * 0.4 12/07/2013 (Peter Hutterer ) + * - update uinput_user_dev struct to allow abs resolution * 0.3 24/05/2006 (Anssi Hannula ) * - update ff support for the changes in kernel interface * - add UINPUT_VERSION @@ -133,5 +135,6 @@ struct uinput_user_dev { __s32 absmin[ABS_CNT]; __s32 absfuzz[ABS_CNT]; __s32 absflat[ABS_CNT]; + __s32 absres[ABS_CNT]; }; #endif /* _UAPI__UINPUT_H_ */