From patchwork Sun Mar 27 07:15:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhaoxiu Zeng X-Patchwork-Id: 8675431 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A4DE49F3D1 for ; Sun, 27 Mar 2016 07:16:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BD3302024C for ; Sun, 27 Mar 2016 07:16:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CD0842022D for ; Sun, 27 Mar 2016 07:16:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752621AbcC0HQG (ORCPT ); Sun, 27 Mar 2016 03:16:06 -0400 Received: from mail-pa0-f67.google.com ([209.85.220.67]:35428 "EHLO mail-pa0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752280AbcC0HQF (ORCPT ); Sun, 27 Mar 2016 03:16:05 -0400 Received: by mail-pa0-f67.google.com with SMTP id fl4so11409829pad.2; Sun, 27 Mar 2016 00:16:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:cc:to:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=hZdhAUiF8uTbE0JeMdd47B7q/pQTx4/jiOCrUaNfGnQ=; b=vBApr7VnK9bJjAZ0Q4IH0nhZJnyhevAx2v2FSVqhnKb7C+HKXEHVbEjX+96zmGp2RL 6Gtha26kjzZU2rL6F77ikPHsp40WTglPU/0NI4bGh07dPPncaZgv/vcWauGpZbzdnVVB dozJF4mc2bn0VdlOvAJOwkgX4qddUKYs7Aguqv4dNbrPIJi6e4xsO+hkYesQVj5IJaxu iMiRXm8RhScjc1ZB0DvRbMPPA7ntxz+5w10s2GEYBKLkUvcwFuHMuaEbhPObyYat4mJg Zw9uejKy7rglU6kEolJvusFxcF3HDknlg+apEZnU1+D9n4ZwBMaCpysrfZ8btXeGb12Q Ymtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:references:cc:to:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=hZdhAUiF8uTbE0JeMdd47B7q/pQTx4/jiOCrUaNfGnQ=; b=fcf3wirRc8oneqJL7y/3dgJSX/b5fJgSY4N7UyK/gytD8fpUQD7C+8/4+F1aH/VFYu t4BpRatyX0eGRQ94Zvc6UECh6E7O/gMWpJBZXr7V35e5raJ7cOZ2SS+KGPvRnGyXOlPW mKZv7vFVEDkaWVGfZuEt4g8ehkZgD7Cw90oYp7kxfJHd9GJ8JMj3lJI3QoQsjSuzjgUA 1z3VlaDcM/OReiL5c/l7IbvKEDlp6VvHt3dktFpfD8g1Y+/gr3UgyOaZI4ZW5Nuf/Ckr AkfQ8wbZAzmSY3qhykpYbXYgFbMA/FLtEiuO7ZGeAE9gEfV5dkItGmsDiBDceQp7YfQG NbZw== X-Gm-Message-State: AD7BkJK8dXjb4QD7F+iFkiSXk+hKHYydyz7ImAznmGMiwzVedpsSgG0/wRzHDsbZlK4pAQ== X-Received: by 10.66.90.163 with SMTP id bx3mr33530550pab.59.1459062964101; Sun, 27 Mar 2016 00:16:04 -0700 (PDT) Received: from [0.0.0.0] (tor-exit4-readme.dfri.se. [171.25.193.78]) by smtp.googlemail.com with ESMTPSA id 83sm26984748pfn.46.2016.03.27.00.15.54 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 27 Mar 2016 00:16:03 -0700 (PDT) Subject: [PATCH 18/31] input: joystick: use parity64 in sidewinder.c References: <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com> Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org To: Dmitry Torokhov From: "zhaoxiu.zeng" Message-ID: <56F7889D.7080300@gmail.com> Date: Sun, 27 Mar 2016 15:15:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.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 From: Zeng Zhaoxiu Signed-off-by: Zeng Zhaoxiu --- drivers/input/joystick/sidewinder.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c index 4a95b22..7ea486e 100644 --- a/drivers/input/joystick/sidewinder.c +++ b/drivers/input/joystick/sidewinder.c @@ -259,22 +259,6 @@ static void sw_init_digital(struct gameport *gameport) } /* - * sw_parity() computes parity of __u64 - */ - -static int sw_parity(__u64 t) -{ - int x = t ^ (t >> 32); - - x ^= x >> 16; - x ^= x >> 8; - x ^= x >> 4; - x ^= x >> 2; - x ^= x >> 1; - return x & 1; -} - -/* * sw_ccheck() checks synchronization bits and computes checksum of nibbles. */ @@ -334,7 +318,7 @@ static int sw_parse(unsigned char *buf, struct sw *sw) for (i = 0; i < sw->number; i ++) { - if (sw_parity(GB(i*15,15))) + if (parity64(GB(i*15,15))) return -1; input_report_abs(sw->dev[i], ABS_X, GB(i*15+3,1) - GB(i*15+2,1)); @@ -351,7 +335,7 @@ static int sw_parse(unsigned char *buf, struct sw *sw) case SW_ID_PP: case SW_ID_FFP: - if (!sw_parity(GB(0,48)) || (hat = GB(42,4)) > 8) + if (!parity64(GB(0,48)) || (hat = GB(42,4)) > 8) return -1; dev = sw->dev[0]; @@ -372,7 +356,7 @@ static int sw_parse(unsigned char *buf, struct sw *sw) case SW_ID_FSP: - if (!sw_parity(GB(0,43)) || (hat = GB(28,4)) > 8) + if (!parity64(GB(0,43)) || (hat = GB(28,4)) > 8) return -1; dev = sw->dev[0]; @@ -397,7 +381,7 @@ static int sw_parse(unsigned char *buf, struct sw *sw) case SW_ID_FFW: - if (!sw_parity(GB(0,33))) + if (!parity64(GB(0,33))) return -1; dev = sw->dev[0];