Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5326015ybv; Tue, 11 Feb 2020 13:33:46 -0800 (PST) X-Google-Smtp-Source: APXvYqwFdkfg9/pWnM+yIRyUxLmVsKRDDC57He4KXIh00Wk4fLMlesVXkgiU/g2paenwiEpk8rlE X-Received: by 2002:aca:1913:: with SMTP id l19mr3982695oii.47.1581456826156; Tue, 11 Feb 2020 13:33:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581456826; cv=none; d=google.com; s=arc-20160816; b=zYVwTDbjI1kvSUUsTn88+f/OEy9E+UuVT+2jqTxEiHYcKwCX3ZYTLkp1kMfcLX6SWL Aw1aus5wioB2p5AFn0DiYSqRAueZnHAmM7o6haEg8CZxTJoO7FvPAYl5hcqKvOZjQG8I PaB5ENLwqUKofP3YmN3pAboNEtOqc3SfTA18C93HQlJdZkr1bjnWrgPny0IfPlRoC0xf yjHR6Kx01cAAD4RVbfYPMMHT0HFq7ln2wbDO6k/AxFntlQCwhLngshdPzJfCSuFucZ1q R3l0NLR0FtHIaojv4PkLDgLHZ+YopaXYwrbfk6lBD3sfW7tD8YLHi7uwxGYNSPCrTZMa iDpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=1kkVXSAKgUNVgDYRGylEMWAcxh+AspRNCnqdEjzWaPk=; b=OXNYKnWsdf1LtqIWQCCxWdfndnm5Qu4TWh8bIjelC2nTn7wKX0FF9lg1AcmKgtj+VI mHL55DIT5JlxodkQnDd/3fKHmjV6VL/1v3QfbrOTaajtqZfPEACeUuZyyI29nmB6S7Bc nUq9ZlA+Al5J9mT5zcYSdfYVFjKT5qyjtaaJ7ZWEV+pQ8pEAUk2Kg9FPV5EGehRSHrom +fqxdE3NzQlNPSNsWW/1OqTMusTZWloLwJ3HvSK8Zo4X2gGRuMzUf9tbJs9AQWr/XIvC OvYa+gcnHfBLvKOIx034vD37NDVF3r+LRItFWfZY5bqq4TJOJMrS0elXA+xMP2l/1j/E tw+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e20si2284068oig.199.2020.02.11.13.33.34; Tue, 11 Feb 2020 13:33:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731275AbgBKSU0 (ORCPT + 99 others); Tue, 11 Feb 2020 13:20:26 -0500 Received: from andre.telenet-ops.be ([195.130.132.53]:34356 "EHLO andre.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730161AbgBKSTd (ORCPT ); Tue, 11 Feb 2020 13:19:33 -0500 Received: from ramsan ([84.195.182.253]) by andre.telenet-ops.be with bizsmtp id 1WKW220015USYZQ01WKWTi; Tue, 11 Feb 2020 19:19:30 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1j1a89-0002oV-Vs; Tue, 11 Feb 2020 19:19:29 +0100 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1j1a89-0003yw-Uf; Tue, 11 Feb 2020 19:19:29 +0100 From: Geert Uytterhoeven To: Gilad Ben-Yossef , Herbert Xu , "David S . Miller" Cc: Greg Kroah-Hartman , "Rafael J . Wysocki" , linux-crypto@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 18/34] crypto: ccree - remove struct cc_sram_ctx Date: Tue, 11 Feb 2020 19:19:12 +0100 Message-Id: <20200211181928.15178-19-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200211181928.15178-1-geert+renesas@glider.be> References: <20200211181928.15178-1-geert+renesas@glider.be> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cc_sram_ctx structure contains only a single member, and only one instance exists. Simplify the code and reduce memory consumption by moving this member to struct cc_drvdata. Signed-off-by: Geert Uytterhoeven --- v2: - New. drivers/crypto/ccree/cc_driver.h | 2 +- drivers/crypto/ccree/cc_sram_mgr.c | 27 +++++---------------------- 2 files changed, 6 insertions(+), 23 deletions(-) diff --git a/drivers/crypto/ccree/cc_driver.h b/drivers/crypto/ccree/cc_driver.h index 9e94a29d84ae61f1..7e483c22858245f9 100644 --- a/drivers/crypto/ccree/cc_driver.h +++ b/drivers/crypto/ccree/cc_driver.h @@ -146,7 +146,7 @@ struct cc_drvdata { void *aead_handle; void *request_mgr_handle; void *fips_handle; - void *sram_mgr_handle; + u32 sram_free_offset; /* offset to non-allocated area in SRAM */ void *debugfs; struct clk *clk; bool coherent; diff --git a/drivers/crypto/ccree/cc_sram_mgr.c b/drivers/crypto/ccree/cc_sram_mgr.c index d46aad7c8140acaa..38f36cbc05b3cf6f 100644 --- a/drivers/crypto/ccree/cc_sram_mgr.c +++ b/drivers/crypto/ccree/cc_sram_mgr.c @@ -4,14 +4,6 @@ #include "cc_driver.h" #include "cc_sram_mgr.h" -/** - * struct cc_sram_ctx -Internal RAM context manager - * @sram_free_offset: the offset to the non-allocated area - */ -struct cc_sram_ctx { - u32 sram_free_offset; -}; - /** * cc_sram_mgr_init() - Initializes SRAM pool. * The pool starts right at the beginning of SRAM. @@ -21,7 +13,6 @@ struct cc_sram_ctx { */ int cc_sram_mgr_init(struct cc_drvdata *drvdata) { - struct cc_sram_ctx *ctx; u32 start = 0; struct device *dev = drvdata_to_dev(drvdata); @@ -34,14 +25,7 @@ int cc_sram_mgr_init(struct cc_drvdata *drvdata) } } - /* Allocate "this" context */ - ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL); - if (!ctx) - return -ENOMEM; - - ctx->sram_free_offset = start; - drvdata->sram_mgr_handle = ctx; - + drvdata->sram_free_offset = start; return 0; } @@ -53,7 +37,6 @@ int cc_sram_mgr_init(struct cc_drvdata *drvdata) */ u32 cc_sram_alloc(struct cc_drvdata *drvdata, u32 size) { - struct cc_sram_ctx *smgr_ctx = drvdata->sram_mgr_handle; struct device *dev = drvdata_to_dev(drvdata); u32 p; @@ -62,14 +45,14 @@ u32 cc_sram_alloc(struct cc_drvdata *drvdata, u32 size) size); return NULL_SRAM_ADDR; } - if (size > (CC_CC_SRAM_SIZE - smgr_ctx->sram_free_offset)) { + if (size > (CC_CC_SRAM_SIZE - drvdata->sram_free_offset)) { dev_err(dev, "Not enough space to allocate %u B (at offset %u)\n", - size, smgr_ctx->sram_free_offset); + size, drvdata->sram_free_offset); return NULL_SRAM_ADDR; } - p = smgr_ctx->sram_free_offset; - smgr_ctx->sram_free_offset += size; + p = drvdata->sram_free_offset; + drvdata->sram_free_offset += size; dev_dbg(dev, "Allocated %u B @ %u\n", size, p); return p; } -- 2.17.1