Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1369823ybj; Thu, 7 May 2020 23:03:40 -0700 (PDT) X-Google-Smtp-Source: APiQypI91dML7ExTC8VAAiNFJ49atGlIoAa8cFkpq5T6wvm25G9Vv1uHUskVUMiaXNzlHL0KEmvW X-Received: by 2002:a17:906:d8b4:: with SMTP id qc20mr495133ejb.253.1588917820034; Thu, 07 May 2020 23:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588917820; cv=none; d=google.com; s=arc-20160816; b=AKFDlQUmext+v7GWXrzHwwljVoLqvn2F5O20mNsK/amhgclfSNLi6QoAPKQuD4BCXr p1/Rkk8UvdRWZig2s3V21cDrUtfvyoPgDqSfT8qsBkFVX7rEfe6gOneEsbx+WhcoqpnB Zb/GRj1de1YQ+2zpwR7VxisD3HkcPzVAhOVn6S0h/h87HoBZnnxvcgZpnb9u69UyX1EF 7Llfg+x14ytexpDNejqzvjCNq1j80ZxuS1lWGuCWohBHkDokoLQzQNoM0kqE7PxJnclt 1wMQe0qNxMClLdweNyeXKeRtw60iOZa/eSDS+gFRphXsEAH/XRXMEi+Ey+iZ7ZqzsbAs bUwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=SLZ50allKuqfcAleLvYRB7OjvEx5wLmqmbqPgS6wIxk=; b=aBJGdTDfxTPIk/tbBSYzl7ZBouf0fEUxlQdDfZI8F8ChSQoP0LXs8X6kZkN094QUMi ITNUsegTH1WYSUyPDALVHvFqP7x8bNrOCnkX7WPiKrCfdu0QYWpvh3JZuOmsWtOOi0oE S//2NhkKPxp6szRCopbCvGdskj8PHdNnjYTBsoH8hmo72S8HJp0mOexhLb13h6hBIAoV kQt9sEdAk2COEP7jSLPA+6kKjAFhr2gkvMbFbj8npOLzDOZ5AJqf45ksQwz8BiUyybtd gPYtXOPn8cmVbC+8xKHuJl1u3K3vU+GFWfF56mtThxoUdhyONVU7IuUWv9bgIzWkfIsV m+pQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j19si367799edp.118.2020.05.07.23.03.17; Thu, 07 May 2020 23:03:40 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728050AbgEHF6w (ORCPT + 99 others); Fri, 8 May 2020 01:58:52 -0400 Received: from esa1.mentor.iphmx.com ([68.232.129.153]:38715 "EHLO esa1.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728032AbgEHF6s (ORCPT ); Fri, 8 May 2020 01:58:48 -0400 IronPort-SDR: v992HnQOXZltl/bnCwJMfbyQQkZkkPOrm6M9c54QLeckyxvbZiW7fTycgg/uStSO6e5LtjTXNP CD5VuRSmfxGSLtDrp/x4QPsT8QTobV7/Y+PAXudYxZU9m6P0D/OL0niRV+zj3+bPbDrFQS5CJR tGIOqQ8dVNjwtMNSuNWapfWJK05Q+Sq6H7uR8iXu73otZZiVClq9nzmq4QJ6m6C+6Wip01rBAB aFQM7SjaD62pEvaVUdnR5lYWA1VDKRaOYyxevXW5DEF1n+kcj8WnFjPeqW11LM4bhjkeHDiOR8 8JE= X-IronPort-AV: E=Sophos;i="5.73,366,1583222400"; d="scan'208";a="50670106" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 07 May 2020 21:58:46 -0800 IronPort-SDR: knVGv/inYw9s8Bajp8uhv8i5A8XhDj4Yje7Hg36lIwhi0BcnkiEyaY3PpKb1Mq0p5X7uNTMzBb xbwrVpN/X3bUoJKtGKKuQpubn1/PDVXtCqwvq77FOH41582mZ5FsRFOEjgtoqxbz/Tvd9FaCyq RNaUmRRqtVMWmztgsSDAhxpfXTmq530eRCxbYorjQd/bsSRaEQhd/m0wAKTrOJqnj4FpeLEqmE wYBEXpwC4FWCU9M7dIT/Xu3wuHKEd980MkaT98CdhzFHAm6o5zPwvBTSAyQ6Y6r/GPDCxCiaXF HAo= From: Jiada Wang To: , , , , CC: , , , , Subject: [PATCH v11 28/56] Input: atmel_mxt_ts - refactor code to enter bootloader into separate func Date: Thu, 7 May 2020 22:56:28 -0700 Message-ID: <20200508055656.96389-29-jiada_wang@mentor.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508055656.96389-1-jiada_wang@mentor.com> References: <20200508055656.96389-1-jiada_wang@mentor.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nick Dyer Refactor code to enter bootloader into separate func Signed-off-by: Nick Dyer (cherry picked from ndyer/linux/for-upstream commit bedd706a32522b946467e15f4f4f24de86a1b4d7) [gdavis: Resolve forward port conflicts due to applying upstream commit 96a938aa214e ("Input: atmel_mxt_ts - remove platform data support").] Signed-off-by: George G. Davis [jiada: Squash change from ndyer/linux/for-upstream commit d691d3ee6c6de84b38464a42 3207b3e23cb9dc3a - Input: atmel_mxt_ts - check firmware format before entering bootloader Add commit description] Signed-off-by: Jiada Wang --- drivers/input/touchscreen/atmel_mxt_ts.c | 43 +++++++++++++++--------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index bb4fc13defea..674763dddcd3 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -3253,23 +3253,10 @@ static int mxt_check_firmware_format(struct device *dev, return -EINVAL; } -static int mxt_load_fw(struct device *dev) +static int mxt_enter_bootloader(struct mxt_data *data) { - struct mxt_data *data = dev_get_drvdata(dev); - struct mxt_flash f = { 0, }; int ret; - ret = request_firmware(&f.fw, data->fw_name, dev); - if (ret) { - dev_err(dev, "Unable to open firmware %s\n", data->fw_name); - return ret; - } - - /* Check for incorrect enc file */ - ret = mxt_check_firmware_format(dev, f.fw); - if (ret) - goto release_firmware; - if (data->suspended) { if (data->suspend_mode == MXT_SUSPEND_REGULATOR) mxt_regulator_enable(data); @@ -3287,14 +3274,14 @@ static int mxt_load_fw(struct device *dev) ret = mxt_t6_command(data, MXT_COMMAND_RESET, MXT_BOOT_VALUE, false); if (ret) - goto release_firmware; + return ret; msleep(MXT_RESET_TIME); /* Do not need to scan since we know family ID */ ret = mxt_lookup_bootloader_address(data, 0); if (ret) - goto release_firmware; + return ret; mxt_sysfs_remove(data); mxt_free_input_device(data); @@ -3305,6 +3292,30 @@ static int mxt_load_fw(struct device *dev) reinit_completion(&data->bl_completion); + return 0; +} + +static int mxt_load_fw(struct device *dev) +{ + struct mxt_data *data = dev_get_drvdata(dev); + struct mxt_flash f = { 0, }; + int ret; + + ret = request_firmware(&f.fw, data->fw_name, dev); + if (ret) { + dev_err(dev, "Unable to open firmware %s\n", data->fw_name); + return ret; + } + + /* Check for incorrect enc file */ + ret = mxt_check_firmware_format(dev, f.fw); + if (ret) + goto release_firmware; + + ret = mxt_enter_bootloader(data); + if (ret) + goto release_firmware; + ret = mxt_check_bootloader(data, MXT_WAITING_BOOTLOAD_CMD, false); if (ret) { /* Bootloader may still be unlocked from previous attempt */ -- 2.17.1