Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp1023496pxa; Fri, 28 Aug 2020 01:11:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgCdBc/J61YEgzZJ0h9R1G+S8mUBDycmd0U36j+aQk+Ok1mAMDRNQpaA042zG9t1w1ozOR X-Received: by 2002:a17:906:f1c4:: with SMTP id gx4mr625365ejb.98.1598602295448; Fri, 28 Aug 2020 01:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598602295; cv=none; d=google.com; s=arc-20160816; b=q/AQbgeIKx4pYp7WtdTe145/YiB/GjdYhRhGzRus9b3L3ee7ESAvNy1RlVpnJ6/pXw Hsk2ycgTLGrERnddb4bOxKFPfX03UqRhJ9SaOS5fSFTh4T9E3iBqLv1MBMYzChGiFnry b1Mtgb8BW9GjCsstxoV6P4mK9nVwW7Wj7OHlEMMvxpDduRSBJFLC5Vamso0zMvlW6KES T3hzTQRTfkQDK2yhDfhG1JxguFPGwWvZOPRzk5J5lsdp8bznLiCpQt2aqF3RJY1X0+Ql /0V7EDnVPLYpnKMFwd66DVA0dnt994djJHnzic7KmUpD8li86WSEgVwIEDXoD89R6jes A/5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=g96tIDvgXJwPKOOA7+dvNjyN4dZbplzDaIkRNTr7fA8=; b=yvrJluYU4m6nzMm2+jkw2Tfpf99+QdTW9C1EO+8Nx7ablFEz0/SPCdkY+kKJlLQxNK EQ8JOskl80IMdPfFMgyFJYmsW+N6a3sRV8mAhozi4AQYggjdE5SMcCgZmxXXkSsy+Bw3 zpLobK9pievULeWwBQtrwmgqDTTVEPla5PQq14lgOUo9IrGgWIIBy5gymaIbsCFJZfcL tREUSYAz39Zi6960I8HTQ00FuOhHrA9dL0e8KCcVbJhRkUkR8G22WMhC5WdE2di8IruU qAQuqipybY/JkI0ulIbOfRskX6P298V6Hk+Sy9auo724YIuw2QDkT7+Gl55TkyukyppY h9Dg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OIyLwi3V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jr5si155548ejb.549.2020.08.28.01.11.12; Fri, 28 Aug 2020 01:11:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OIyLwi3V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728554AbgH1IIZ (ORCPT + 99 others); Fri, 28 Aug 2020 04:08:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727911AbgH1IIS (ORCPT ); Fri, 28 Aug 2020 04:08:18 -0400 Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43879C061264; Fri, 28 Aug 2020 01:08:17 -0700 (PDT) Received: by mail-lj1-x243.google.com with SMTP id f26so311532ljc.8; Fri, 28 Aug 2020 01:08:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=g96tIDvgXJwPKOOA7+dvNjyN4dZbplzDaIkRNTr7fA8=; b=OIyLwi3Vr5KWpQPEDlhBsXpg/0S4rnyQymPOqu1yKAIwoMPbUTHVXdAMh+1nVxeqw+ +RXtkoQIUQWC+DpfY+fW4qXGBgOfXzpjrJBQ7mZTtsK9+i7uPSYwwFDafP+zgFt6BkH4 AHSV2gmRA55eQ6IPxvdYIWrkB4dVDk0dY6OqRRifGMNsd0gXZk5MyMgVxL7/jHa9Be0A ZsAq0kTkAk3NDfQOFaG2E7cbKz2+pGobSGLJCEQleR8L6AQQ4NyYArQh/XfvkLd9EwOE 7euZli3irUtQnZ3yaWVy0UVHWWdFs/lQ2YilW0VaFnAp7yRJQC9d+c+g9hCkCTKnDJ41 n8dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=g96tIDvgXJwPKOOA7+dvNjyN4dZbplzDaIkRNTr7fA8=; b=F0WBz9mWx7y+yloysECzd/IvZ4TAvvmAktEpOhjsm4+cdJADtYaWX2nApWRU4SxjIG YqCSQMm8clt0FzF7/xUdMrMvwUFFNw+oqfl7huVV7b3dlPegvufxZWfndvCK/wV3Bqy4 g0i4VILL3qt4YP54z9Kfu1GDRQtL5ugCaDkbPmaUJFTQMyHa6L+MazVcaDQRKZ3MlwAM XH4FykBA0QJNg5sBh6wJckoGh/28z0hAXp586ADNFp6hEGbNp6WaLJK2PlPJTHJ2jOqs 3STmhW9HzhMs8+m+CSY+AFC0f4ATduWsbHejZUewFsrtQkjlwKH+XhtmepFnVIXGIZIJ deKQ== X-Gm-Message-State: AOAM532QJXnt0yOICzDX/Bl0HrIJnOnZpSPGZa9Uh35jYq1462Ku94uo DOO9fY/1UcT2sfXOAFIjV/k= X-Received: by 2002:a2e:b0db:: with SMTP id g27mr339392ljl.69.1598602095628; Fri, 28 Aug 2020 01:08:15 -0700 (PDT) Received: from [192.168.2.145] (109-252-170-211.dynamic.spd-mgts.ru. [109.252.170.211]) by smtp.googlemail.com with ESMTPSA id a4sm124716lfr.2.2020.08.28.01.08.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Aug 2020 01:08:15 -0700 (PDT) Subject: Re: [PATCH v2 1/1] Input: atmel_mxt_ts - allow specification of firmware file name To: Jiada Wang , nick@shmanahar.org, dmitry.torokhov@gmail.com Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, erosca@de.adit-jv.com, Andrew_Gabbasov@mentor.com References: <20200821075410.8250-1-jiada_wang@mentor.com> From: Dmitry Osipenko Message-ID: <081a63b6-b34e-1e52-50ac-b44255c8ed40@gmail.com> Date: Fri, 28 Aug 2020 11:08:14 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200821075410.8250-1-jiada_wang@mentor.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 21.08.2020 10:54, Jiada Wang пишет: > From: Nick Dyer > > On platforms which have multiple device instances using this driver, the > firmware may be different on each device. This patch makes the user give > the name of the firmware file when flashing. > > If user specified firmware file can't be found, then driver will try to > flash default firmware "maxtouch.fw". > > Signed-off-by: Nick Dyer > Acked-by: Benson Leung > Acked-by: Yufeng Shen > (cherry picked from ndyer/linux/for-upstream commit 76ebb7cee971cb42dfb0a3a9224403b8b09abcf1) > [gdavis: Forward port and fix conflicts.] > Signed-off-by: George G. Davis > [jiada: change to flash default firmware file, when user specified firmware can't be found] > Signed-off-by: Jiada Wang > --- > drivers/input/touchscreen/atmel_mxt_ts.c | 33 +++++++++++++++++++++++- > 1 file changed, 32 insertions(+), 1 deletion(-) > > diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c > index a2189739e30f..a20bc1bf8d52 100644 > --- a/drivers/input/touchscreen/atmel_mxt_ts.c > +++ b/drivers/input/touchscreen/atmel_mxt_ts.c > @@ -34,6 +34,7 @@ > #define MXT_FW_NAME "maxtouch.fw" > #define MXT_CFG_NAME "maxtouch.cfg" > #define MXT_CFG_MAGIC "OBP_RAW V1" > +#define MAX_FILENAME_SIZE 64 > > /* Registers */ > #define MXT_OBJECT_START 0x07 > @@ -308,6 +309,7 @@ struct mxt_data { > struct t7_config t7_cfg; > struct mxt_dbg dbg; > struct gpio_desc *reset_gpio; > + char fw_name[MAX_FILENAME_SIZE]; > > /* Cached parameters from object table */ > u16 T5_address; > @@ -2887,6 +2889,26 @@ static int mxt_load_fw(struct device *dev, const char *fn) > return ret; > } > > +static int mxt_update_file_name(struct device *dev, char *file_name, > + const char *buf, size_t count) > +{ > + size_t len = count; > + > + /* Echo into the sysfs entry may append newline at the end of buf */ > + if (buf[count - 1] == '\n') > + len = count - 1; > + > + /* Simple sanity check */ > + if (len > MAX_FILENAME_SIZE - 1) { > + dev_warn(dev, "File name too long\n"); > + return -EINVAL; > + } > + > + strscpy(file_name, buf, len + 1); > + > + return 0; > +} > + > static ssize_t mxt_update_fw_store(struct device *dev, > struct device_attribute *attr, > const char *buf, size_t count) > @@ -2894,7 +2916,16 @@ static ssize_t mxt_update_fw_store(struct device *dev, > struct mxt_data *data = dev_get_drvdata(dev); > int error; > > - error = mxt_load_fw(dev, MXT_FW_NAME); > + error = mxt_update_file_name(dev, data->fw_name, buf, count); > + if (error) > + return error; > + > + error = mxt_load_fw(dev, data->fw_name); > + if (error) { > + dev_warn(dev, "try %s instead\n", MXT_FW_NAME); Hello, Jiada! Will this message be printed even if fw_name is an empty string or whatever string that is already used by existing userspace for writing to update_fw? Maybe it actually should be better to add a new device attribute that will take the fw_name? Then the old attribute will continue to work like it worked before. > + error = mxt_load_fw(dev, MXT_FW_NAME); > + } > + > if (error) { > dev_err(dev, "The firmware update failed(%d)\n", error); > count = error; >