From patchwork Tue Mar 10 19:57:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charlie Mooney X-Patchwork-Id: 5980371 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 C795BBF440 for ; Tue, 10 Mar 2015 19:57:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DC769201C0 for ; Tue, 10 Mar 2015 19:57:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D830C201B9 for ; Tue, 10 Mar 2015 19:57:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753397AbbCJT5S (ORCPT ); Tue, 10 Mar 2015 15:57:18 -0400 Received: from mail-ie0-f180.google.com ([209.85.223.180]:33853 "EHLO mail-ie0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752668AbbCJT5Q (ORCPT ); Tue, 10 Mar 2015 15:57:16 -0400 Received: by iecsl2 with SMTP id sl2so28350286iec.1 for ; Tue, 10 Mar 2015 12:57:15 -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=z6hfAUO4L+YtxrABiMagbV9zduCMrgGslWCFYW074lc=; b=eKyb6TQG1Bevsb1gnns4KoRToDQfie0xa1wE/q0lpMQTtHZoVnLIP6ROadO2cHQTqA ZD/S+obgcALqADNGbPgx3kcBO20yf0GR0BpMjpQk+/20mskieu5ovHbgaoJQ2Ed+X3R+ +V9klc33vzDztXU/H7NAwwLZqnVU9mjKmEHoEshOR67ZkfRkOlQxAO7SKRXjwxPEuOsx lJDYN0InenaWIuJdYiNjyr0pPGQU9dDuehbGHYxyfGcLOib/VNlu4jVLj9wHCkgdOA6m M8jaW7lAtCAuirEM79QvqYIIjw6B6aV+9wXJdNtVQ+eeaUl499DF3BVMTfQ+7UVSg1Nz PcyQ== 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=z6hfAUO4L+YtxrABiMagbV9zduCMrgGslWCFYW074lc=; b=cN+qkiIV+J14jqtpgsFmyZTlt3BZaEzdWS7FN7GCvXI1dgwGeJL5P7yE+RpE9J0XiS hWJZ5Hjy6SL5LsaZign46sPOYMTCH6wV0RrrfVfUhEhiXpBuGY8Rf0ZA9qTdkD2tfK98 vEa+IU4GA44PX5r2KBmV6zDm6J9hVrWM6d8PGavvlttMmAo/uaBY25dhFGylooY5E84P 45vVgUlHr35HP/t8u3jngcAGA2wo7sOSfhrRuxe59mRZ/P6Bzvn1SYCYXv9h8WhPZHzx izIimRuzc33c45DBVyWkY0130FPmY9wt3bZDV6+ROczPU0k+rcL8j3OQnssdGsgY59NO tGzg== X-Gm-Message-State: ALoCoQmplnKVkkyAk5COD0ItOjSI8roklrcDzlejt2yvOf0JepSWE7GImHM7WC0DB4Q0X8VfWY5w X-Received: by 10.42.100.73 with SMTP id z9mr36801324icn.79.1426017435261; Tue, 10 Mar 2015 12:57:15 -0700 (PDT) Received: from cmooney.mtv.corp.google.com ([172.22.64.44]) by mx.google.com with ESMTPSA id k99sm1062806iod.8.2015.03.10.12.57.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Mar 2015 12:57:14 -0700 (PDT) From: Charlie Mooney To: linux-input@vger.kernel.org Cc: dmitry.torokhov@gmail.com, scott.liu@emc.com.tw, fabf@skynet.be, Charlie Mooney Subject: [PATCH] Input: elants_i2c: Append hw_version to FW file Date: Tue, 10 Mar 2015 12:57:03 -0700 Message-Id: <1426017423-26249-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 Currently the elants_i2c driver simply requests a static filename /lib/firmware/elants_i2c.bin when it gets firmware updates. This is a problem if you have two Elan touchscreens using the same driver. If both touchscreens have different firmwares, you would need to move the files around in your filesystem when you're updating them so that they don't get updated with the other's FW. If you have a read-only filesystem then this is impossible, even. This patch changes the elants_i2c driver to automatically append the four-hex-digit hw_version of the device onto the name of the FW file it's requesting for update. Since different touchscreens should have a different hw_version's this means the user needs to append the hw version of the touchscreen he or she intends to update onto the end of the firmware filename and then the driver will do the rest. The firmware filenames it looks for now are of the form: elants_i2c_${HW_VERSION}.bin eg: elants_i2c_2a44.bin Signed-off-by: Charlie Mooney --- drivers/input/touchscreen/elants_i2c.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index 926c58e..d34ba57 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -98,7 +98,10 @@ #define MAX_FW_UPDATE_RETRIES 30 #define ELAN_FW_PAGESIZE 132 -#define ELAN_FW_FILENAME "elants_i2c.bin" +#define ELAN_FW_BASE_FILENAME "elants_i2c" +#define ELAN_FW_EXTENSION "bin" +#define ELAN_FW_FILENAME_MAX_LEN (ARRAY_SIZE(ELAN_FW_BASE_FILENAME) + \ + ARRAY_SIZE(ELAN_FW_EXTENSION) + 5) /* calibration timeout definition */ #define ELAN_CALI_TIMEOUT_MSEC 10000 @@ -697,12 +700,16 @@ static int elants_i2c_fw_update(struct elants_data *ts) { struct i2c_client *client = ts->client; const struct firmware *fw; + char fw_filename_buffer[ELAN_FW_FILENAME_MAX_LEN]; int error; - error = request_firmware(&fw, ELAN_FW_FILENAME, &client->dev); + snprintf(fw_filename_buffer, ELAN_FW_FILENAME_MAX_LEN, "%s_%4x.%s", + ELAN_FW_BASE_FILENAME, ts->hw_version, ELAN_FW_EXTENSION); + dev_info(&client->dev, "requesting fw name = %s\n", fw_filename_buffer); + error = request_firmware(&p_fw_entry, fw_filename_buffer, &client->dev); if (error) { dev_err(&client->dev, "failed to request firmware %s: %d\n", - ELAN_FW_FILENAME, error); + fw_filename_buffer, error); return error; }