Commit f1b19dff authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Herbert Xu

crypto: ccree - remove struct cc_sram_ctx

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: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent f33d807c
...@@ -146,7 +146,7 @@ struct cc_drvdata { ...@@ -146,7 +146,7 @@ struct cc_drvdata {
void *aead_handle; void *aead_handle;
void *request_mgr_handle; void *request_mgr_handle;
void *fips_handle; void *fips_handle;
void *sram_mgr_handle; u32 sram_free_offset; /* offset to non-allocated area in SRAM */
void *debugfs; void *debugfs;
struct clk *clk; struct clk *clk;
bool coherent; bool coherent;
......
...@@ -4,14 +4,6 @@ ...@@ -4,14 +4,6 @@
#include "cc_driver.h" #include "cc_driver.h"
#include "cc_sram_mgr.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. * cc_sram_mgr_init() - Initializes SRAM pool.
* The pool starts right at the beginning of SRAM. * The pool starts right at the beginning of SRAM.
...@@ -21,7 +13,6 @@ struct cc_sram_ctx { ...@@ -21,7 +13,6 @@ struct cc_sram_ctx {
*/ */
int cc_sram_mgr_init(struct cc_drvdata *drvdata) int cc_sram_mgr_init(struct cc_drvdata *drvdata)
{ {
struct cc_sram_ctx *ctx;
u32 start = 0; u32 start = 0;
struct device *dev = drvdata_to_dev(drvdata); struct device *dev = drvdata_to_dev(drvdata);
...@@ -34,14 +25,7 @@ int cc_sram_mgr_init(struct cc_drvdata *drvdata) ...@@ -34,14 +25,7 @@ int cc_sram_mgr_init(struct cc_drvdata *drvdata)
} }
} }
/* Allocate "this" context */ drvdata->sram_free_offset = start;
ctx = devm_kzalloc(dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return -ENOMEM;
ctx->sram_free_offset = start;
drvdata->sram_mgr_handle = ctx;
return 0; return 0;
} }
...@@ -53,7 +37,6 @@ int cc_sram_mgr_init(struct cc_drvdata *drvdata) ...@@ -53,7 +37,6 @@ int cc_sram_mgr_init(struct cc_drvdata *drvdata)
*/ */
u32 cc_sram_alloc(struct cc_drvdata *drvdata, u32 size) 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); struct device *dev = drvdata_to_dev(drvdata);
u32 p; u32 p;
...@@ -62,14 +45,14 @@ u32 cc_sram_alloc(struct cc_drvdata *drvdata, u32 size) ...@@ -62,14 +45,14 @@ u32 cc_sram_alloc(struct cc_drvdata *drvdata, u32 size)
size); size);
return NULL_SRAM_ADDR; 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", 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; return NULL_SRAM_ADDR;
} }
p = smgr_ctx->sram_free_offset; p = drvdata->sram_free_offset;
smgr_ctx->sram_free_offset += size; drvdata->sram_free_offset += size;
dev_dbg(dev, "Allocated %u B @ %u\n", size, p); dev_dbg(dev, "Allocated %u B @ %u\n", size, p);
return p; return p;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment