From patchwork Fri Jan 23 12:29:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kepplinger-Novakovic X-Patchwork-Id: 5693561 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 DB717C058D for ; Fri, 23 Jan 2015 12:30:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 10AEC20154 for ; Fri, 23 Jan 2015 12:30:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 27B642012B for ; Fri, 23 Jan 2015 12:29:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750911AbbAWM36 (ORCPT ); Fri, 23 Jan 2015 07:29:58 -0500 Received: from mx02.posteo.de ([89.146.194.165]:55067 "EHLO mx02.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750902AbbAWM35 (ORCPT ); Fri, 23 Jan 2015 07:29:57 -0500 Received: from dovecot03.posteo.de (unknown [185.67.36.28]) by mx02.posteo.de (Postfix) with ESMTPS id F3FE323696E; Fri, 23 Jan 2015 13:29:55 +0100 (CET) Received: from mail.posteo.de (localhost [127.0.0.1]) by dovecot03.posteo.de (Postfix) with ESMTPSA id 3kTKYG62v5z5vN8; Fri, 23 Jan 2015 13:29:54 +0100 (CET) From: Martin Kepplinger To: dmitry.torokhov@gmail.com Cc: khoroshilov@ispras.ru, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Kepplinger Subject: [PATCH] input: (gtco) use sign_extend32() for sign extension Date: Fri, 23 Jan 2015 13:29:36 +0100 Message-Id: <1422016176-6299-1-git-send-email-martink@posteo.de> X-Mailer: git-send-email 2.1.4 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, 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 Signed-off-by: Martin Kepplinger --- Despite it's name, sign_extend32() is safe to use for 8 and 16 bit types too. drivers/input/tablet/gtco.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/input/tablet/gtco.c b/drivers/input/tablet/gtco.c index 8580456..272a838 100644 --- a/drivers/input/tablet/gtco.c +++ b/drivers/input/tablet/gtco.c @@ -59,7 +59,7 @@ Scott Hill shill@gtcocalcomp.com #include #include #include - +#include #include @@ -666,13 +666,8 @@ static void gtco_urb_callback(struct urb *urbinfo) case 4: /* Tilt */ - /* Sign extend these 7 bit numbers. */ - if (device->buffer[6] & 0x40) - device->buffer[6] |= 0x80; - - if (device->buffer[7] & 0x40) - device->buffer[7] |= 0x80; - + device->buffer[6] = sign_extend32(device->buffer[6], 6); + device->buffer[7] = sign_extend32(device->buffer[7], 6); valsigned = (device->buffer[6]); input_report_abs(inputdev, ABS_TILT_X, (s32)valsigned);