From: Rosen Penev <rosenp@gmail.com>
To: linux-crypto@vger.kernel.org
Cc: Srujana Challa <schalla@marvell.com>,
Bharat Bhushan <bbhushan2@marvell.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] crypto: cesa: allocate engines with main struct
Date: Fri, 24 Apr 2026 19:32:47 -0700 [thread overview]
Message-ID: <20260425023247.475233-1-rosenp@gmail.com> (raw)
Use a flexible array member to combine and simplify allocation.
Move struct mv_cesa_dev down as flexible array members require full
definitions.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/crypto/marvell/cesa/cesa.c | 11 +++-----
drivers/crypto/marvell/cesa/cesa.h | 42 +++++++++++++++---------------
2 files changed, 25 insertions(+), 28 deletions(-)
diff --git a/drivers/crypto/marvell/cesa/cesa.c b/drivers/crypto/marvell/cesa/cesa.c
index 8afa3a87e38d..687ed730174d 100644
--- a/drivers/crypto/marvell/cesa/cesa.c
+++ b/drivers/crypto/marvell/cesa/cesa.c
@@ -416,7 +416,7 @@ static int mv_cesa_probe(struct platform_device *pdev)
const struct mbus_dram_target_info *dram;
struct device *dev = &pdev->dev;
struct mv_cesa_dev *cesa;
- struct mv_cesa_engine *engines;
+ struct mv_cesa_engine *engine;
int irq, ret, i, cpu;
u32 sram_size;
@@ -431,7 +431,8 @@ static int mv_cesa_probe(struct platform_device *pdev)
return -ENOTSUPP;
}
- cesa = devm_kzalloc(dev, sizeof(*cesa), GFP_KERNEL);
+ cesa = devm_kzalloc(dev, struct_size(cesa, engines, caps->nengines),
+ GFP_KERNEL);
if (!cesa)
return -ENOMEM;
@@ -445,10 +446,6 @@ static int mv_cesa_probe(struct platform_device *pdev)
sram_size = CESA_SA_MIN_SRAM_SIZE;
cesa->sram_size = sram_size;
- cesa->engines = devm_kcalloc(dev, caps->nengines, sizeof(*engines),
- GFP_KERNEL);
- if (!cesa->engines)
- return -ENOMEM;
spin_lock_init(&cesa->lock);
@@ -465,7 +462,7 @@ static int mv_cesa_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, cesa);
for (i = 0; i < caps->nengines; i++) {
- struct mv_cesa_engine *engine = &cesa->engines[i];
+ engine = &cesa->engines[i];
char res_name[16];
engine->id = i;
diff --git a/drivers/crypto/marvell/cesa/cesa.h b/drivers/crypto/marvell/cesa/cesa.h
index 50ca1039fdaa..18f9f28040a6 100644
--- a/drivers/crypto/marvell/cesa/cesa.h
+++ b/drivers/crypto/marvell/cesa/cesa.h
@@ -402,27 +402,6 @@ struct mv_cesa_dev_dma {
struct dma_pool *padding_pool;
};
-/**
- * struct mv_cesa_dev - CESA device
- * @caps: device capabilities
- * @regs: device registers
- * @sram_size: usable SRAM size
- * @lock: device lock
- * @engines: array of engines
- * @dma: dma pools
- *
- * Structure storing CESA device information.
- */
-struct mv_cesa_dev {
- const struct mv_cesa_caps *caps;
- void __iomem *regs;
- struct device *dev;
- unsigned int sram_size;
- spinlock_t lock;
- struct mv_cesa_engine *engines;
- struct mv_cesa_dev_dma *dma;
-};
-
/**
* struct mv_cesa_engine - CESA engine
* @id: engine id
@@ -471,6 +450,27 @@ struct mv_cesa_engine {
int irq;
};
+/**
+ * struct mv_cesa_dev - CESA device
+ * @caps: device capabilities
+ * @regs: device registers
+ * @sram_size: usable SRAM size
+ * @lock: device lock
+ * @dma: dma pools
+ * @engines: array of engines
+ *
+ * Structure storing CESA device information.
+ */
+struct mv_cesa_dev {
+ const struct mv_cesa_caps *caps;
+ void __iomem *regs;
+ struct device *dev;
+ unsigned int sram_size;
+ spinlock_t lock;
+ struct mv_cesa_dev_dma *dma;
+ struct mv_cesa_engine engines[];
+};
+
/**
* struct mv_cesa_req_ops - CESA request operations
* @process: process a request chunk result (should return 0 if the
--
2.54.0
reply other threads:[~2026-04-25 2:33 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260425023247.475233-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=bbhushan2@marvell.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=schalla@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox