From patchwork Wed Nov 7 16:37:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 1711751 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 5897E3FD2B for ; Wed, 7 Nov 2012 16:41:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753016Ab2KGQle (ORCPT ); Wed, 7 Nov 2012 11:41:34 -0500 Received: from mail-ee0-f46.google.com ([74.125.83.46]:56378 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751657Ab2KGQh5 (ORCPT ); Wed, 7 Nov 2012 11:37:57 -0500 Received: by mail-ee0-f46.google.com with SMTP id b15so1021344eek.19 for ; Wed, 07 Nov 2012 08:37:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; bh=xpih5TOTdHR746S6JqqDcAVAAarzn7KzTsCHgh5d924=; b=jqXM8LPwwWysHBcQrV+oL68imYirGXHvZOO57+gtarA/N4HEVDVjJq7JT/vR1vIC1S 2c+8YzyZNpmh+tcouBY5nCWpechUpLuerB7wA7BIZn+BSArBpgvkjZ8LiejMeWgdy/h/ tTkqyzWdQ8I2meFyIJComiUCmZUBxCd2iKOnlv6kwtdCn1BjKqhrsFnCWdnJ1f9umHJp +rcCvkeA78+FtpyygtktkE4BO59Q/CMc7Qkdnd3KYXFZW0CZ2DjdxxDXPZAXCGQ305R0 MQMGzfvAxigpgzF3Gd8VxXYCa4kUQh97/S0uST26MXLpWq8/jNfonpSHtObkdFRz6O4T MWVA== Received: by 10.14.182.5 with SMTP id n5mr17364179eem.5.1352306275991; Wed, 07 Nov 2012 08:37:55 -0800 (PST) Received: from miniplouf.banquise.com (lan31-8-82-247-176-67.fbx.proxad.net. [82.247.176.67]) by mx.google.com with ESMTPS id a44sm64766844eeo.7.2012.11.07.08.37.54 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 07 Nov 2012 08:37:55 -0800 (PST) From: Benjamin Tissoires To: "benjamin.tissoires" , Dmitry Torokhov , Henrik Rydberg , Jiri Kosina , Stephane Chatty , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 02/13] HID: hid-input: round return value of hidinput_calc_abs_res Date: Wed, 7 Nov 2012 17:37:25 +0100 Message-Id: <1352306256-12180-3-git-send-email-benjamin.tissoires@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1352306256-12180-1-git-send-email-benjamin.tissoires@gmail.com> References: <1352306256-12180-1-git-send-email-benjamin.tissoires@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org hidinput_calc_abs_res should return the closest int in the division instead of the floor. On a device with a logical_max of 3008 and a physical_max of 255mm, previous implementation gave a resolution of 11 instead of 12. With 11, user-space computes a physical size of 273.5mm and the round_closest results gives 250.6mm. The old implementation introduced an error of 2cm in this example. Signed-off-by: Benjamin Tissoires Acked-by: Jiri Kosina --- drivers/hid/hid-input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c index f5b1d57..67044f3 100644 --- a/drivers/hid/hid-input.c +++ b/drivers/hid/hid-input.c @@ -287,7 +287,7 @@ __s32 hidinput_calc_abs_res(const struct hid_field *field, __u16 code) } /* Calculate resolution */ - return logical_extents / physical_extents; + return DIV_ROUND_CLOSEST(logical_extents, physical_extents); } EXPORT_SYMBOL_GPL(hidinput_calc_abs_res);