From patchwork Wed Nov 14 15:59:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 1742101 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 1089340E04 for ; Wed, 14 Nov 2012 15:59:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1422766Ab2KNP7o (ORCPT ); Wed, 14 Nov 2012 10:59:44 -0500 Received: from mail-we0-f174.google.com ([74.125.82.174]:43778 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161113Ab2KNP7m (ORCPT ); Wed, 14 Nov 2012 10:59:42 -0500 Received: by mail-we0-f174.google.com with SMTP id t9so203768wey.19 for ; Wed, 14 Nov 2012 07:59:41 -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=jv9apGR9CdJT77OiljXGGCGTrl0F7NmETCkIHlai9gU=; b=kXup5s4n4TqQNRCDQFLjPbtTejexEg674hJna9SIOptspGIn7JhBzz18Tlmq+GDN2u Pb1rXzH5f0Wm+UDeaAUnwRePpXnzQk+q+RdHhcnXFgXVpvpPhe5QBVQS3oJv4hPicvNW 4fFOzHH/Gq75wHKDK6JbRvys38fRgPJuj4rUDJYPicUU68H0cPjmJybhU4iQLW85Jw2D YPVjw5Y++Pi+wH0+yKPoP4hL9LoZ/oJ4Cl9Kgyy8d+HcHHeRZ4gU0IwiIBJGD0pzfTWq APIpBWG0mgeY0scgasn6YyoLf179H3o843NbTqNQdWP+Fi134pJT6mq09GKb0ap/Go5q yYYQ== Received: by 10.180.79.37 with SMTP id g5mr26726302wix.7.1352908781678; Wed, 14 Nov 2012 07:59:41 -0800 (PST) Received: from localhost.localdomain.com (lan31-8-82-247-176-67.fbx.proxad.net. [82.247.176.67]) by mx.google.com with ESMTPS id r10sm3050116wiz.0.2012.11.14.07.59.39 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 14 Nov 2012 07:59:40 -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 v4 02/14] HID: hid-input: round return value of hidinput_calc_abs_res Date: Wed, 14 Nov 2012 16:59:14 +0100 Message-Id: <1352908766-4492-3-git-send-email-benjamin.tissoires@gmail.com> X-Mailer: git-send-email 1.8.0 In-Reply-To: <1352908766-4492-1-git-send-email-benjamin.tissoires@gmail.com> References: <1352908766-4492-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);