Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3209524pxb; Sat, 9 Oct 2021 04:53:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjEwLHIzX+zauaUAqnqMC7CVj0zkQ5M7WY3pOQw6rTfgtELVDD5zvKpQlB3IkpOW4mg3xx X-Received: by 2002:a05:6402:21eb:: with SMTP id ce11mr22819246edb.153.1633780395194; Sat, 09 Oct 2021 04:53:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633780395; cv=none; d=google.com; s=arc-20160816; b=cm62+51uX5tBTeOYPYHguES5kJ1XSnbXPWOfwlQ03ygcqKNGMwx3Bu0Glz2GdtjgOM PtRhqrTMwn4hzbOBcotheWMYK/z8iB6JmIkg1ACp6QyTHqGU0NpcCOrJbTEI7WL0yKVn AOutuMkIM4FQUA+fEwPCaIXRbJi5lNu9wTX9wmSed2ju1QY51FmL3OQTEbnAitdNHaWB nEk+dxvKItAUs7NzlxmjRUyHfZf/89f+vxZy7OQ9i6xOLsW/91rmiAsvGdhXSLJ6fCZO pCG8LvRyoxWBHxI2vmHhfOKpTH+j6L//Q/4CVfF8U/hTrOEJ0Mhf661WfyPoCn7JLBy9 r5gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=5B7osALGkMq4z6TfUD8C4USTTOHwH17luAiTHWn99ns=; b=gfodXBObK3UHd3kjbclrOug5v0SJlbaQZkufPsSsgDMHHZgL1LYEKLahml8BO6vgwv cAHSaag7KnedltM8doEQCA3eOim6t/AEfT9ng33L0SovVV3WN/W4A9UrMX4dKlRzsaR2 Iy2IKLjxMMvtF3knhryaCe1PtNvHOJqBGu34GfRsHNgae/GZlJUUImvTWkb8wXZ9LWFI KHcr5bmeJUf5piTY+ZHxxPI/+yoACT700/J/zzJoDHZwjMf7HUhwXgtp8fIt7zyG8j/6 x06IiSv9abod4BW5ZMZFz9AhXifbwEAxkuiynl3swdomPjvsJgLQGc1FovgohYlIUf01 a38g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alistair23.me header.s=fm2 header.b=Vb1pAROw; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=gUEfmhWg; 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 i15si4377036edc.275.2021.10.09.04.52.52; Sat, 09 Oct 2021 04:53:15 -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=@alistair23.me header.s=fm2 header.b=Vb1pAROw; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=gUEfmhWg; 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 S244762AbhJILxV (ORCPT + 99 others); Sat, 9 Oct 2021 07:53:21 -0400 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:43205 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244777AbhJILxL (ORCPT ); Sat, 9 Oct 2021 07:53:11 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id 8DD47580542; Sat, 9 Oct 2021 07:51:14 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sat, 09 Oct 2021 07:51:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alistair23.me; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=5B7osALGkMq4z 6TfUD8C4USTTOHwH17luAiTHWn99ns=; b=Vb1pAROwysxO4IATx/iEZxsvwJA3K zVf3Y8AmAgrzke2OPYeoJtZBQ3c4bA2hy6EJ86Nb3x7XEv++Utltwyb4IUnHFGQs R45VP2ZcAZutb8HjavRxyrvVhe1Zq72Dk2UowYHQofEsP3wYjZbTUPdouibDB9Ng 17N2CUIyWepxC/CkJnd9ZwFxf0XSv9lytcpFbgjDxOeeOgLpt4rPs8pbPWqFSIvQ WUkFHkmAgK81tLE4TmJlTgDp4qQbJrL8HL1hODmrB83nN+V/qIE/mEPTeh0Sz+Xd +/GJpzmXXSDWYma0IvzWm+x5fjTDAmqYcBN8dFsk4SVOMEIlM2K6CFIQA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=5B7osALGkMq4z6TfUD8C4USTTOHwH17luAiTHWn99ns=; b=gUEfmhWg mplpy4yPWtX1gOtKXYj5x9xafH1A7COtvZBzLSzZcvLxl2Oc1sQYUfvivpTcFsvE AuiHyRoWUIfR+s8XgrCvruautCr8DCLApokLOHvq/CLBz1g3d/+G1b796UETCnXe bxASw6IX1AkdD0q80LVfRsiIxKqkGLKxRruW8QH8Vgp3uR8za5fcsV6r2+cL32wB wIKOOvsbwI+VqSmPjpYMQ7gQfdifXCxpY/XThdw+hP0k/lngAuFl6X9RGysSJ3V2 OlAlEna0q9QWWh50nKma3H+20pMnUhutQHsUON6M6hEcuCBoKZKwoCwSTWQMq2ne j/k/yOzJGdiT5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddtvddggeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefhvffufffkofgjfhgggfestdekre dtredttdenucfhrhhomheptehlihhsthgrihhrucfhrhgrnhgtihhsuceorghlihhsthgr ihhrsegrlhhishhtrghirhdvfedrmhgvqeenucggtffrrghtthgvrhhnpeeggedtteejke eggeeugfehueevudegvdetjeeviedugedvtdekffekhedtteduhfenucevlhhushhtvghr ufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhishhtrghirhesrghlih hsthgrihhrvdefrdhmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 9 Oct 2021 07:51:09 -0400 (EDT) From: Alistair Francis To: lee.jones@linaro.org, robh+dt@kernel.org, lgirdwood@gmail.com, broonie@kernel.org, kernel@pengutronix.de Cc: shawnguo@kernel.org, s.hauer@pengutronix.de, linux-imx@nxp.com, amitk@kernel.org, rui.zhang@intel.com, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, alistair23@gmail.com, linux-hwmon@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, Alistair Francis Subject: [PATCH 4/7] capsules: sha: Continue reducing code size Date: Sat, 9 Oct 2021 21:50:24 +1000 Message-Id: <20211009115031.18392-6-alistair@alistair23.me> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211009115031.18392-1-alistair@alistair23.me> References: <20211009115031.18392-1-alistair@alistair23.me> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alistair Francis Signed-off-by: Alistair Francis --- capsules/src/sha.rs | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/capsules/src/sha.rs b/capsules/src/sha.rs index a296bc6bc..0d2667e22 100644 --- a/capsules/src/sha.rs +++ b/capsules/src/sha.rs @@ -443,28 +443,27 @@ impl< allow_num: usize, mut slice: ReadOnlyProcessBuffer, ) -> Result { - let res = match allow_num { - // Pass buffer for the data to be in - 1 => self - .apps - .enter(appid, |app, _| { - mem::swap(&mut app.data, &mut slice); - Ok(()) - }) - .unwrap_or(Err(ErrorCode::FAIL)), + let res = self + .apps + .enter(appid, |app, _| { + match allow_num { + // Pass buffer for the data to be in + 1 => { + mem::swap(&mut app.data, &mut slice); + Ok(()) + } - // Compare buffer for verify - 2 => self - .apps - .enter(appid, |app, _| { - mem::swap(&mut app.compare, &mut slice); - Ok(()) - }) - .unwrap_or(Err(ErrorCode::FAIL)), + // Compare buffer for verify + 2 => { + mem::swap(&mut app.compare, &mut slice); + Ok(()) + } - // default - _ => Err(ErrorCode::NOSUPPORT), - }; + // default + _ => Err(ErrorCode::NOSUPPORT), + } + }) + .unwrap_or(Err(ErrorCode::FAIL)); match res { Ok(()) => Ok(slice), -- 2.31.1