Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <herbert@gondor.apana.org.au>

+18 -17
+18 -17
drivers/crypto/xilinx/zynqmp-aes-gcm.c
··· 9 9 #include <crypto/gcm.h> 10 10 #include <crypto/internal/aead.h> 11 11 #include <crypto/scatterwalk.h> 12 - 13 12 #include <linux/dma-mapping.h> 13 + #include <linux/err.h> 14 + #include <linux/firmware/xlnx-zynqmp.h> 15 + #include <linux/kernel.h> 14 16 #include <linux/module.h> 15 17 #include <linux/of_device.h> 16 18 #include <linux/platform_device.h> 17 - 18 - #include <linux/firmware/xlnx-zynqmp.h> 19 + #include <linux/string.h> 19 20 20 21 #define ZYNQMP_DMA_BIT_MASK 32U 21 22 ··· 44 43 45 44 struct zynqmp_aead_drv_ctx { 46 45 union { 47 - struct aead_alg aead; 46 + struct aead_engine_alg aead; 48 47 } alg; 49 48 struct device *dev; 50 49 struct crypto_engine *engine; ··· 61 60 }; 62 61 63 62 struct zynqmp_aead_tfm_ctx { 64 - struct crypto_engine_ctx engine_ctx; 65 63 struct device *dev; 66 64 u8 key[ZYNQMP_AES_KEY_SIZE]; 67 65 u8 *iv; ··· 286 286 struct zynqmp_aead_req_ctx *rq_ctx = aead_request_ctx(req); 287 287 288 288 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); 290 290 291 291 return crypto_transfer_aead_request_to_engine(drv_ctx->engine, req); 292 292 } ··· 299 299 struct zynqmp_aead_req_ctx *rq_ctx = aead_request_ctx(req); 300 300 301 301 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); 303 303 304 304 return crypto_transfer_aead_request_to_engine(drv_ctx->engine, req); 305 305 } ··· 312 312 struct zynqmp_aead_drv_ctx *drv_ctx; 313 313 struct aead_alg *alg = crypto_aead_alg(aead); 314 314 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); 316 316 tfm_ctx->dev = drv_ctx->dev; 317 317 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, 321 319 0, 322 320 CRYPTO_ALG_NEED_FALLBACK); 323 321 324 322 if (IS_ERR(tfm_ctx->fbk_cipher)) { 325 323 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); 327 325 return PTR_ERR(tfm_ctx->fbk_cipher); 328 326 } 329 327 ··· 346 348 } 347 349 348 350 static struct zynqmp_aead_drv_ctx aes_drv_ctx = { 349 - .alg.aead = { 351 + .alg.aead.base = { 350 352 .setkey = zynqmp_aes_aead_setkey, 351 353 .setauthsize = zynqmp_aes_aead_setauthsize, 352 354 .encrypt = zynqmp_aes_aead_encrypt, ··· 368 370 .cra_ctxsize = sizeof(struct zynqmp_aead_tfm_ctx), 369 371 .cra_module = THIS_MODULE, 370 372 } 371 - } 373 + }, 374 + .alg.aead.op = { 375 + .do_one_request = zynqmp_handle_aes_req, 376 + }, 372 377 }; 373 378 374 379 static int zynqmp_aes_aead_probe(struct platform_device *pdev) ··· 404 403 goto err_engine; 405 404 } 406 405 407 - err = crypto_register_aead(&aes_drv_ctx.alg.aead); 406 + err = crypto_engine_register_aead(&aes_drv_ctx.alg.aead); 408 407 if (err < 0) { 409 408 dev_err(dev, "Failed to register AEAD alg.\n"); 410 409 goto err_aead; ··· 412 411 return 0; 413 412 414 413 err_aead: 415 - crypto_unregister_aead(&aes_drv_ctx.alg.aead); 414 + crypto_engine_unregister_aead(&aes_drv_ctx.alg.aead); 416 415 417 416 err_engine: 418 417 if (aes_drv_ctx.engine) ··· 424 423 static int zynqmp_aes_aead_remove(struct platform_device *pdev) 425 424 { 426 425 crypto_engine_exit(aes_drv_ctx.engine); 427 - crypto_unregister_aead(&aes_drv_ctx.alg.aead); 426 + crypto_engine_unregister_aead(&aes_drv_ctx.alg.aead); 428 427 429 428 return 0; 430 429 }