Skip to content

Commit 28f860d

Browse files
committed
crypto: zynqmp - Use new crypto_engine_op interface
Use the new crypto_engine_op interface where the callback is stored in the algorithm object. Signed-off-by: Herbert Xu <[email protected]>
1 parent 7a2673d commit 28f860d

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

drivers/crypto/xilinx/zynqmp-aes-gcm.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
#include <crypto/gcm.h>
1010
#include <crypto/internal/aead.h>
1111
#include <crypto/scatterwalk.h>
12-
1312
#include <linux/dma-mapping.h>
13+
#include <linux/err.h>
14+
#include <linux/firmware/xlnx-zynqmp.h>
15+
#include <linux/kernel.h>
1416
#include <linux/module.h>
1517
#include <linux/of_device.h>
1618
#include <linux/platform_device.h>
17-
18-
#include <linux/firmware/xlnx-zynqmp.h>
19+
#include <linux/string.h>
1920

2021
#define ZYNQMP_DMA_BIT_MASK 32U
2122

@@ -43,7 +44,7 @@ enum zynqmp_aead_keysrc {
4344

4445
struct zynqmp_aead_drv_ctx {
4546
union {
46-
struct aead_alg aead;
47+
struct aead_engine_alg aead;
4748
} alg;
4849
struct device *dev;
4950
struct crypto_engine *engine;
@@ -60,7 +61,6 @@ struct zynqmp_aead_hw_req {
6061
};
6162

6263
struct zynqmp_aead_tfm_ctx {
63-
struct crypto_engine_ctx engine_ctx;
6464
struct device *dev;
6565
u8 key[ZYNQMP_AES_KEY_SIZE];
6666
u8 *iv;
@@ -286,7 +286,7 @@ static int zynqmp_aes_aead_encrypt(struct aead_request *req)
286286
struct zynqmp_aead_req_ctx *rq_ctx = aead_request_ctx(req);
287287

288288
rq_ctx->op = ZYNQMP_AES_ENCRYPT;
289-
drv_ctx = container_of(alg, struct zynqmp_aead_drv_ctx, alg.aead);
289+
drv_ctx = container_of(alg, struct zynqmp_aead_drv_ctx, alg.aead.base);
290290

291291
return crypto_transfer_aead_request_to_engine(drv_ctx->engine, req);
292292
}
@@ -299,7 +299,7 @@ static int zynqmp_aes_aead_decrypt(struct aead_request *req)
299299
struct zynqmp_aead_req_ctx *rq_ctx = aead_request_ctx(req);
300300

301301
rq_ctx->op = ZYNQMP_AES_DECRYPT;
302-
drv_ctx = container_of(alg, struct zynqmp_aead_drv_ctx, alg.aead);
302+
drv_ctx = container_of(alg, struct zynqmp_aead_drv_ctx, alg.aead.base);
303303

304304
return crypto_transfer_aead_request_to_engine(drv_ctx->engine, req);
305305
}
@@ -312,18 +312,16 @@ static int zynqmp_aes_aead_init(struct crypto_aead *aead)
312312
struct zynqmp_aead_drv_ctx *drv_ctx;
313313
struct aead_alg *alg = crypto_aead_alg(aead);
314314

315-
drv_ctx = container_of(alg, struct zynqmp_aead_drv_ctx, alg.aead);
315+
drv_ctx = container_of(alg, struct zynqmp_aead_drv_ctx, alg.aead.base);
316316
tfm_ctx->dev = drv_ctx->dev;
317317

318-
tfm_ctx->engine_ctx.op.do_one_request = zynqmp_handle_aes_req;
319-
320-
tfm_ctx->fbk_cipher = crypto_alloc_aead(drv_ctx->alg.aead.base.cra_name,
318+
tfm_ctx->fbk_cipher = crypto_alloc_aead(drv_ctx->alg.aead.base.base.cra_name,
321319
0,
322320
CRYPTO_ALG_NEED_FALLBACK);
323321

324322
if (IS_ERR(tfm_ctx->fbk_cipher)) {
325323
pr_err("%s() Error: failed to allocate fallback for %s\n",
326-
__func__, drv_ctx->alg.aead.base.cra_name);
324+
__func__, drv_ctx->alg.aead.base.base.cra_name);
327325
return PTR_ERR(tfm_ctx->fbk_cipher);
328326
}
329327

@@ -348,7 +346,7 @@ static void zynqmp_aes_aead_exit(struct crypto_aead *aead)
348346
}
349347

350348
static struct zynqmp_aead_drv_ctx aes_drv_ctx = {
351-
.alg.aead = {
349+
.alg.aead.base = {
352350
.setkey = zynqmp_aes_aead_setkey,
353351
.setauthsize = zynqmp_aes_aead_setauthsize,
354352
.encrypt = zynqmp_aes_aead_encrypt,
@@ -370,7 +368,10 @@ static struct zynqmp_aead_drv_ctx aes_drv_ctx = {
370368
.cra_ctxsize = sizeof(struct zynqmp_aead_tfm_ctx),
371369
.cra_module = THIS_MODULE,
372370
}
373-
}
371+
},
372+
.alg.aead.op = {
373+
.do_one_request = zynqmp_handle_aes_req,
374+
},
374375
};
375376

376377
static int zynqmp_aes_aead_probe(struct platform_device *pdev)
@@ -403,15 +404,15 @@ static int zynqmp_aes_aead_probe(struct platform_device *pdev)
403404
goto err_engine;
404405
}
405406

406-
err = crypto_register_aead(&aes_drv_ctx.alg.aead);
407+
err = crypto_engine_register_aead(&aes_drv_ctx.alg.aead);
407408
if (err < 0) {
408409
dev_err(dev, "Failed to register AEAD alg.\n");
409410
goto err_aead;
410411
}
411412
return 0;
412413

413414
err_aead:
414-
crypto_unregister_aead(&aes_drv_ctx.alg.aead);
415+
crypto_engine_unregister_aead(&aes_drv_ctx.alg.aead);
415416

416417
err_engine:
417418
if (aes_drv_ctx.engine)
@@ -423,7 +424,7 @@ static int zynqmp_aes_aead_probe(struct platform_device *pdev)
423424
static int zynqmp_aes_aead_remove(struct platform_device *pdev)
424425
{
425426
crypto_engine_exit(aes_drv_ctx.engine);
426-
crypto_unregister_aead(&aes_drv_ctx.alg.aead);
427+
crypto_engine_unregister_aead(&aes_drv_ctx.alg.aead);
427428

428429
return 0;
429430
}

0 commit comments

Comments
 (0)