From patchwork Fri Oct 6 02:53:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masaki Ota <012nexus@gmail.com> X-Patchwork-Id: 9988309 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D133960216 for ; Fri, 6 Oct 2017 02:54:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BEF8C262AE for ; Fri, 6 Oct 2017 02:54:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3CAF27F4B; Fri, 6 Oct 2017 02:54:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,FROM_STARTS_WITH_NUMS,RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 326A4262AE for ; Fri, 6 Oct 2017 02:54:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751525AbdJFCya (ORCPT ); Thu, 5 Oct 2017 22:54:30 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:34909 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751784AbdJFCxg (ORCPT ); Thu, 5 Oct 2017 22:53:36 -0400 Received: by mail-pg0-f65.google.com with SMTP id p5so14740327pgn.2; Thu, 05 Oct 2017 19:53:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=abcCcfqiRR4VT+lJ/GmzYZjDoI8/zf9C1csFLeSucfg=; b=W2kNwSEnTovvI4tcr8ewxtLpuxcZ1dWriQfXUPFx4D2MM8aVQwwvPfVgMLTViV382T jFhgh8Oo6PYuL7edJqKdHKhBU5K7sFyycf3k2PdXISJrUfYchk1U2fkWdvl4IYad2HTh 6StXwfIDa4daZIiocSN76PMi7Kn9/1NONBJ+BcV52KrpomK0kCQpJWlNJljpA2gpzGeW ldLCtey92L7V6r7HtdhG6VqpAO/DLHXYujXpsoIAj5AxksNWoklhuaPYiE/m5JjzIcEh VdNcX37Udp+DU4Jw+0FgeStHDDGp1EAKRXW4HvwxphQByJjlIoQZixl2lbJrinSEQREa lEzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=abcCcfqiRR4VT+lJ/GmzYZjDoI8/zf9C1csFLeSucfg=; b=crOUnb2qUmnFx1VosRdRI5dHQDHiJNnRhT2Pw4auQc66R841Z3p+Fu1FZHGDiQNJQp LnbD9srwITRZYGgUvSoNNdyAcFu+jOi9mN86M/qkmtOdl5ru3XU3DR3n//dldUm3Ihuq nLXecgohbkuWapRdngGG6c46DqgYUkluY286LEo4RbgdCg7NXW05YLwWq3PKWmJk+lot 18nieBCfUeXGcukUyxSZEtQ7yt+vPZNWVal1AlLWvS5lyDxj8gT7QR/iAgoTYzMLgoPD 2W/4jhAVvRJryowaNgEdceZHA1ZXHHvOIcbl0oZ02yMonV9NHTBLfgAqsGRHea2h8RRG lNYA== X-Gm-Message-State: AMCzsaWHPryNbteepTj2PEwi9FKFxEouO6xNCL9FLtFVIfkyt+ZMdVby afxfMBHPH1w6xAZMhQKBgIk= X-Google-Smtp-Source: AOwi7QDqS2R5mdTAc/FSXKW1N4XxYmdwlgvLHDD6GHQrLt+4l+GxzaSl90dfy3VC1dTrSWHqQExwBA== X-Received: by 10.84.132.35 with SMTP id 32mr632885ple.170.1507258416260; Thu, 05 Oct 2017 19:53:36 -0700 (PDT) Received: from localhost (p2218-ipad303aobadori.miyagi.ocn.ne.jp. [123.216.73.218]) by smtp.gmail.com with ESMTPSA id b22sm488573pfh.175.2017.10.05.19.53.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Oct 2017 19:53:35 -0700 (PDT) From: Masaki Ota <012nexus@gmail.com> X-Google-Original-From: Masaki Ota To: jikos@kernel.org, benjamin.tissoires@redhat.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, masaki.ota@jp.alps.com Subject: [PATCH 4/7] replace some variables Date: Fri, 6 Oct 2017 11:53:16 +0900 Message-Id: <20171006025319.2505-5-masaki.ota@jp.alps.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171006025319.2505-1-masaki.ota@jp.alps.com> References: <20171006025319.2505-1-masaki.ota@jp.alps.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Masaki Ota -Move some variables(dev_ctrl, dev_type, sen_line_num_x, sen_line_num_y, pitch_x, pitch_y, resolution, btn_info) from u1_dev structure to "u1_init()", because these variables are only used in "u1_init()" function. Signed-off-by: Masaki Ota --- drivers/hid/hid-alps.c | 67 ++++++++++++++++++++------------------------------ 1 file changed, 27 insertions(+), 40 deletions(-) diff --git a/drivers/hid/hid-alps.c b/drivers/hid/hid-alps.c index 201fe175cba3..4c323b58e009 100644 --- a/drivers/hid/hid-alps.c +++ b/drivers/hid/hid-alps.c @@ -61,14 +61,10 @@ * @input2: pointer to the kernel input2 device * @hdev: pointer to the struct hid_device * - * @dev_ctrl: device control parameter * @dev_type: device type - * @sen_line_num_x: number of sensor line of X - * @sen_line_num_y: number of sensor line of Y - * @pitch_x: sensor pitch of X - * @pitch_y: sensor pitch of Y - * @resolution: resolution - * @btn_info: button information + * @max_fingers: total number of fingers + * @has_sp: boolean of sp existense + * @sp_btn_info: button information * @x_active_len_mm: active area length of X (mm) * @y_active_len_mm: active area length of Y (mm) * @x_max: maximum x coordinate value @@ -77,22 +73,14 @@ * @y_min: minimum y coordinate value * @btn_cnt: number of buttons * @sp_btn_cnt: number of stick buttons - * @has_sp: boolean of sp existense - * @max_fingers: total number of fingers */ struct u1_dev { struct input_dev *input; struct input_dev *input2; struct hid_device *hdev; - u8 dev_ctrl; - u8 dev_type; - u8 sen_line_num_x; - u8 sen_line_num_y; - u8 pitch_x; - u8 pitch_y; - u8 resolution; - u8 btn_info; + u8 max_fingers; + u8 has_sp; u8 sp_btn_info; u32 x_active_len_mm; u32 y_active_len_mm; @@ -102,8 +90,6 @@ struct u1_dev { u32 y_min; u32 btn_cnt; u32 sp_btn_cnt; - u8 has_sp; - u8 max_fingers; }; static int u1_read_write_register(struct hid_device *hdev, u32 address, @@ -266,78 +252,80 @@ static int alps_post_resume(struct hid_device *hdev) static int u1_init(struct hid_device *hdev, struct u1_dev *pri_data) { int ret; + u8 tmp, dev_ctrl, sen_line_num_x, sen_line_num_y; + u8 pitch_x, pitch_y, resolution; /* Device initialization */ ret = u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1, - &pri_data->dev_ctrl, 0, true); + &dev_ctrl, 0, true); if (ret < 0) { dev_err(&hdev->dev, "failed U1_DEV_CTRL_1 (%d)\n", ret); goto exit; } - pri_data->dev_ctrl &= ~U1_DISABLE_DEV; - pri_data->dev_ctrl |= U1_TP_ABS_MODE; + dev_ctrl &= ~U1_DISABLE_DEV; + dev_ctrl |= U1_TP_ABS_MODE; ret = u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1, - NULL, pri_data->dev_ctrl, false); + NULL, dev_ctrl, false); if (ret < 0) { dev_err(&hdev->dev, "failed to change TP mode (%d)\n", ret); goto exit; } ret = u1_read_write_register(hdev, ADDRESS_U1_NUM_SENS_X, - &pri_data->sen_line_num_x, 0, true); + &sen_line_num_x, 0, true); if (ret < 0) { dev_err(&hdev->dev, "failed U1_NUM_SENS_X (%d)\n", ret); goto exit; } ret = u1_read_write_register(hdev, ADDRESS_U1_NUM_SENS_Y, - &pri_data->sen_line_num_y, 0, true); + &sen_line_num_y, 0, true); if (ret < 0) { dev_err(&hdev->dev, "failed U1_NUM_SENS_Y (%d)\n", ret); goto exit; } ret = u1_read_write_register(hdev, ADDRESS_U1_PITCH_SENS_X, - &pri_data->pitch_x, 0, true); + &pitch_x, 0, true); if (ret < 0) { dev_err(&hdev->dev, "failed U1_PITCH_SENS_X (%d)\n", ret); goto exit; } ret = u1_read_write_register(hdev, ADDRESS_U1_PITCH_SENS_Y, - &pri_data->pitch_y, 0, true); + &pitch_y, 0, true); if (ret < 0) { dev_err(&hdev->dev, "failed U1_PITCH_SENS_Y (%d)\n", ret); goto exit; } ret = u1_read_write_register(hdev, ADDRESS_U1_RESO_DWN_ABS, - &pri_data->resolution, 0, true); + &resolution, 0, true); if (ret < 0) { dev_err(&hdev->dev, "failed U1_RESO_DWN_ABS (%d)\n", ret); goto exit; } pri_data->x_active_len_mm = - (pri_data->pitch_x * (pri_data->sen_line_num_x - 1)) / 10; + (pitch_x * (sen_line_num_x - 1)) / 10; pri_data->y_active_len_mm = - (pri_data->pitch_y * (pri_data->sen_line_num_y - 1)) / 10; + (pitch_y * (sen_line_num_y - 1)) / 10; pri_data->x_max = - (pri_data->resolution << 2) * (pri_data->sen_line_num_x - 1); + (resolution << 2) * (sen_line_num_x - 1); pri_data->x_min = 1; pri_data->y_max = - (pri_data->resolution << 2) * (pri_data->sen_line_num_y - 1); + (resolution << 2) * (sen_line_num_y - 1); pri_data->y_min = 1; ret = u1_read_write_register(hdev, ADDRESS_U1_PAD_BTN, - &pri_data->btn_info, 0, true); + &tmp, 0, true); if (ret < 0) { dev_err(&hdev->dev, "failed U1_PAD_BTN (%d)\n", ret); goto exit; } - if ((pri_data->btn_info & 0x0F) == (pri_data->btn_info & 0xF0) >> 4) { - pri_data->btn_cnt = (pri_data->btn_info & 0x0F); + if ((tmp & 0x0F) == (tmp & 0xF0) >> 4) { + pri_data->btn_cnt = (tmp & 0x0F); } else { /* Button pad */ pri_data->btn_cnt = 1; @@ -346,16 +334,15 @@ static int u1_init(struct hid_device *hdev, struct u1_dev *pri_data) pri_data->has_sp = 0; /* Check StickPointer device */ ret = u1_read_write_register(hdev, ADDRESS_U1_DEVICE_TYP, - &pri_data->dev_type, 0, true); + &tmp, 0, true); if (ret < 0) { dev_err(&hdev->dev, "failed U1_DEVICE_TYP (%d)\n", ret); goto exit; } - - if (pri_data->dev_type & U1_DEVTYPE_SP_SUPPORT) { - pri_data->dev_ctrl |= U1_SP_ABS_MODE; + if (tmp & U1_DEVTYPE_SP_SUPPORT) { + dev_ctrl |= U1_SP_ABS_MODE; ret = u1_read_write_register(hdev, ADDRESS_U1_DEV_CTRL_1, - NULL, pri_data->dev_ctrl, false); + NULL, dev_ctrl, false); if (ret < 0) { dev_err(&hdev->dev, "failed SP mode (%d)\n", ret); goto exit;