From patchwork Tue Sep 12 02:54:11 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: 9948309 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 34F0C603F3 for ; Tue, 12 Sep 2017 02:56:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 243BD28DE1 for ; Tue, 12 Sep 2017 02:56:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1748428DBC; Tue, 12 Sep 2017 02:56:10 +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 A16DD28DE7 for ; Tue, 12 Sep 2017 02:56:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751078AbdILCzj (ORCPT ); Mon, 11 Sep 2017 22:55:39 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:36669 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751089AbdILCyi (ORCPT ); Mon, 11 Sep 2017 22:54:38 -0400 Received: by mail-pg0-f68.google.com with SMTP id d8so5524642pgt.3; Mon, 11 Sep 2017 19:54:37 -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=BkDb+ogijTb/TJDvnb9r1E5A88Nzumq1QVw6LmXhXKA=; b=fIpwXyw1Ea+4onS9fdVg1BO9KNjgfJrsTE/5Mvx6sRRWZRqueziOSmo8vo4hXjTy1m ATRMlUH+4oL39f4+djzpf2usttIt79lzbeqhL5Isyt8JYuO+QHqeeY7oB/ejXwONbg2g JnURQqb1GOrQCyuedHFVJ1BVolod+w90bfdkr8by31/p6gfV1xaUJ8tlROH7uwwx4aiC czSvtqYv3qSqwE9lMO1rMjQI5ftEVLuaQxChulgUVbVzScBabsCLkhQM0XM+UQllRYUY AK2XgIg2QZb+NjW5gNQcFuwDFI9jNGvoPK57LBy22DQeWihjTt96W+hS6bNCGgT0CZFr wcNw== 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=BkDb+ogijTb/TJDvnb9r1E5A88Nzumq1QVw6LmXhXKA=; b=h5R2as6vD9hAeGm6aghoFXVQEtyIknA41I9nqpOUTmosTKSCrlOfzEOAMq2PefOxqA XA8Y+FESTxTVfHgd2giRcdyx0gN1jVfOy8YNVVLb50+TW0XgWwRa+tzQ9jOcsctGFSE0 ElD7i52b4FChkOvRBh6hb9iZ1oPCZb9RzLBA8s4JcVReqHUwlumEqCHuejnWqwDNfcbr lUvsLzqqRJYEdP8kRjCMsuN+gfO+PZHvpEBUnX6carYyXxI8TZBHtBRGM7hOID0hWejd uwIHy31zp5vZnaxkZ4Ec4O8vZdntzv/C6JVsIepGLEDnWemzp2TuoKp2YS0MDkiIZlCO 1kag== X-Gm-Message-State: AHPjjUj6yo4a4MtVU4tcti7XINEkPVOCO1PT0+sE7NNVn7+p5yShMGIJ hpZr/zA87eh6iVT3HtXybA== X-Google-Smtp-Source: ADKCNb4d0QIBAicO7nwrAYGjOetA7zrJsZ3c5YrTpMRDdNZEB4OMjKfZewoT7jRDyGNhebGJSUgV9w== X-Received: by 10.84.211.39 with SMTP id b36mr3214910pli.330.1505184877206; Mon, 11 Sep 2017 19:54:37 -0700 (PDT) Received: from localhost (p2142-ipad301aobadori.miyagi.ocn.ne.jp. [123.216.57.142]) by smtp.gmail.com with ESMTPSA id q13sm17737974pfd.100.2017.09.11.19.54.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Sep 2017 19:54:36 -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] Minor changes in hid-alps.c for support new Alps device(replace some variables) Date: Tue, 12 Sep 2017 11:54:11 +0900 Message-Id: <20170912025414.3784-5-masaki.ota@jp.alps.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170912025414.3784-1-masaki.ota@jp.alps.com> References: <20170912025414.3784-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 -To support Alps T4 device, replace some variables 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;