From patchwork Wed Mar 11 01:41:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 5981551 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 5E2039F2A9 for ; Wed, 11 Mar 2015 01:41:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5148A20412 for ; Wed, 11 Mar 2015 01:41:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 40EC4203ED for ; Wed, 11 Mar 2015 01:41:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751710AbbCKBli (ORCPT ); Tue, 10 Mar 2015 21:41:38 -0400 Received: from mail-ig0-f182.google.com ([209.85.213.182]:43595 "EHLO mail-ig0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751506AbbCKBlh (ORCPT ); Tue, 10 Mar 2015 21:41:37 -0400 Received: by igbhn18 with SMTP id hn18so8772336igb.2 for ; Tue, 10 Mar 2015 18:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=518bi25QetyEf/R8NlPF3lXxHML7du746lVvjJnlL4c=; b=apiunufm9VLjL1au8mXNAEgjVZct2ieLLgWc9PgYiZUyd1nPy8btNVxOJw7Qi/yGHe ldrAi1KYE/RtVdtn9rxb48ARRqFUqa+aVT4NsMLiehmohHitt5YqG5F8axPmXXvJ2coJ qGtd8LdcCcBBacD0s2yJqY4BYcgTHy7M6CA8OZRN29zMCP51c+gxIr65GjWP9iTPdxJm 1IZ7+qL+SgFdFYw7FLE7AKqBLwxqeDFrRhoJ8+UR9y7AZ29skwLIzczjZD1fus3rreNz 8bG3QSKn7eGmBo27P4/kXfyTF8t8mZLdEeetvTEo4DHFXQSpotux80LElCHxd6Bh+o/m st9Q== X-Received: by 10.107.167.3 with SMTP id q3mr60913665ioe.18.1426038096901; Tue, 10 Mar 2015 18:41:36 -0700 (PDT) Received: from dtor-ws ([2620:0:1000:1301:fc09:462c:3e0f:ae46]) by mx.google.com with ESMTPSA id vk4sm1585488igc.11.2015.03.10.18.41.34 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 10 Mar 2015 18:41:35 -0700 (PDT) Date: Tue, 10 Mar 2015 18:41:32 -0700 From: Dmitry Torokhov To: Charlie Mooney Cc: linux-input@vger.kernel.org, scott.liu@emc.com.tw, fabf@skynet.be Subject: Re: [PATCH] Input: elants_i2c: Append hw_version to FW file Message-ID: <20150311014132.GA22959@dtor-ws> References: <1426017423-26249-1-git-send-email-charliemooney@chromium.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1426017423-26249-1-git-send-email-charliemooney@chromium.org> User-Agent: Mutt/1.5.21 (2010-09-15) 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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 Hi Charlie, On Tue, Mar 10, 2015 at 12:57:03PM -0700, Charlie Mooney wrote: > 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) Looked at this again and I don't really like how we need to maintain the MAX_LEN and make sure it is in sync with the format string. How about the patch below instead? Thanks. diff --git a/drivers/input/touchscreen/elants_i2c.c b/drivers/input/touchscreen/elants_i2c.c index 926c58e..43b3c9c 100644 --- a/drivers/input/touchscreen/elants_i2c.c +++ b/drivers/input/touchscreen/elants_i2c.c @@ -98,7 +98,6 @@ #define MAX_FW_UPDATE_RETRIES 30 #define ELAN_FW_PAGESIZE 132 -#define ELAN_FW_FILENAME "elants_i2c.bin" /* calibration timeout definition */ #define ELAN_CALI_TIMEOUT_MSEC 10000 @@ -697,12 +696,19 @@ static int elants_i2c_fw_update(struct elants_data *ts) { struct i2c_client *client = ts->client; const struct firmware *fw; + char *fw_name; int error; - error = request_firmware(&fw, ELAN_FW_FILENAME, &client->dev); + fw_name = kasprintf(GFP_KERNEL, "elants_i2c_%4x.bin", ts->hw_version); + if (!fw_name) + return -ENOMEM; + + dev_info(&client->dev, "requesting fw name = %s\n", fw_name); + error = request_firmware(&fw, fw_name, &client->dev); + kfree(fw_name); if (error) { - dev_err(&client->dev, "failed to request firmware %s: %d\n", - ELAN_FW_FILENAME, error); + dev_err(&client->dev, "failed to request firmware: %d\n", + error); return error; }