From patchwork Thu Sep 17 01:23:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Duson Lin X-Patchwork-Id: 7201641 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 871A49F380 for ; Thu, 17 Sep 2015 01:23:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 75B4020803 for ; Thu, 17 Sep 2015 01:23:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CB13720801 for ; Thu, 17 Sep 2015 01:23:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752813AbbIQBXi (ORCPT ); Wed, 16 Sep 2015 21:23:38 -0400 Received: from emcscan.emc.com.tw ([192.72.220.5]:6337 "EHLO emcscan.emc.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752811AbbIQBXi (ORCPT ); Wed, 16 Sep 2015 21:23:38 -0400 Received: from unknown (HELO emc.com.tw) ([192.168.10.1]) by emcscan.emc.com.tw with ESMTP; 17 Sep 2015 09:23:35 +0800 Received: from NB92067 ([192.168.33.28]) by emc.com.tw (8.13.7+Sun/8.13.7) with ESMTP id t8H1NVmp024548; Thu, 17 Sep 2015 09:23:31 +0800 (CST) From: "DusonLin" To: "'Daniel Drake'" , Cc: , References: <1442437369-23192-1-git-send-email-drake@endlessm.com> In-Reply-To: <1442437369-23192-1-git-send-email-drake@endlessm.com> Subject: RE: [PATCH] elan_i2c - Don't require known iap version Date: Thu, 17 Sep 2015 09:23:27 +0800 Message-ID: <001b01d0f0e7$77be3490$673a9db0$@emc.com.tw> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 thread-index: AQHXZSpDp6j63nYUMM1ZnztY+Bmzpp4zAVig Content-Language: zh-tw Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, 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 Hi Daniel, Thanks for your great support, please see my little concern at below. -----Original Message----- From: Daniel Drake [mailto:drake@endlessm.com] Sent: Thursday, September 17, 2015 5:03 AM To: dmitry.torokhov@gmail.com; dusonlin@emc.com.tw Cc: jprvita@gmail.com; linux-input@vger.kernel.org Subject: [PATCH] elan_i2c - Don't require known iap version The Asus X456UA has an ELAN1000 touchpad with IAP version 0xe. This is unknown to elan_get_fwinfo() so driver probe fails and I am left with an unusable touchpad. However, the fwinfo is not required for general driver usage, it is only needed if the user decides to upload new firmware. Adjust the driver so that fwinfo is only calculated and used when it is really needed. Signed-off-by: Daniel Drake --- drivers/input/mouse/elan_i2c_core.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) } @@ -339,7 +329,8 @@ static int elan_write_fw_block(struct elan_tp_data *data, } static int __elan_update_firmware(struct elan_tp_data *data, - const struct firmware *fw) + const struct firmware *fw, + u16 fw_validpage_count) { struct i2c_client *client = data->client; struct device *dev = &client->dev; @@ -356,7 +347,7 @@ static int __elan_update_firmware(struct elan_tp_data *data, iap_start_addr = get_unaligned_le16(&fw->data[ETP_IAP_START_ADDR * 2]); boot_page_count = (iap_start_addr * 2) / ETP_FW_PAGE_SIZE; - for (i = boot_page_count; i < data->fw_validpage_count; i++) { + for (i = boot_page_count; i < fw_validpage_count; i++) { u16 checksum = 0; const u8 *page = &fw->data[i * ETP_FW_PAGE_SIZE]; @@ -393,7 +384,8 @@ static int __elan_update_firmware(struct elan_tp_data *data, } static int elan_update_firmware(struct elan_tp_data *data, - const struct firmware *fw) + const struct firmware *fw, + u16 fw_validpage_count) { struct i2c_client *client = data->client; int retval; @@ -403,7 +395,7 @@ static int elan_update_firmware(struct elan_tp_data *data, disable_irq(client->irq); data->in_fw_update = true; - retval = __elan_update_firmware(data, fw); + retval = __elan_update_firmware(data, fw, fw_validpage_count); if (retval) { dev_err(&client->dev, "firmware update failed: %d\n", retval); data->ops->iap_reset(client); @@ -485,6 +477,17 @@ static ssize_t elan_sysfs_update_fw(struct device *dev, int error; const u8 *fw_signature; static const u8 signature[] = {0xAA, 0x55, 0xCC, 0x33, 0xFF, 0xFF}; + u16 fw_validpage_count; + u16 fw_signature_address; + + error = elan_get_fwinfo(data->iap_version, &fw_validpage_count, + &fw_signature_address); + if (error) { + dev_err(&data->client->dev, [Duson] I think it's better to change here " dev_err(dev," + "unknown iap version %d\n", data->iap_version); + return error; + } + /* Look for a firmware with the product id appended. */ fw_name = kasprintf(GFP_KERNEL, ETP_FW_NAME, data->product_id); @@ -502,7 +505,7 @@ static ssize_t elan_sysfs_update_fw(struct device *dev, } /* Firmware file must match signature data */ - fw_signature = &fw->data[data->fw_signature_address]; + fw_signature = &fw->data[fw_signature_address]; if (memcmp(fw_signature, signature, sizeof(signature)) != 0) { dev_err(dev, "signature mismatch (expected %*ph, got %*ph)\n", (int)sizeof(signature), signature, @@ -515,7 +518,7 @@ static ssize_t elan_sysfs_update_fw(struct device *dev, if (error) goto out_release_fw; - error = elan_update_firmware(data, fw); + error = elan_update_firmware(data, fw, fw_validpage_count); mutex_unlock(&data->sysfs_mutex); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index fa94530..aaa9e94 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -84,8 +84,6 @@ struct elan_tp_data { int pressure_adjustment; u8 mode; u8 ic_type; - u16 fw_validpage_count; - u16 fw_signature_address; bool irq_wake; @@ -264,14 +262,6 @@ static int elan_query_device_info(struct elan_tp_data *data) if (error) return error; - error = elan_get_fwinfo(data->iap_version, &data->fw_validpage_count, - &data->fw_signature_address); - if (error) { - dev_err(&data->client->dev, - "unknown iap version %d\n", data->iap_version); - return error; - } - return 0;