From patchwork Wed Apr 10 11:58:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13624165 X-Patchwork-Delegate: mail@conchuod.ie Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DDAB2CD128A for ; Wed, 10 Apr 2024 11:58:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gCFNNIrXG5IMppTzD24wHQ8BAaE3wdPSCehtkTpv5Ew=; b=MBbXiFLhV3AU/w Kxcyym3iAH2RqWrWSPHieomlv55zpe81kzxTklMuhEcosH3tg6jsvjlWPeoIKxiGFvvXPWVxKApGH CtH9DBI9FKr5HzQA+Cv7aTXey0F4xav92xaLgUT5d3t4bn9Ny11aLMg70civd3ewFaoAufrxqhURa Sez1MXhzFfJer9q56MQSbujJI3t7DS3b7bvy+XcuCnioMU8lq/GPvmUc7UcYihcNv8919ohFtcqMa UNYU3v2LsX48/xFJUSCbMCrJKpmLetXT9JruLae2fuoNwU3PuP6f8g/4xihrWv/466ylFDKFdPanu GOeuLnQM2jMAIF763WiQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWbM-00000006li2-2Yb8; Wed, 10 Apr 2024 11:58:52 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWbG-00000006lcc-03ff for linux-riscv@lists.infradead.org; Wed, 10 Apr 2024 11:58:47 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id E4E53CE27B3; Wed, 10 Apr 2024 11:58:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93A5BC43390; Wed, 10 Apr 2024 11:58:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712750322; bh=hLF5VZ17pcPT+iEdSikbSqPPdiOP/ae+ULNTI7IT42U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g6+1JWy2ltqVeLACEyfTQQ8B+ANNmaXO+i0uHM7LnBIiDhS1LVx6wLMBWvpq4UqAh zWU3yRPQs2pq5PSPzXMOwdKbEQqkQr2U8unUIwUM4PvfhQyDpoOYk+dZNInNtTtUS4 6ppi8bYj/seXUUzuAhIDE5P8hzJEZ9YVQID5aiNMntUxHpoyMNIHrNbdUsVOuUVL8G WjZC5VblrRl7YHzpdl21FfZpPC1F0r0O1V8IYzh3NetWJ6s3d1jPIv2HKl53/5icQY CM9EDjCCZxcRoWthEsmsuV/zS+SKcSCoD2RNLV6TZjgqEvtPeMuvh8T8Jw/QTIoG/h wXyzcc/GWqRBA== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Daire McNamara , Cyril Jean , linux-kernel@vger.kernel.org Subject: [PATCH v1 1/5] firmware: microchip: support writing bitstream info to flash Date: Wed, 10 Apr 2024 12:58:04 +0100 Message-ID: <20240410-shabby-fineness-6e8662cf44e2@spud> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410-opulently-epic-8654bdac3422@spud> References: <20240410-opulently-epic-8654bdac3422@spud> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4272; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=Mheo3lXIW1m+cEZnaJh1zYtTPgF5wFDCI953hFakqwY=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDGlidVe62P1CVnpYFjuaKwXP62QWc3Jrz97DM+0aE1N6f WLQ1A8dpSwMYhwMsmKKLIm3+1qk1v9x2eHc8xZmDisTyBAGLk4BmEjQQkaGbX8bv/nsVs6/Zzg1 xar7tOK50F95VywLck++bknStJ69l+EP11/9D2nJW8xXhEm0H5+f/NTF7eR7J7cbLucUOzcvfCn NCQA= X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_045846_444926_B057EA7D X-CRM114-Status: GOOD ( 17.68 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Conor Dooley Updating the FPGA image might bring with it changes visible to Linux, so it is helpful to also co-locate dt-overlays that describe the new image contents. If these are packaged in a specific format [1] (detected by first 4 bytes being MCHP, since FPGA images have no magic), load the file to the reserved 1 MiB region immediately after the directory in flash. The Beagle-V Fire's "gateware" already creates these files and puts them in flash [2]. Link: exists on confluence, needs to be made public Link: https://openbeagle.org/beaglev-fire/gateware/-/blob/main/gateware_scripts/generate_gateware_overlays.py?ref_type=heads [2] Signed-off-by: Conor Dooley --- drivers/firmware/microchip/mpfs-auto-update.c | 47 +++++++++++++++---- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/microchip/mpfs-auto-update.c b/drivers/firmware/microchip/mpfs-auto-update.c index 32394c24b37d..33343e83373c 100644 --- a/drivers/firmware/microchip/mpfs-auto-update.c +++ b/drivers/firmware/microchip/mpfs-auto-update.c @@ -71,8 +71,9 @@ #define AUTO_UPDATE_UPGRADE_DIRECTORY (AUTO_UPDATE_DIRECTORY_WIDTH * AUTO_UPDATE_UPGRADE_INDEX) #define AUTO_UPDATE_BLANK_DIRECTORY (AUTO_UPDATE_DIRECTORY_WIDTH * AUTO_UPDATE_BLANK_INDEX) #define AUTO_UPDATE_DIRECTORY_SIZE SZ_1K -#define AUTO_UPDATE_RESERVED_SIZE SZ_1M -#define AUTO_UPDATE_BITSTREAM_BASE (AUTO_UPDATE_DIRECTORY_SIZE + AUTO_UPDATE_RESERVED_SIZE) +#define AUTO_UPDATE_INFO_BASE AUTO_UPDATE_DIRECTORY_SIZE +#define AUTO_UPDATE_INFO_SIZE SZ_1M +#define AUTO_UPDATE_BITSTREAM_BASE (AUTO_UPDATE_DIRECTORY_SIZE + AUTO_UPDATE_INFO_SIZE) #define AUTO_UPDATE_TIMEOUT_MS 60000 @@ -86,6 +87,17 @@ struct mpfs_auto_update_priv { bool cancel_request; }; +static bool mpfs_auto_update_is_bitstream_info(const u8 *data, u32 size) +{ + if (size < 4) + return false; + + if (data[0] == 0x4d && data[1] == 0x43 && data[2] == 0x48 && data[3] == 0x50) + return true; + + return false; +} + static enum fw_upload_err mpfs_auto_update_prepare(struct fw_upload *fw_uploader, const u8 *data, u32 size) { @@ -287,22 +299,37 @@ static int mpfs_auto_update_write_bitstream(struct fw_upload *fw_uploader, const loff_t directory_address = AUTO_UPDATE_UPGRADE_DIRECTORY; size_t erase_size = AUTO_UPDATE_DIRECTORY_SIZE; size_t bytes_written = 0; + bool is_info = mpfs_auto_update_is_bitstream_info(data, size); u32 image_address; int ret; erase_size = round_up(erase_size, (u64)priv->flash->erasesize); - image_address = AUTO_UPDATE_BITSTREAM_BASE + - AUTO_UPDATE_UPGRADE_INDEX * priv->size_per_bitstream; + if (is_info) + image_address = AUTO_UPDATE_INFO_BASE; + else + image_address = AUTO_UPDATE_BITSTREAM_BASE + + AUTO_UPDATE_UPGRADE_INDEX * priv->size_per_bitstream; buffer = devm_kzalloc(priv->dev, erase_size, GFP_KERNEL); if (!buffer) return -ENOMEM; - ret = mpfs_auto_update_set_image_address(priv, buffer, image_address, directory_address); - if (ret) { - dev_err(priv->dev, "failed to set image address in the SPI directory: %d\n", ret); - goto out; + /* + * For bitstream info, the descriptor is written to a fixed offset, + * so there is no need to set the image address. + */ + if (!is_info) { + ret = mpfs_auto_update_set_image_address(priv, buffer, image_address, directory_address); + if (ret) { + dev_err(priv->dev, "failed to set image address in the SPI directory: %d\n", ret); + return ret; + } + } else { + if (size > AUTO_UPDATE_INFO_SIZE) { + dev_err(priv->dev, "bitstream info exceeds permitted size\n"); + return -ENOSPC; + } } /* @@ -334,6 +361,7 @@ static int mpfs_auto_update_write_bitstream(struct fw_upload *fw_uploader, const } *written = bytes_written; + dev_info(priv->dev, "Wrote 0x%zx bytes to the flash\n", bytes_written); out: devm_kfree(priv->dev, buffer); @@ -360,6 +388,9 @@ static enum fw_upload_err mpfs_auto_update_write(struct fw_upload *fw_uploader, goto out; } + if (mpfs_auto_update_is_bitstream_info(data, size)) + goto out; + ret = mpfs_auto_update_verify_image(fw_uploader); if (ret) err = FW_UPLOAD_ERR_FW_INVALID; From patchwork Wed Apr 10 11:58:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13624162 X-Patchwork-Delegate: mail@conchuod.ie Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1049CD1296 for ; Wed, 10 Apr 2024 11:58:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jjmaOKzdEiZrviKYzrb793U0DBWzxBHkvDpYocsXGZo=; b=C1ZTFzUoKWUIvS mhi1zBe0FP/ZjGHLaPgF4Lo0xGXTt1SqD6pCZV6xLNVpFWjSu6S+4BnIOtqS326RFCrWeoO8vg9OR SJAAd4Z2hzoRCHpBTGEJ+foV2hnAEtJv83/5wIsZuVKHf5ahG8EkoA2gfoBWgqbipUz7SfnEFgoQs lbZAaLdb8kYsXnT8lMmMiaBBkn0qUV61CFOWSYnssTdQke0XhGMzzIF99tFRTlR7Xfm4j3EbBSxuz Mvb7u5A8EyauBVADuoN3onV3OVhLkIgKw+WDR4Sp5Zac9ST546mbg3bu3odk01CGFrYEaqsIgB9WG tQdnDcHO7xgjyXA9pYJA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWbI-00000006lee-3Xph; Wed, 10 Apr 2024 11:58:48 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWbF-00000006lci-2U2L for linux-riscv@lists.infradead.org; Wed, 10 Apr 2024 11:58:46 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id DB9D761C0D; Wed, 10 Apr 2024 11:58:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B724C43394; Wed, 10 Apr 2024 11:58:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712750324; bh=miFooV5xlwUAoCg/5+WmOIw7hiB7FtagEK3Q2jQpBdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LzkTexlUdZzTNblZagdSguoN7Auvwyg5ucQMjlq+cptVQwFQ4S867LO/VGgVQ25q1 VTUXuPxX2YRuFFbOfc+vkQY7WlmW5Jdt4DKt79iebKHmaX7ED+HaeoHFIT0C4ugRL+ rJgJeQsfQG7vm+75L4d7106btgyKMPzToYMmFkXkIS+VxRVQqrhSrvjrzFh3Ga72Gp LbgeBgxre8b7e4fJX64eavrDEv51lh66jxVdQb6vp/RIU6mjy0blehj1w31tybG7kY hfFnXfndpz7KzVwYlROXa+6YdsGM3E40qG5qSaBTLDqrFnbcD4/e2rWYvxmOVYVvlv Oplqn6rf66Z5g== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Daire McNamara , Cyril Jean , linux-kernel@vger.kernel.org Subject: [PATCH v1 2/5] firmware: microchip: don't unconditionally print validation success Date: Wed, 10 Apr 2024 12:58:05 +0100 Message-ID: <20240410-throwing-sandworm-7d03e4e2f4e8@spud> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410-opulently-epic-8654bdac3422@spud> References: <20240410-opulently-epic-8654bdac3422@spud> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1033; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=bV+GMkr+Qxwo4lMIT/B+7/B5KMkZCVAYKLvbSQ6UzsY=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDGlidVesmcN/GW7tkMwrORDPaLzTzH1p8vWTh5Zni3yrb YxN2vu3o5SFQYyDQVZMkSXxdl+L1Po/Ljuce97CzGFlAhnCwMUpABPZIszwv+z3nHNeM45xms/P ifjf1NKtIvw0wGjhOfO0BSdPGqxKsGRkmO7Y8GXVvIqnl019DRTuX808xacV1bN4xZo8zeDmY99 YuAE= X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_045845_704160_E2E18517 X-CRM114-Status: UNSURE ( 7.32 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Conor Dooley If validation fails, both prints are made. Skip the success one in the failure case. Fixes: ec5b0f1193ad ("firmware: microchip: add PolarFire SoC Auto Update support") Signed-off-by: Conor Dooley --- drivers/firmware/microchip/mpfs-auto-update.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/firmware/microchip/mpfs-auto-update.c b/drivers/firmware/microchip/mpfs-auto-update.c index 33343e83373c..298ad21e139b 100644 --- a/drivers/firmware/microchip/mpfs-auto-update.c +++ b/drivers/firmware/microchip/mpfs-auto-update.c @@ -218,10 +218,12 @@ static int mpfs_auto_update_verify_image(struct fw_upload *fw_uploader) if (ret | response->resp_status) { dev_warn(priv->dev, "Verification of Upgrade Image failed!\n"); ret = ret ? ret : -EBADMSG; + goto free_message; } dev_info(priv->dev, "Verification of Upgrade Image passed!\n"); +free_message: devm_kfree(priv->dev, message); free_response: devm_kfree(priv->dev, response); From patchwork Wed Apr 10 11:58:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13624164 X-Patchwork-Delegate: mail@conchuod.ie Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7743ECD11C2 for ; Wed, 10 Apr 2024 11:58:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VBkYYGvT9sqw5L0YnMqs4qJ4IOTrmt+jEvxSIQfkSP0=; b=U1OE9lluutBH2j LjOQLi7KMVHcolkUniUq2FX39fwHdu+s5uAENlGlr4Fr8LlxHHl6mDToKS0jejg5WiDwcqUX9eE6o uVWBUsC2v1wqcegtCMyROeQyU8polOR4b5fdi2/aYS5dIafr8koMhBPdcxZb+fqFjfCb1109W3MZg SQ4oAZgeYQHy3Rlu1AIdiSVSGvQuyf1DnGxGvhrWFe1RNifVEFQDS4fFjqLQ1tjq82DJbnGxhfwuk Z/6I5LuxUJ0G0BDjj6+emDgKyH7EAu1v7PxXNhNSP9gGMd6yxqACDqKVpeDBh8WCY6cJBOmKkvas3 70+DV78a/9UNcfCgTteA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWbO-00000006ljY-2fLU; Wed, 10 Apr 2024 11:58:54 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWbH-00000006ldf-0o0B for linux-riscv@lists.infradead.org; Wed, 10 Apr 2024 11:58:48 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A2F5B61C15; Wed, 10 Apr 2024 11:58:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 224EEC43390; Wed, 10 Apr 2024 11:58:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712750326; bh=I0ucffUjI9S2cz08Ial3I81TqrYvCDbjo9pZBliGHHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t5pvV5ZzYr/RzporQ5oxS0aMfiV+V0q4Y2GxhgF1z79jFoCE0gBmPkJy7lhMoquBE x5z4w5o7IMU/EeUHyW97iTep8pYcNF6KIh+C6IB1CYcLFVxgjZNCMMTbCIvMFB+BwK Szme+Lh+6kyqU/xCcuo6woWbxG6NduD1jomFGw6DXp9AdBzEZ/tjEm8rGLIakgd0RY npZInp/oD3QhFqLgV5ZO/OlqiFRHKixUjPiQCLE4yCKluiRNE6DxYAHJqYLS8Chb01 R6SpQ+opJhACIPLeF7JZyq61Arnb3jTq/ZCsAu1QCNK1g8CO+Q5qModKWlw/T5WglX 0v98rHwxKfdJA== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Daire McNamara , Cyril Jean , linux-kernel@vger.kernel.org Subject: [PATCH v1 3/5] firmware: microchip: clarify that sizes and addresses are in hex Date: Wed, 10 Apr 2024 12:58:06 +0100 Message-ID: <20240410-elk-staleness-285063ef0433@spud> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410-opulently-epic-8654bdac3422@spud> References: <20240410-opulently-epic-8654bdac3422@spud> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2012; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=BNSIAOq6X1LAhr9L0BQrr3EsDDjmIu+xC/kpYkZfVl4=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDGlidVfOqLZ/vnLjSxXD8h3G/DkLbvKtbNCIX7r23GEmu ZX9mnmSHaUsDGIcDLJiiiyJt/tapNb/cdnh3PMWZg4rE8gQBi5OAZgImxEjw9U517olFpwtyuQL X5PH7H3p4OtWvTtsN/foftl8pObDp7cM/5PmMj+azXDi/pYJrpMub31nvWG+4a3j7w7zqk1h1wz beJQFAA== X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_045847_305352_86481BBE X-CRM114-Status: GOOD ( 11.21 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Conor Dooley As it says on the tin. It can be kinda confusing when "22830" is in hex, so prefix the hex numbers with a "0x". Signed-off-by: Conor Dooley --- drivers/firmware/microchip/mpfs-auto-update.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/microchip/mpfs-auto-update.c b/drivers/firmware/microchip/mpfs-auto-update.c index 298ad21e139b..078ff328f261 100644 --- a/drivers/firmware/microchip/mpfs-auto-update.c +++ b/drivers/firmware/microchip/mpfs-auto-update.c @@ -279,7 +279,7 @@ static int mpfs_auto_update_set_image_address(struct mpfs_auto_update_priv *priv AUTO_UPDATE_DIRECTORY_WIDTH); memset(buffer + AUTO_UPDATE_BLANK_DIRECTORY, 0x0, AUTO_UPDATE_DIRECTORY_WIDTH); - dev_info(priv->dev, "Writing the image address (%x) to the flash directory (%llx)\n", + dev_info(priv->dev, "Writing the image address (0x%x) to the flash directory (0x%llx)\n", image_address, directory_address); ret = mtd_write(priv->flash, 0x0, erase_size, &bytes_written, (u_char *)buffer); @@ -342,7 +342,7 @@ static int mpfs_auto_update_write_bitstream(struct fw_upload *fw_uploader, const erase.len = round_up(size, (size_t)priv->flash->erasesize); erase.addr = image_address; - dev_info(priv->dev, "Erasing the flash at address (%x)\n", image_address); + dev_info(priv->dev, "Erasing the flash at address (0x%x)\n", image_address); ret = mtd_erase(priv->flash, &erase); if (ret) goto out; @@ -352,7 +352,7 @@ static int mpfs_auto_update_write_bitstream(struct fw_upload *fw_uploader, const * will do all of that itself - including verifying that the bitstream * is valid. */ - dev_info(priv->dev, "Writing the image to the flash at address (%x)\n", image_address); + dev_info(priv->dev, "Writing the image to the flash at address (0x%x)\n", image_address); ret = mtd_write(priv->flash, (loff_t)image_address, size, &bytes_written, data); if (ret) goto out; From patchwork Wed Apr 10 11:58:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13624167 X-Patchwork-Delegate: mail@conchuod.ie Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94BE0CD11C2 for ; Wed, 10 Apr 2024 11:59:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wiWytukYbZFCL/h1siw3tkkehW2tfnI+mSALMjFgA6c=; b=EU1wUqjLyp0fGw LEcdsk8QVSRPcdZCu2d4v5IdTkx3vp4ECDKEMOBqoBbtGpTvHGmJjRTaoh5Q3aPX+kXKTcHGMFVG5 fJMdM/5fWy/yICCEw0+GoB1N02l/73bOmfbhnsCex3FGc/Bq7mFfN7PFQqpFz0cbT2AE+8q7/Ij6H j0xpUZFO9GMAYgA8u1lHd3IumVUQLFIsoyKMxP5BZJcfsmOUIYOAIY9NgLL0pSWXF6Hf1mk6nYEY5 q3EE+TyZICBrPfy4bwO9WxPbZrCNiRERKZFDiWt5/QFs30QeeljiOfPe4MC+j6PjwX5oIUM76+q1c YTEbPDaJm1RzGiKv4S5A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWbQ-00000006llK-272L; Wed, 10 Apr 2024 11:58:56 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWbI-00000006leZ-3mjU for linux-riscv@lists.infradead.org; Wed, 10 Apr 2024 11:58:50 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6AEDC61BFD; Wed, 10 Apr 2024 11:58:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEC8FC43390; Wed, 10 Apr 2024 11:58:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712750328; bh=zozmtpGCyzauq3lW42w4fnyusZzE+3jFnWSCycg+74w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ki2sL3MhTeMJTG3avbeH1rzNAe7ciJKLADcUu1fQX6z8ruJDN7zDZ+xQ8xSe28t4h YhkH6vqfVaZHU9te9wWvdi5pPKlKDCnRBeBnjIV+Rc48jKhTKBYFD9oeQnL8J4GVZb HVMEZKtFzlB2SOMIasbDU9Gzk2dtbZAuEFDIbmsoSKiape4vzIXXDm8sijBmwY5Sti iWJMcaxZjcQBA1vjeI1rInOjnB4e6VQaeljR0Y+zBZYvOIb0L+mTukLCuWeoyiufay ojFtgFrSaLueQnp9nfK2cr9h0aQ0arl+iRMn1B6ZC2csTJ49/U9Iqe4gmILb/nxfra gCiQ6tAqghoyw== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Daire McNamara , Cyril Jean , linux-kernel@vger.kernel.org Subject: [PATCH v1 4/5] firmware: microchip: move buffer allocation into mpfs_auto_update_set_image_address() Date: Wed, 10 Apr 2024 12:58:07 +0100 Message-ID: <20240410-manhood-gathering-41ccbfdad649@spud> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410-opulently-epic-8654bdac3422@spud> References: <20240410-opulently-epic-8654bdac3422@spud> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4105; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=wFllIaLoSb4Gw+0g2yEUZWRr6LUeHyCfKeT7QJ6ExZU=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDGlidVd1lBOmeBjKi02Xe3uSP7V/Pf+C1dOcTPVPX1Z9I PRvlXV4RykLgxgHg6yYIkvi7b4WqfV/XHY497yFmcPKBDKEgYtTACbS6srIMPltMsdPBVHxzU9W FgTfqeLbN4m7+g1P2V2hKvkzOg+vpjEyXJ/q3iv1ePUiRh2XM1fvnfeUiNvy4aifBX/iRq4z6fp 57AA= X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_045849_142719_5FFE74CE X-CRM114-Status: GOOD ( 14.12 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Conor Dooley This buffer is used exclusively by mpfs_auto_update_set_image_address(), so move the management of it there, employing the recently added cleanup infrastructure to avoid littering the function with gotos. Signed-off-by: Conor Dooley --- drivers/firmware/microchip/mpfs-auto-update.c | 32 ++++++++----------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/drivers/firmware/microchip/mpfs-auto-update.c b/drivers/firmware/microchip/mpfs-auto-update.c index 078ff328f261..d7ce27f4ba1b 100644 --- a/drivers/firmware/microchip/mpfs-auto-update.c +++ b/drivers/firmware/microchip/mpfs-auto-update.c @@ -9,6 +9,7 @@ * * Author: Conor Dooley */ +#include #include #include #include @@ -233,15 +234,17 @@ static int mpfs_auto_update_verify_image(struct fw_upload *fw_uploader) return ret; } -static int mpfs_auto_update_set_image_address(struct mpfs_auto_update_priv *priv, char *buffer, +static int mpfs_auto_update_set_image_address(struct mpfs_auto_update_priv *priv, u32 image_address, loff_t directory_address) { struct erase_info erase; - size_t erase_size = AUTO_UPDATE_DIRECTORY_SIZE; + size_t erase_size = round_up(AUTO_UPDATE_DIRECTORY_SIZE, (u64)priv->flash->erasesize); size_t bytes_written = 0, bytes_read = 0; + char *buffer __free(kfree) = kzalloc(erase_size, GFP_KERNEL); int ret; - erase_size = round_up(erase_size, (u64)priv->flash->erasesize); + if (!buffer) + return -ENOMEM; erase.addr = AUTO_UPDATE_DIRECTORY_BASE; erase.len = erase_size; @@ -287,7 +290,7 @@ static int mpfs_auto_update_set_image_address(struct mpfs_auto_update_priv *priv return ret; if (bytes_written != erase_size) - return ret; + return -EIO; return 0; } @@ -297,7 +300,6 @@ static int mpfs_auto_update_write_bitstream(struct fw_upload *fw_uploader, const { struct mpfs_auto_update_priv *priv = fw_uploader->dd_handle; struct erase_info erase; - char *buffer; loff_t directory_address = AUTO_UPDATE_UPGRADE_DIRECTORY; size_t erase_size = AUTO_UPDATE_DIRECTORY_SIZE; size_t bytes_written = 0; @@ -313,16 +315,12 @@ static int mpfs_auto_update_write_bitstream(struct fw_upload *fw_uploader, const image_address = AUTO_UPDATE_BITSTREAM_BASE + AUTO_UPDATE_UPGRADE_INDEX * priv->size_per_bitstream; - buffer = devm_kzalloc(priv->dev, erase_size, GFP_KERNEL); - if (!buffer) - return -ENOMEM; - /* * For bitstream info, the descriptor is written to a fixed offset, * so there is no need to set the image address. */ if (!is_info) { - ret = mpfs_auto_update_set_image_address(priv, buffer, image_address, directory_address); + ret = mpfs_auto_update_set_image_address(priv, image_address, directory_address); if (ret) { dev_err(priv->dev, "failed to set image address in the SPI directory: %d\n", ret); return ret; @@ -345,7 +343,7 @@ static int mpfs_auto_update_write_bitstream(struct fw_upload *fw_uploader, const dev_info(priv->dev, "Erasing the flash at address (0x%x)\n", image_address); ret = mtd_erase(priv->flash, &erase); if (ret) - goto out; + return ret; /* * No parsing etc of the bitstream is required. The system controller @@ -355,19 +353,15 @@ static int mpfs_auto_update_write_bitstream(struct fw_upload *fw_uploader, const dev_info(priv->dev, "Writing the image to the flash at address (0x%x)\n", image_address); ret = mtd_write(priv->flash, (loff_t)image_address, size, &bytes_written, data); if (ret) - goto out; + return ret; - if (bytes_written != size) { - ret = -EIO; - goto out; - } + if (bytes_written != size) + return -EIO; *written = bytes_written; dev_info(priv->dev, "Wrote 0x%zx bytes to the flash\n", bytes_written); -out: - devm_kfree(priv->dev, buffer); - return ret; + return 0; } static enum fw_upload_err mpfs_auto_update_write(struct fw_upload *fw_uploader, const u8 *data, From patchwork Wed Apr 10 11:58:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Conor Dooley X-Patchwork-Id: 13624166 X-Patchwork-Delegate: mail@conchuod.ie Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6A8DBCD128A for ; Wed, 10 Apr 2024 11:59:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=P7TKrlnLowpQ0210zGQ9lq7xJwyu+tlt94VCfwx/Pgg=; b=pKoWuUD/tpzPsJ j7Kt9SZydT1+5qS2ntw1ndRnNsLyjrVi5P7DBT28CH6sOM0XLFf2mBFA6MI7CFxcVAqLZX/zgaKm+ b3CKVAgIZ5bu8Xp5qogNzv988uKmFXbf8FB8jqs5c3d1nyG+Hh6+hpeGSH/OpIDhVHqqOJVPtR4Xf H35KpDRexm/bO5hhUzm1XxlNX3xXd1sBgpY3NsnPdvEIhI2bNIYxrbJxrG2nt5VqEWWlQ57bYE62N c0gRUdNIPP0JVkm6S7S1KTkuWGsoOUMbTBaLCeqhOyLuOTUMaqm1r/pAJ+gVhkRGa6LhBrHvRwlYJ PpXGKmFyzsBO0V1Mnkog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWbR-00000006lmg-3yOc; Wed, 10 Apr 2024 11:58:57 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ruWbK-00000006lfz-328b for linux-riscv@lists.infradead.org; Wed, 10 Apr 2024 11:58:52 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 31C8761C0C; Wed, 10 Apr 2024 11:58:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6690C433F1; Wed, 10 Apr 2024 11:58:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712750330; bh=rZ17Zq2r5GglmuwlVZDKvybg4wn7yP4nbMxcY1IRFwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sYY9z9jcmEO9tTdM8vBgKwQv8FfuqM0s1bASlPyB8S1nbwPNs2+QMU+gpzIG9K6HC 2Yoei5a+E1SBFZ78y6zTcN+ITA/9bl3K7XxPYKRIZPiPFLDy5XUdAcsbVC3anuBBXw g+NR7hD89euUY0/BntKr9OWjSxjn+LOXKXrGj4nLuS5k0jwUFfjQgUesO6PDRxxphQ a8d5GUkxpVC3ipWpreiUrRUym9Jy5U+L6vpZe8L1vdrFfWijsvtTsVC8EPlFaC+KZn PYkDjpWxomEjg3pTnTXGrWq+w6PRuP+vBqEBohOHO9X1C0fdWdpNE21WkD0De6eez0 gLWvdA17qTVsA== From: Conor Dooley To: linux-riscv@lists.infradead.org Cc: conor@kernel.org, Conor Dooley , Daire McNamara , Cyril Jean , linux-kernel@vger.kernel.org Subject: [PATCH v1 5/5] firmware: microchip: use scope-based cleanup where possible Date: Wed, 10 Apr 2024 12:58:08 +0100 Message-ID: <20240410-glory-patriot-2d7c7876dcfe@spud> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240410-opulently-epic-8654bdac3422@spud> References: <20240410-opulently-epic-8654bdac3422@spud> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3938; i=conor.dooley@microchip.com; h=from:subject:message-id; bh=0WayOjS6Zyrbw3ItGJG9W3xsEKlmQEnuZ+2GI5oj4yg=; b=owGbwMvMwCFWscWwfUFT0iXG02pJDGlidVfT0uZ3P5i5Me39ZkGnq/U8rSpnHH9HVxjqTKkLK 7zx2Uq0o5SFQYyDQVZMkSXxdl+L1Po/Ljuce97CzGFlAhnCwMUpABNxWsHw36v1/Jo7G90V2U+6 XHXk051U6pXF8euz5hb5F0tnHBa5uZqRYefGd3/F2VQYhazl7R5/sHtbK/RP70suW5PTuW4JC3F ndgA= X-Developer-Key: i=conor.dooley@microchip.com; a=openpgp; fpr=F9ECA03CF54F12CD01F1655722E2C55B37CF380C X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240410_045851_001738_A4D1BF6B X-CRM114-Status: GOOD ( 13.19 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Conor Dooley There's a bunch of structs created and freed every time the mailbox is used. Move them to use the scope-based cleanup infrastructure to avoid manually tearing them down. mpfs_auto_update_available() didn't free the memory that it used (albeit it allocated exactly once during probe) so that gets moved over too. Signed-off-by: Conor Dooley --- drivers/firmware/microchip/mpfs-auto-update.c | 59 +++++-------------- 1 file changed, 16 insertions(+), 43 deletions(-) diff --git a/drivers/firmware/microchip/mpfs-auto-update.c b/drivers/firmware/microchip/mpfs-auto-update.c index d7ce27f4ba1b..30de47895b1c 100644 --- a/drivers/firmware/microchip/mpfs-auto-update.c +++ b/drivers/firmware/microchip/mpfs-auto-update.c @@ -175,28 +175,17 @@ static enum fw_upload_err mpfs_auto_update_poll_complete(struct fw_upload *fw_up static int mpfs_auto_update_verify_image(struct fw_upload *fw_uploader) { struct mpfs_auto_update_priv *priv = fw_uploader->dd_handle; - struct mpfs_mss_response *response; - struct mpfs_mss_msg *message; - u32 *response_msg; + u32 *response_msg __free(kfree) = + kzalloc(AUTO_UPDATE_FEATURE_RESP_SIZE * sizeof(*response_msg), GFP_KERNEL); + struct mpfs_mss_response *response __free(kfree) = + kzalloc(sizeof(struct mpfs_mss_response), GFP_KERNEL); + struct mpfs_mss_msg *message __free(kfree) = + kzalloc(sizeof(struct mpfs_mss_msg), GFP_KERNEL); int ret; - response_msg = devm_kzalloc(priv->dev, AUTO_UPDATE_FEATURE_RESP_SIZE * sizeof(response_msg), - GFP_KERNEL); - if (!response_msg) + if (!response_msg || !response || !message) return -ENOMEM; - response = devm_kzalloc(priv->dev, sizeof(struct mpfs_mss_response), GFP_KERNEL); - if (!response) { - ret = -ENOMEM; - goto free_response_msg; - } - - message = devm_kzalloc(priv->dev, sizeof(struct mpfs_mss_msg), GFP_KERNEL); - if (!message) { - ret = -ENOMEM; - goto free_response; - } - /* * The system controller can verify that an image in the flash is valid. * Rather than duplicate the check in this driver, call the relevant @@ -218,20 +207,12 @@ static int mpfs_auto_update_verify_image(struct fw_upload *fw_uploader) ret = mpfs_blocking_transaction(priv->sys_controller, message); if (ret | response->resp_status) { dev_warn(priv->dev, "Verification of Upgrade Image failed!\n"); - ret = ret ? ret : -EBADMSG; - goto free_message; + return ret ? ret : -EBADMSG; } dev_info(priv->dev, "Verification of Upgrade Image passed!\n"); -free_message: - devm_kfree(priv->dev, message); -free_response: - devm_kfree(priv->dev, response); -free_response_msg: - devm_kfree(priv->dev, response_msg); - - return ret; + return 0; } static int mpfs_auto_update_set_image_address(struct mpfs_auto_update_priv *priv, @@ -406,23 +387,15 @@ static const struct fw_upload_ops mpfs_auto_update_ops = { static int mpfs_auto_update_available(struct mpfs_auto_update_priv *priv) { - struct mpfs_mss_response *response; - struct mpfs_mss_msg *message; - u32 *response_msg; + u32 *response_msg __free(kfree) = + kzalloc(AUTO_UPDATE_FEATURE_RESP_SIZE * sizeof(*response_msg), GFP_KERNEL); + struct mpfs_mss_response *response __free(kfree) = + kzalloc(sizeof(struct mpfs_mss_response), GFP_KERNEL); + struct mpfs_mss_msg *message __free(kfree) = + kzalloc(sizeof(struct mpfs_mss_msg), GFP_KERNEL); int ret; - response_msg = devm_kzalloc(priv->dev, - AUTO_UPDATE_FEATURE_RESP_SIZE * sizeof(*response_msg), - GFP_KERNEL); - if (!response_msg) - return -ENOMEM; - - response = devm_kzalloc(priv->dev, sizeof(struct mpfs_mss_response), GFP_KERNEL); - if (!response) - return -ENOMEM; - - message = devm_kzalloc(priv->dev, sizeof(struct mpfs_mss_msg), GFP_KERNEL); - if (!message) + if (!response_msg || !response || !message) return -ENOMEM; /*