From patchwork Wed Oct 31 17:39:11 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ping Cheng X-Patchwork-Id: 1680671 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 0856ADFE76 for ; Wed, 31 Oct 2012 17:39:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932542Ab2JaRjZ (ORCPT ); Wed, 31 Oct 2012 13:39:25 -0400 Received: from mail-da0-f46.google.com ([209.85.210.46]:64618 "EHLO mail-da0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965385Ab2JaRjX (ORCPT ); Wed, 31 Oct 2012 13:39:23 -0400 Received: by mail-da0-f46.google.com with SMTP id n41so742983dak.19 for ; Wed, 31 Oct 2012 10:39:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=p1N/hm6t5vWh9851g/PzIHf5rqQ8sjDJXqt24fFImMs=; b=MDI5I13KN1ptijpDdVKheezzJOKPqOvzuxPwR+21CPfo1Bk3kSAkpPYEZpqkIXgcLO farUJ0tXoECkqGWcAjv6gLOgIawCWW+olqHtFue5tuY2EASqdsO2e84Kiz2WX9uYUsDD AXnGxh8GQsGRvCTURZ0Hu+VZTJwduJMw9Nm1ILF246CuNAF/SSREuKuAiS8KHvx3Kx4s vmryMqPwHNvCZIzW1vKNNlWBnimF3s59fDX1SZlWX+muNfOy2H+8OUsk5cH4ppOFNlZn llohRNcBN6fM28AQ4SatuE8/hbbh0xAGdESfn4YMTOnBUvtl91FB1l5MbFdn6oJVeoah xsdA== Received: by 10.68.223.66 with SMTP id qs2mr49253931pbc.139.1351705163367; Wed, 31 Oct 2012 10:39:23 -0700 (PDT) Received: from pingc-Gateway-E-155C.wacom.com ([67.51.163.2]) by mx.google.com with ESMTPS id s1sm2504525paz.0.2012.10.31.10.39.21 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 31 Oct 2012 10:39:22 -0700 (PDT) From: Ping Cheng To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, Ping Cheng , Ping Cheng Subject: [PATCH 1/2] input - wacom: Clean up device type code Date: Wed, 31 Oct 2012 10:39:11 -0700 Message-Id: <1351705151-14360-1-git-send-email-pingc@wacom.com> X-Mailer: git-send-email 1.7.9.5 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Use switch instead of if statement to verify device types Signed-off-by: Ping Cheng --- drivers/input/tablet/wacom_sys.c | 53 +++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c index 858ad44..67442f4 100644 --- a/drivers/input/tablet/wacom_sys.c +++ b/drivers/input/tablet/wacom_sys.c @@ -386,23 +386,36 @@ static int wacom_parse_hid(struct usb_interface *intf, if (usage == WCM_DESKTOP) { if (finger) { features->device_type = BTN_TOOL_FINGER; - if (features->type == TABLETPC2FG) { - /* need to reset back */ + + switch (features->type) { + case TABLETPC2FG: features->pktlen = WACOM_PKGLEN_TPC2FG; - } + break; - if (features->type == MTSCREEN || features->type == WACOM_24HDT) + case MTSCREEN: + case WACOM_24HDT: features->pktlen = WACOM_PKGLEN_MTOUCH; + break; - if (features->type == BAMBOO_PT) { - /* need to reset back */ + case BAMBOO_PT: features->pktlen = WACOM_PKGLEN_BBTOUCH; + break; + + default: + features->pktlen = WACOM_PKGLEN_GRAPHIRE; + break; + } + + switch (features->type) { + case BAMBOO_PT: features->x_phy = get_unaligned_le16(&report[i + 5]); features->x_max = get_unaligned_le16(&report[i + 8]); i += 15; - } else if (features->type == WACOM_24HDT) { + break; + + case WACOM_24HDT: features->x_max = get_unaligned_le16(&report[i + 3]); features->x_phy = @@ -410,7 +423,9 @@ static int wacom_parse_hid(struct usb_interface *intf, features->unit = report[i - 1]; features->unitExpo = report[i - 3]; i += 12; - } else { + break; + + default: features->x_max = get_unaligned_le16(&report[i + 3]); features->x_phy = @@ -418,10 +433,11 @@ static int wacom_parse_hid(struct usb_interface *intf, features->unit = report[i + 9]; features->unitExpo = report[i + 11]; i += 12; + break; } } else if (pen) { /* penabled only accepts exact bytes of data */ - if (features->type == TABLETPC2FG) + if (features->type >= TABLETPC) features->pktlen = WACOM_PKGLEN_GRAPHIRE; features->device_type = BTN_TOOL_PEN; features->x_max = @@ -434,32 +450,39 @@ static int wacom_parse_hid(struct usb_interface *intf, case HID_USAGE_Y: if (usage == WCM_DESKTOP) { if (finger) { - int type = features->type; - - if (type == TABLETPC2FG || type == MTSCREEN) { + switch (features->type) { + case TABLETPC2FG: + case MTSCREEN: features->y_max = get_unaligned_le16(&report[i + 3]); features->y_phy = get_unaligned_le16(&report[i + 6]); i += 7; - } else if (type == WACOM_24HDT) { + break; + + case WACOM_24HDT: features->y_max = get_unaligned_le16(&report[i + 3]); features->y_phy = get_unaligned_le16(&report[i - 2]); i += 7; - } else if (type == BAMBOO_PT) { + break; + + case BAMBOO_PT: features->y_phy = get_unaligned_le16(&report[i + 3]); features->y_max = get_unaligned_le16(&report[i + 6]); i += 12; - } else { + break; + + default: features->y_max = features->x_max; features->y_phy = get_unaligned_le16(&report[i + 3]); i += 4; + break; } } else if (pen) { features->y_max =