From patchwork Fri Oct 6 01:16:58 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: 9988211 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 7FA8B60216 for ; Fri, 6 Oct 2017 01:18:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 715CE28CCF for ; Fri, 6 Oct 2017 01:18:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6660128D44; Fri, 6 Oct 2017 01:18:28 +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=unavailable 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 EA5D028CCF for ; Fri, 6 Oct 2017 01:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751721AbdJFBR3 (ORCPT ); Thu, 5 Oct 2017 21:17:29 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:38526 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751486AbdJFBR0 (ORCPT ); Thu, 5 Oct 2017 21:17:26 -0400 Received: by mail-pf0-f196.google.com with SMTP id a7so15634300pfj.5; Thu, 05 Oct 2017 18:17:26 -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=Zh4V9iXwlwf6+3jp2W5avO3lQ2jOBzf40SV8IM9zuBvKk6Orq/SRrrIOHiYo6XjCrT 8i4ccEyTlNfZkTr4hXaB8kDoMNhK3I/iub1mNoB1WnmlnYgXvQ+St7GaSVu2jTMxPw8I rAYpQM1KOIGZFlg8MpBnUmATs5HtFIdfq11yeKJ/aPZaai2KO4oMGKOESOyvDhG7Rq66 +JK9pqERpQTPiiBVLRWZQgjdWMl3jZm2wPxQxO77J33Ta7uP51sFSDhYXds5fwX5T4My C9BTsbAKpIDKmEf602XEs2mgI+RLvPWqcbV+cudL30BIooWymM/REacq2uWbhwDq+4d1 uGyg== 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=dm7Fcs9zusCcqK/oRV14NBHBASxYqZxTx55jsssVA/Fsr9dO2A/31KWg3N4p6FWIm2 6K3GKifZWe+kpKjbz2OQeDDa1ts0d/k1AEPva7RmLoWXl5i/Sj4B4EnHQSWlnrcrHrfx g7zCGb7DV1malctD+nJMgPKXO9dYUlAY14ZuSJZBOi+FL59ERRNdFkPHNANb328JyYv2 VvAn/0v7mbGsIC5VvNGaz0wGnp21yMIt/RnCIDDTIacZmLi0Masb44bbStLf3kPNwGSm ZbyJW89/QHIfi0iIhvnDAZtw/hpCvCPTwu0JygKEY1FESm5bc+k8cCc3frDa1t8oxOyA xEtg== X-Gm-Message-State: AMCzsaXD/aPRjTvgV2WUUYNQRnajAqpc4m3D2awDRfjmEm4wKQhAs5i5 XZlcRs1eyGDLqRIS1QJ3tyY= X-Google-Smtp-Source: AOwi7QAKQ0AcjdG/j7+/aa8UMPATag/IBY6ZI/GKJRin8d+LtiEZRjfrvbHcPRy+9Y2aSVh8bVGMgw== X-Received: by 10.98.98.130 with SMTP id w124mr493675pfb.191.1507252645673; Thu, 05 Oct 2017 18:17:25 -0700 (PDT) Received: from localhost (p2218-ipad303aobadori.miyagi.ocn.ne.jp. [123.216.73.218]) by smtp.gmail.com with ESMTPSA id k10sm268681pgq.92.2017.10.05.18.17.24 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 05 Oct 2017 18:17:25 -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 10:16:58 +0900 Message-Id: <20171006011701.3761-5-masaki.ota@jp.alps.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171006011701.3761-1-masaki.ota@jp.alps.com> References: <20171006011701.3761-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;