Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp3209644pxb; Sat, 9 Oct 2021 04:53:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/Wj5TPeH5PmDb4vQTiAIclmQoTIbVH0gWnsPy+Rw6bFG99hPJrmkQKYcA7lVTaubEDy24 X-Received: by 2002:a05:6402:520b:: with SMTP id s11mr4062653edd.123.1633780410727; Sat, 09 Oct 2021 04:53:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633780410; cv=none; d=google.com; s=arc-20160816; b=TECKyJmRTUGhVc1Z5+P0Gf8eITJYu2//RJjbK3t7f9GqYgQx6iFYmft1f8iEW9gkZN t7qLes6i8kc2iF5iv/GjsQwxhXhe77i7fbPXoYMkMVO0Jp9rpb8LdGHfQQvzYeVywa5O aSDpaYLFvuQlF3/CB2nP8eJSSRIK8jI+xwOLquD5vtA6EJT775JS+qkE2FOpjtncd7hy JE9nNLZ6wPIqKFrxsLnHJ558nysfkZDvncPdo3GDZIpL/E6/XYqVmtSTf+O/UpMVhTXm ViQUt9YeVUtOrqYzdIp4b2GuPFLXKKhO0uEYJcSdbzajuCU8iplgU9IJHLnKmKQjfc98 Wv4w== 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=JmrAk6lslDeRq3HtNAosrHiHpleBbi7+FujnFXzxuU0=; b=qmW87486JxpZzsWCjeaTGRswlgcRcS9R79sDeLT3TWQOGdjXNRMoMKuC7fsTNE3BqB Pgu1UR/M1JU5YNDasFdIDiZTSfaUpaRwHCAsZOme8Lpp6FmkTn3jFaROJVOD75FEuF/J s1hfAqQ/dVeuuTDgSdJHs729wwtzjtFvK4Kqa2MxrtV9fJ5WVZfo/6zmwXIm7BXXL59x mCHs1qoquXkClgUG9IA4zly6hRNdCfcToeufxb+ELksGaPCIR6Z+hZPW7HSxvKPacuC5 H6vYc1fx9IEmWOkyFu9aPHtg4oMGq/NKOtAVA0VpPIhgr04E50xfNEvV8X7R+7eY/zTA fy6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alistair23.me header.s=fm2 header.b=a9jASffo; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=jifjRidy; 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 s4si3143177eju.487.2021.10.09.04.53.07; Sat, 09 Oct 2021 04:53:30 -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=a9jASffo; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=jifjRidy; 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 S244845AbhJILxZ (ORCPT + 99 others); Sat, 9 Oct 2021 07:53:25 -0400 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:36661 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244798AbhJILxW (ORCPT ); Sat, 9 Oct 2021 07:53:22 -0400 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 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/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), -- 2.31.1