From patchwork Fri Jan 5 05:53:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 10146035 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 472176034B for ; Fri, 5 Jan 2018 05:53:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D7AB28893 for ; Fri, 5 Jan 2018 05:53:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 30FE328902; Fri, 5 Jan 2018 05:53:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCE9F28893 for ; Fri, 5 Jan 2018 05:53:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751232AbeAEFxn (ORCPT ); Fri, 5 Jan 2018 00:53:43 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:38346 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751220AbeAEFxm (ORCPT ); Fri, 5 Jan 2018 00:53:42 -0500 Received: by mail-pg0-f67.google.com with SMTP id t67so1651051pgc.5; Thu, 04 Jan 2018 21:53:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=QITJdbmylywdEWOjVgBk4lJxrdlzdNNt1mQmGTCwk+M=; b=KFUyVB34pN4MbiYQ5iLTV21rIsCuHPVVoa5WVyiiRQMh4Geo2JkmPeqsn71L2MpsD4 158pP4rBUEPPNZioE/jhnzWJ6mACrSB36FsGEGpouutwie/5VtPfH/56knHqKwiRQhVk IdXFDRzIZj/CtXO1WLwIM4Ca/w7VKrH2AdWS0DkLoTSIr8JBQDAjqs9h9TM/fnDKNGAw q4obj7ap6pdA9yapP3e2e7imvfLlnZVrW5xq5tQ7ZoMZhkS1OYBIWUAGp5x+T4X/vud6 vM+lEFhQDGgpLOc5YAzXeymSUl5rygX6wOk+YX3tQ32qmnDsBQHXP9O4LjO8fZW2rfoP 9XEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=QITJdbmylywdEWOjVgBk4lJxrdlzdNNt1mQmGTCwk+M=; b=Jle/EbE1rf9aokbLrn/ILZIyVoSsNZrJjiS5lk47Axzn819ili01esKZmIQ9Mwz9oL H3due+pN5R7huRbkBb4FQeF6dt9aDITurxErklctNLbQu1stv8SWQU8VRbb2+3dCVU2t Ww5Vksu3LG3TGnJ+Xepj6gMhb9Q4yEzrSgugoBPdMHn6f05MtF2ftBfZnjr+84ECHKcX t8BwESkxaTGoPtY1YdUz/Q0FTEKdMQk47gOls7Ndi81inr1ah1c+XUN8DHL9HSFrfFay XeGXSqnBH6x+jsHptv3k0UOCpbT57EqTs9i8+9IKcakqBe1qnU3ye7G5hjBes4pfIRNA Fu2Q== X-Gm-Message-State: AKGB3mKFSXqgSS0+REMNvdzU++CsRrRxE8iAkFrmZO/lv6ASGGyt1KqD KEimQjcnSrT59/d5ozJO/8I= X-Google-Smtp-Source: ACJfBouJoMgbEGtG86LZi2pyMCtXxBN0ObNGab9PYcsUzARJa9ssMqVnxowvAfzf0cIAY+Uk2ccwWA== X-Received: by 10.98.46.65 with SMTP id u62mr1859903pfu.61.1515131621455; Thu, 04 Jan 2018 21:53:41 -0800 (PST) Received: from dtor-ws ([2620:0:1000:1611:da80:8749:c06f:9515]) by smtp.gmail.com with ESMTPSA id 69sm12052215pft.11.2018.01.04.21.53.40 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jan 2018 21:53:40 -0800 (PST) Date: Thu, 4 Jan 2018 21:53:38 -0800 From: Dmitry Torokhov To: "jeffrey.lin" Cc: groeck@chromium.org, keith.tzeng@quantatw.com, Katherine.Hsieh@quantatw.com, bleung@google.com, jeffrey.lin@rad-ic.com, KP.li@rad-ic.com, albert.shieh@rad-ic.com, calvin.tseng@rad-ic.com, linux-kernel@vger.kernel.org, linux-input@vger.kernel.org Subject: Re: [PATCH] driver: input :touchscreen :Modify Raydium Firmware update input file Message-ID: <20180105055338.cogtaty5p5r5gglt@dtor-ws> References: <20171221135122.345-1-jeffrey.lin@raydium.corp-partner.google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20171221135122.345-1-jeffrey.lin@raydium.corp-partner.google.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Jeffrey, On Thu, Dec 21, 2017 at 09:51:22PM +0800, jeffrey.lin wrote: > Modify update firmware to accept alternative file name > > Signed-off-by: jeffrey.lin > --- > drivers/input/touchscreen/raydium_i2c_ts.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c > index a99fb5cac5a0..439d43c3519c 100644 > --- a/drivers/input/touchscreen/raydium_i2c_ts.c > +++ b/drivers/input/touchscreen/raydium_i2c_ts.c > @@ -130,6 +130,7 @@ struct raydium_data { > struct gpio_desc *reset_gpio; > > struct raydium_info info; > + char fw_file[64]; You do not really need to keep the firmware name in driver data, just use a temporary in raydium_i2c_fw_update(). > > struct mutex sysfs_mutex; > > @@ -752,12 +753,16 @@ static int raydium_i2c_fw_update(struct raydium_data *ts) > { > struct i2c_client *client = ts->client; > const struct firmware *fw = NULL; > - const char *fw_file = "raydium.fw"; > int error; > > - error = request_firmware(&fw, fw_file, &client->dev); > + /* Firmware name */ > + snprintf(ts->fw_file, sizeof(ts->fw_file), > + "raydium_%x.fw", ts->info.hw_ver); hw_ver is LE32, you need to convert it to CPU endianness before using. Also it would be better if we used the same encoding for the hardware version as the one that we use when we output it in sysfs. It makes userspace life a bit easier I think. How about the version of the patch below? Thanks. diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c index 100538d64fff..d1c09e6a2cb6 100644 --- a/drivers/input/touchscreen/raydium_i2c_ts.c +++ b/drivers/input/touchscreen/raydium_i2c_ts.c @@ -752,13 +752,20 @@ static int raydium_i2c_fw_update(struct raydium_data *ts) { struct i2c_client *client = ts->client; const struct firmware *fw = NULL; - const char *fw_file = "raydium.fw"; + char *fw_file; int error; + fw_file = kasprintf(GFP_KERNEL, "raydium_%#04x.fw", + le32_to_cpu(ts->info.hw_ver)); + if (!fw_file) + return -ENOMEM; + + dev_dbg(&client->dev, "firmware name: %s\n", fw_file); + error = request_firmware(&fw, fw_file, &client->dev); if (error) { dev_err(&client->dev, "Unable to open firmware %s\n", fw_file); - return error; + goto out_free_fw_file; } disable_irq(client->irq); @@ -787,6 +794,9 @@ static int raydium_i2c_fw_update(struct raydium_data *ts) release_firmware(fw); +out_free_fw_file: + kfree(fw_file); + return error; }