From patchwork Sat Sep 5 17:25:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 7129481 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 83BDEBEEC1 for ; Sat, 5 Sep 2015 17:26:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 70442208C0 for ; Sat, 5 Sep 2015 17:26:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1BA79208B7 for ; Sat, 5 Sep 2015 17:26:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752073AbbIERZr (ORCPT ); Sat, 5 Sep 2015 13:25:47 -0400 Received: from mail-pa0-f50.google.com ([209.85.220.50]:32870 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751798AbbIERZr (ORCPT ); Sat, 5 Sep 2015 13:25:47 -0400 Received: by pacex6 with SMTP id ex6so53927315pac.0; Sat, 05 Sep 2015 10:25:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=2sJ56qZRmeIE/lytTVcqjhIhDFpNlxZu/SQeJ3bEMa0=; b=odnA7PmLhhniBoVy1nb1BytN3gLmxa+040oycdE5KBi+BzM4P6SoXXNPJoU7L5bKMZ JA7bvRGp5jFuzbnwzj+AE54qb+1r/domedL/IM6TWcok9es2J3uGVLf8QjMxQ0yJKsts TXFlAlzkR8rPQQXUmNMmFR5Upf0g3QkRd4gnO/iZD6FCCRSYC4vnFV9TBLBtt04BQAKN 3vwyZn+4f8q4EFshAjo/eMee+PGeGcnvHjA68Uu6qNvgeglqSrzgwOzTwc6R3RW6ybjp KWe34Cf5V9EZ2sgDEI2FI4Do2imSvtHPGaeKcwh7/uS2UOqdaQfBYErvLg3QfAAjxV5J CYNg== X-Received: by 10.66.139.133 with SMTP id qy5mr23221208pab.44.1441473946413; Sat, 05 Sep 2015 10:25:46 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1301:fd0c:9982:9e07:7649]) by smtp.gmail.com with ESMTPSA id kr1sm6405504pbc.93.2015.09.05.10.25.45 (version=TLS1_2 cipher=AES128-SHA256 bits=128/128); Sat, 05 Sep 2015 10:25:45 -0700 (PDT) Date: Sat, 5 Sep 2015 10:25:43 -0700 From: Dmitry Torokhov To: linux-input@vger.kernel.org Cc: Joe Perches , John Stultz , Peter Popovec , linux-kernel@vger.kernel.org Subject: [PATCH] Input: walkera0701 - fix abs() calculations on 64 bit values Message-ID: <20150905172543.GA23438@dtor-ws> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 abs() function can not be used with 64 bit values, so let's switch to abs64(). From include/linux/kernel.h: /* * abs() handles unsigned and signed longs, ints, shorts and chars. * For all input types abs() returns a signed long. * abs() should not be used for 64-bit types (s64, u64, long long) * - use abs64() for those. */ Reported-by: Joe Perches Signed-off-by: Dmitry Torokhov --- drivers/input/joystick/walkera0701.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/input/joystick/walkera0701.c b/drivers/input/joystick/walkera0701.c index b76ac58..a8bc2fe 100644 --- a/drivers/input/joystick/walkera0701.c +++ b/drivers/input/joystick/walkera0701.c @@ -150,7 +150,7 @@ static void walkera0701_irq_handler(void *handler_data) if (w->counter == 24) { /* full frame */ walkera0701_parse_frame(w); w->counter = NO_SYNC; - if (abs(pulse_time - SYNC_PULSE) < RESERVE) /* new frame sync */ + if (abs64(pulse_time - SYNC_PULSE) < RESERVE) /* new frame sync */ w->counter = 0; } else { if ((pulse_time > (ANALOG_MIN_PULSE - RESERVE) @@ -161,7 +161,7 @@ static void walkera0701_irq_handler(void *handler_data) } else w->counter = NO_SYNC; } - } else if (abs(pulse_time - SYNC_PULSE - BIN0_PULSE) < + } else if (abs64(pulse_time - SYNC_PULSE - BIN0_PULSE) < RESERVE + BIN1_PULSE - BIN0_PULSE) /* frame sync .. */ w->counter = 0;