crypto: eip93 - use struct_size() and flexible array for ring allocation

Embed the single ring as a flexible array member in eip93_device
instead of allocating it separately. This simplifies the probe path
and uses struct_size() for a single allocation.

Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Rosen Penev
2026-08-03 15:40:28 -07:00
committed by Herbert Xu
parent f7d53dd3f2
commit ce64a0e7e6
2 changed files with 12 additions and 16 deletions

View File

@@ -415,7 +415,7 @@ static int eip93_crypto_probe(struct platform_device *pdev)
u32 ver, algo_flags;
int ret;
eip93 = devm_kzalloc(dev, sizeof(*eip93), GFP_KERNEL);
eip93 = devm_kzalloc(dev, struct_size(eip93, ring, 1), GFP_KERNEL);
if (!eip93)
return -ENOMEM;
@@ -436,10 +436,6 @@ static int eip93_crypto_probe(struct platform_device *pdev)
if (ret)
return ret;
eip93->ring = devm_kcalloc(eip93->dev, 1, sizeof(*eip93->ring), GFP_KERNEL);
if (!eip93->ring)
return -ENOMEM;
ret = eip93_desc_init(eip93);
if (ret)
return ret;

View File

@@ -92,17 +92,6 @@
EIP93_HASH_SHA224 | \
EIP93_HASH_SHA256))
/**
* struct eip93_device - crypto engine device structure
*/
struct eip93_device {
void __iomem *base;
struct device *dev;
struct clk *clk;
int irq;
struct eip93_ring *ring;
};
struct eip93_desc_ring {
void *base;
void *base_end;
@@ -131,6 +120,17 @@ struct eip93_ring {
struct idr crypto_async_idr;
};
/**
* struct eip93_device - crypto engine device structure
*/
struct eip93_device {
void __iomem *base;
struct device *dev;
struct clk *clk;
int irq;
struct eip93_ring ring[];
};
enum eip93_alg_type {
EIP93_ALG_TYPE_AEAD,
EIP93_ALG_TYPE_SKCIPHER,