From patchwork Fri Sep 18 13:38:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 7216461 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2D0A3BEEC1 for ; Fri, 18 Sep 2015 13:38:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1DD0720842 for ; Fri, 18 Sep 2015 13:38:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E17B32083D for ; Fri, 18 Sep 2015 13:38:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752057AbbIRNic (ORCPT ); Fri, 18 Sep 2015 09:38:32 -0400 Received: from mail-pa0-f42.google.com ([209.85.220.42]:33949 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751596AbbIRNib (ORCPT ); Fri, 18 Sep 2015 09:38:31 -0400 Received: by padhy16 with SMTP id hy16so51917393pad.1 for ; Fri, 18 Sep 2015 06:38:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=nPJGAxLtGS+0+AfKOyV+/5CsOQCgUWDmUAm4jw8Ywko=; b=F1Bp9685A01KC9AmsKGNHpRJoXVd7iF6LUJx7C+Mb+M6rTFFhH9kEqJxjl16wvbDJ2 4NXEEUtjw1UFx4jhE7SQvR1bed9+WXwtzNEDm06RbWiVOVaZp9HQ0DVhsAUqUsxc24sp XvZc8B8SIcfoJLBFIRWVp93PD1Z4JmlytzUWQR/ou2Q6PMTHE8pClJ2w+LEoPnsCduFg mdQkaqWz1yQJ3VXdlgrvwxY2oe7hvTSdl6hBQteEYJ2gsl78XynTI4GfG1zBcG3Kd7cV mmbXws+QVAX8A8urow38NmJVJIcv9sN4Jwot+rI7V/jHLc8xtqkgOV6glih+OtMgPeV7 lYyQ== X-Gm-Message-State: ALoCoQkwhGqHQW0AysxGA8vpaN2SUNajRZbjKOwkg4pvaAp1vY2a19pf2yMm8TouekC8Q3pcSR05 X-Received: by 10.68.104.227 with SMTP id gh3mr7509693pbb.108.1442583510929; Fri, 18 Sep 2015 06:38:30 -0700 (PDT) Received: from nuc.gallo.pinto ([190.181.183.61]) by smtp.gmail.com with ESMTPSA id as4sm9195335pbc.48.2015.09.18.06.38.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Sep 2015 06:38:29 -0700 (PDT) From: Daniel Drake To: dmitry.torokhov@gmail.com, dusonlin@emc.com.tw Cc: jprvita@gmail.com, linux-input@vger.kernel.org Subject: [PATCH v2] elan_i2c - Don't require known iap version Date: Fri, 18 Sep 2015 07:38:15 -0600 Message-Id: <1442583495-4593-1-git-send-email-drake@endlessm.com> X-Mailer: git-send-email 2.1.4 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 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 | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) v2: simplified dev_err call diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index fa94530..bababfe 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; } @@ -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,15 @@ 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(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 +503,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 +516,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);