From patchwork Sat Oct 9 11:50:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 12547603 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BBBAC433F5 for ; Sat, 9 Oct 2021 11:55:06 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 653A260EE9 for ; Sat, 9 Oct 2021 11:55:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 653A260EE9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=alistair23.me Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=1Mc84PEMDzI2fB+hrp7AAL5nbilVO+nZJHUpwySiGEg=; b=XUGJ+CEAZ92Kxk tjQcPaagScLJWWPfW7HLpxFeLznGIjz4TIFITURFrS9Kw2XYZUe8wth8G1Om20Qno48YGG2ufS+tp 5iaKcFzH8A9YN+jNF1sJLUGZkrpBRuh3EwE5eO/9VRynohiPupEf79PnmCcnpLXU4edN0ZUm/Ob56 UuiM7Qe0hf8PBowleUdR+4/WexeV3vdzTDQYBuCcNylb5ARYT9rXPUPrnNCN2rbWTswlU7dZKEpPm aOvd/VVBaGWu3WuHLP21axnunUAbtHTrzmCUKStPAvd0kdS84X2SlDYa2CiZ4iCBGL4vZFIwpqYTB rlvzkaW4+Cc8O9fZbwXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZAuZ-005WnA-Cc; Sat, 09 Oct 2021 11:53:07 +0000 Received: from new3-smtp.messagingengine.com ([66.111.4.229]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZAsv-005VxA-SO for linux-arm-kernel@lists.infradead.org; Sat, 09 Oct 2021 11:51:27 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 3B3C458055A; Sat, 9 Oct 2021 07:51:25 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sat, 09 Oct 2021 07:51:25 -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=JmrAk6lslDeRq 3HtNAosrHiHpleBbi7+FujnFXzxuU0=; b=a9jASffo+ouzTcQbMF/wWeyVROh29 Eq8LUJxa0ujsDLXo7W7UqO7LsGhSeJcIazKOG5Cua58Lk56XEy5kk1KDNQGFyHuw 4ZQ4L+p9nnrCrR/redQsfd7++ZObqJX8IN6yOn9oXgA+I3Ms2QbZ++C/P6YU9MCM GWpKN9+KfeIcpFzHuSXhR9artJaEwIBXPywUeDXDm94Bxy37JqYzOZK4lmB0voSK t+QbUg46GnCQRIzwny4qg/p04Fxp/0vUIpPxlUzi/BkPveu2d6+uArgFnS3DMK3r BNv2/c7xFc+G4+HcCJAQrUK9VroD0kQkx3gZxwU+ki2HbIG/li0VY1WqA== 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=JmrAk6lslDeRq3HtNAosrHiHpleBbi7+FujnFXzxuU0=; b=jifjRidy 6ivREx2qZJVJnYB/SDTETrCzc0E6gNKxNGEmaLunPXlJH/NcaOfgE22JhTIZ65yh P5j12PxlXaHsCsdKlqUj4XEN+YEjEmpnmSebPZyCVGEUHWpZ09dNKELycPtNS0/N b60stEAEfwQ9vZQaPfffauAjkPYTyTg68K28DwXWyJDyEbIGBEo4f3/ZSI/7ZLze 2aiY70HsZ+0qMtWrY4SSkF+8LkL5yLye7Tod34MV26ClKDargu5p9TES12FT41RQ HxtCVZKoWuXOHx9ZbrhFK4nkNXzc/6vu18FqNtLRbyQ3pIu3g6UaSD87oNXiojzf 5tveUnbnRALvOg== 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:20 -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 5/7] capsules: hmac: Continue reducing code size Date: Sat, 9 Oct 2021 21:50:26 +1000 Message-Id: <20211009115031.18392-8-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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211009_045126_050902_7F0300BE X-CRM114-Status: UNSURE ( 7.71 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Alistair Francis Signed-off-by: Alistair Francis --- capsules/src/hmac.rs | 52 ++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/capsules/src/hmac.rs b/capsules/src/hmac.rs index 83d1e5ea5..0ea30635b 100644 --- a/capsules/src/hmac.rs +++ b/capsules/src/hmac.rs @@ -478,37 +478,33 @@ impl< allow_num: usize, mut slice: ReadOnlyProcessBuffer, ) -> Result { - let res = match allow_num { - // Pass buffer for the key to be in - 0 => self - .apps - .enter(appid, |app, _| { - mem::swap(&mut app.key, &mut slice); - Ok(()) - }) - .unwrap_or(Err(ErrorCode::FAIL)), + let res = self + .apps + .enter(appid, |app, _| { + match allow_num { + // Pass buffer for the key to be in + 0 => { + mem::swap(&mut app.key, &mut slice); + Ok(()) + } - // 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)), + // 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),