crypto: cesa: allocate engines with main struct
Subsystems (2)
PATCH 1/1 crypto: cesa: allocate engines with main struct
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 <[email protected]>
--- drivers/crypto/marvell/cesa/cesa.c | 11 +++----- drivers/crypto/marvell/cesa/cesa.h | 42 +++++++++++++++--------------- 2 files changed, 25 insertions(+), 28 deletions(-)
drivers/crypto/marvell/cesa/cesa.c +4 -7
@@ -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;
drivers/crypto/marvell/cesa/cesa.h +21 -21
54 lines not on this page · raw message
Signature · 1 line
2.54.0
Herbert Xu
maintainerQuoted 10 lines · Rosen Penev
Use a flexible array member to combine and simplify allocation.
Move struct
mv_cesa_devdown as flexible array members require full definitions.Signed-off-by Rosen Penev <[email protected]>--- drivers/crypto/marvell/cesa/cesa.c | 11 +++----- drivers/crypto/marvell/cesa/cesa.h | 42 +++++++++++++++--------------- 2 files changed, 25 insertions(+), 28 deletions(-)
Patch applied. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt