From patchwork Fri Jun 5 16:25:31 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Mooney X-Patchwork-Id: 6556321 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 C0CC7C0020 for ; Fri, 5 Jun 2015 16:26:08 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DBB99206F5 for ; Fri, 5 Jun 2015 16:26:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CAC6C206F8 for ; Fri, 5 Jun 2015 16:26:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752492AbbFEQ0F (ORCPT ); Fri, 5 Jun 2015 12:26:05 -0400 Received: from mail-ie0-f181.google.com ([209.85.223.181]:33931 "EHLO mail-ie0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752008AbbFEQ0E (ORCPT ); Fri, 5 Jun 2015 12:26:04 -0400 Received: by iebmu5 with SMTP id mu5so26288464ieb.1 for ; Fri, 05 Jun 2015 09:26:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=RtvTxVvg+aHLWi3B/AzsQPxMgNYmwCcLYc6krQ+RrNg=; b=Cy/7Iq6uD/7UUDnTd692+ErlZyWzthrY1Tu+w9ON+SmafNkcLiByaciGbRgaX0ZpS8 TfPBUL/x/tbqX+4oiEUBklM67zn2FxDyKOGbrHWNEBfAJvBVItvcsjuVMGCJn9XlAurh EaNmiXA+7BDxLiH+COrg7DAtkfPoeC45Lf/JRaRnSVoICfWiRjsn6fMQ5NNGJhR0h3/x zUsCddaAIdLpCwNYNpBYtzQD13sd8Smsy2MYng05rNQsGWCA2OlXfUvt+Sp6J0eUE8Tv X8xa/q6uQlorjCXAynbiBrsMkgLUpqneOChXU29FTnu+UFfg8fn6M8g+ypi7KFm34T5M It6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=RtvTxVvg+aHLWi3B/AzsQPxMgNYmwCcLYc6krQ+RrNg=; b=YO3fbpIt9rle6/v46LKtRb2H6EvNDaH/3gPS22KEXfWtr+teWMYPIH9s7tMjdiclYt XTfZUxHkTKgNm7CLQzwK2EDgklEBD8kJd29Rnm5Vyht1FBGewC25eqzusYP0+opatNZr /4L5p0x/UjVZmXVHGAqc1z8oAOOamGDHQVjIDSO1sI7xZpMqdShdTad+H5bY5M1jfxUl +tH+5hpuO0pmxT0sNEppYPUEE8KXc8EJPOu6pDBUM102Kq3XAsPC+WtK6mLyu4rXXWky +f8Vv0yFkuWJfLdW2Wy37WdOJ+gSxgwHpbT0FM7Rxb8fN6n/Ei5o/hDon5Wipxcis0be 6Ttw== X-Gm-Message-State: ALoCoQnqm3YtK7Sym5Z0i63TKjN1Sb+m5Rrs4TmeSeVZgbUbVoB2ZzXCyvp7l1KjJ2B8aJyr82DH X-Received: by 10.43.19.72 with SMTP id qj8mr2449435icb.68.1433521563941; Fri, 05 Jun 2015 09:26:03 -0700 (PDT) Received: from cmooney.mtv.corp.google.com ([172.22.64.44]) by mx.google.com with ESMTPSA id r4sm1652406igh.9.2015.06.05.09.26.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jun 2015 09:26:02 -0700 (PDT) From: Charlie Mooney To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, dusonlin@emc.com.tw, bleung@chromium.org, nicolas.iooss_linux@m4x.org, charliemooney@google.com, Charlie Mooney Subject: [PATCH] input: elan_i2c - Add product IDs FW names Date: Fri, 5 Jun 2015 09:25:31 -0700 Message-Id: <1433521531-920-1-git-send-email-charliemooney@chromium.org> X-Mailer: git-send-email 2.1.2 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,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 Previously the elan_i2c touchpad driver would simply request the firmware "/lib/firmware/elan_i2c.bin" This CL appends the "product ID" (by using the same function as the sysfs interface for consistency) to the filename. This results in filenames of the form "/lib/firmware/elan_i2c_72.0.bin", allowing you to support multiple elan_i2c touchpads on the same device by simply naming each device's FW with its corresponding product ID. This way when you trigger a fw update the driver will load the correct binary. Signed-off-by: Charlie Mooney --- drivers/input/mouse/elan_i2c.h | 4 +++- drivers/input/mouse/elan_i2c_core.c | 19 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/input/mouse/elan_i2c.h b/drivers/input/mouse/elan_i2c.h index 6d5f8a4..d793184 100644 --- a/drivers/input/mouse/elan_i2c.h +++ b/drivers/input/mouse/elan_i2c.h @@ -28,7 +28,9 @@ #define ETP_PRESSURE_OFFSET 25 /* IAP Firmware handling */ -#define ETP_FW_NAME "elan_i2c.bin" +#define ETP_FW_BASENAME "elan_i2c" +#define ETP_FW_EXTENSION "bin" +#define ETP_PRODUCT_ID_FORMAT_STRING "%d.0" #define ETP_IAP_START_ADDR 0x0083 #define ETP_FW_IAP_PAGE_ERR (1 << 5) #define ETP_FW_IAP_INTF_ERR (1 << 4) diff --git a/drivers/input/mouse/elan_i2c_core.c b/drivers/input/mouse/elan_i2c_core.c index fd5068b..fea9837 100644 --- a/drivers/input/mouse/elan_i2c_core.c +++ b/drivers/input/mouse/elan_i2c_core.c @@ -403,7 +403,8 @@ static ssize_t elan_sysfs_read_product_id(struct device *dev, struct i2c_client *client = to_i2c_client(dev); struct elan_tp_data *data = i2c_get_clientdata(client); - return sprintf(buf, "%d.0\n", data->product_id); + return sprintf(buf, ETP_PRODUCT_ID_FORMAT_STRING "\n", + data->product_id); } static ssize_t elan_sysfs_read_fw_ver(struct device *dev, @@ -446,10 +447,20 @@ static ssize_t elan_sysfs_update_fw(struct device *dev, const u8 *fw_signature; static const u8 signature[] = {0xAA, 0x55, 0xCC, 0x33, 0xFF, 0xFF}; - error = request_firmware(&fw, ETP_FW_NAME, dev); + /* Look for a firmware with the product id appended. */ + char *full_fw_name = kasprintf(GFP_KERNEL, + "%s_" ETP_PRODUCT_ID_FORMAT_STRING ".%s", + ETP_FW_BASENAME, data->product_id, ETP_FW_EXTENSION); + if (!full_fw_name) { + dev_err(dev, "failed fw filename memory allocation."); + return -ENOMEM; + } + dev_info(dev, "requesting fw '%s'\n", fw_name); + error = request_firmware(&fw, full_fw_name, dev); + kfree(full_fw_name); if (error) { - dev_err(dev, "cannot load firmware %s: %d\n", - ETP_FW_NAME, error); + dev_err(dev, "cannot load firmware '%s': %d\n", + full_fw_name, error); return error; }