Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753687Ab2KMHom (ORCPT ); Tue, 13 Nov 2012 02:44:42 -0500 Received: from cantor2.suse.de ([195.135.220.15]:40338 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753250Ab2KMHol (ORCPT ); Tue, 13 Nov 2012 02:44:41 -0500 Date: Tue, 13 Nov 2012 08:44:38 +0100 (CET) From: Jiri Kosina To: Benjamin Tissoires Cc: Dmitry Torokhov , Henrik Rydberg , Stephane Chatty , linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 02/13] HID: hid-input: round return value of hidinput_calc_abs_res In-Reply-To: <1352306256-12180-3-git-send-email-benjamin.tissoires@gmail.com> Message-ID: References: <1352306256-12180-1-git-send-email-benjamin.tissoires@gmail.com> <1352306256-12180-3-git-send-email-benjamin.tissoires@gmail.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1407 Lines: 43 On Wed, 7 Nov 2012, Benjamin Tissoires wrote: > 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); > > -- > 1.7.11.7 > -- Jiri Kosina SUSE Labs -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/