Commit 4ca7c7d8 authored by Horia Geantă's avatar Horia Geantă Committed by Herbert Xu

crypto: caam - trivial code clean-up

-replace offsetof with container_of
-remove unused "assoc_nents", "iv_dma" from aead_edesc
and fix comments
-remove unused CAAM_MAX_IV_LENGTH #define
Signed-off-by: default avatarHoria Geantă <horia.geanta@nxp.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 1b008eed
...@@ -62,8 +62,6 @@ ...@@ -62,8 +62,6 @@
#define CAAM_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + \ #define CAAM_MAX_KEY_SIZE (AES_MAX_KEY_SIZE + \
CTR_RFC3686_NONCE_SIZE + \ CTR_RFC3686_NONCE_SIZE + \
SHA512_DIGEST_SIZE * 2) SHA512_DIGEST_SIZE * 2)
/* max IV is max of AES_BLOCK_SIZE, DES3_EDE_BLOCK_SIZE */
#define CAAM_MAX_IV_LENGTH 16
#define AEAD_DESC_JOB_IO_LEN (DESC_JOB_IO_LEN + CAAM_CMD_SZ * 2) #define AEAD_DESC_JOB_IO_LEN (DESC_JOB_IO_LEN + CAAM_CMD_SZ * 2)
#define GCM_DESC_JOB_IO_LEN (AEAD_DESC_JOB_IO_LEN + \ #define GCM_DESC_JOB_IO_LEN (AEAD_DESC_JOB_IO_LEN + \
...@@ -1873,20 +1871,16 @@ static int xts_ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher, ...@@ -1873,20 +1871,16 @@ static int xts_ablkcipher_setkey(struct crypto_ablkcipher *ablkcipher,
/* /*
* aead_edesc - s/w-extended aead descriptor * aead_edesc - s/w-extended aead descriptor
* @assoc_nents: number of segments in associated data (SPI+Seq) scatterlist
* @src_nents: number of segments in input scatterlist * @src_nents: number of segments in input scatterlist
* @dst_nents: number of segments in output scatterlist * @dst_nents: number of segments in output scatterlist
* @iv_dma: dma address of iv for checking continuity and link table
* @desc: h/w descriptor (variable length; must not exceed MAX_CAAM_DESCSIZE)
* @sec4_sg_bytes: length of dma mapped sec4_sg space * @sec4_sg_bytes: length of dma mapped sec4_sg space
* @sec4_sg_dma: bus physical mapped address of h/w link table * @sec4_sg_dma: bus physical mapped address of h/w link table
* @sec4_sg: pointer to h/w link table
* @hw_desc: the h/w job descriptor followed by any referenced link tables * @hw_desc: the h/w job descriptor followed by any referenced link tables
*/ */
struct aead_edesc { struct aead_edesc {
int assoc_nents;
int src_nents; int src_nents;
int dst_nents; int dst_nents;
dma_addr_t iv_dma;
int sec4_sg_bytes; int sec4_sg_bytes;
dma_addr_t sec4_sg_dma; dma_addr_t sec4_sg_dma;
struct sec4_sg_entry *sec4_sg; struct sec4_sg_entry *sec4_sg;
...@@ -1898,9 +1892,9 @@ struct aead_edesc { ...@@ -1898,9 +1892,9 @@ struct aead_edesc {
* @src_nents: number of segments in input scatterlist * @src_nents: number of segments in input scatterlist
* @dst_nents: number of segments in output scatterlist * @dst_nents: number of segments in output scatterlist
* @iv_dma: dma address of iv for checking continuity and link table * @iv_dma: dma address of iv for checking continuity and link table
* @desc: h/w descriptor (variable length; must not exceed MAX_CAAM_DESCSIZE)
* @sec4_sg_bytes: length of dma mapped sec4_sg space * @sec4_sg_bytes: length of dma mapped sec4_sg space
* @sec4_sg_dma: bus physical mapped address of h/w link table * @sec4_sg_dma: bus physical mapped address of h/w link table
* @sec4_sg: pointer to h/w link table
* @hw_desc: the h/w job descriptor followed by any referenced link tables * @hw_desc: the h/w job descriptor followed by any referenced link tables
*/ */
struct ablkcipher_edesc { struct ablkcipher_edesc {
...@@ -2017,8 +2011,7 @@ static void ablkcipher_encrypt_done(struct device *jrdev, u32 *desc, u32 err, ...@@ -2017,8 +2011,7 @@ static void ablkcipher_encrypt_done(struct device *jrdev, u32 *desc, u32 err,
dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err); dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err);
#endif #endif
edesc = (struct ablkcipher_edesc *)((char *)desc - edesc = container_of(desc, struct ablkcipher_edesc, hw_desc[0]);
offsetof(struct ablkcipher_edesc, hw_desc));
if (err) if (err)
caam_jr_strstatus(jrdev, err); caam_jr_strstatus(jrdev, err);
...@@ -2050,8 +2043,7 @@ static void ablkcipher_decrypt_done(struct device *jrdev, u32 *desc, u32 err, ...@@ -2050,8 +2043,7 @@ static void ablkcipher_decrypt_done(struct device *jrdev, u32 *desc, u32 err,
dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err); dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err);
#endif #endif
edesc = (struct ablkcipher_edesc *)((char *)desc - edesc = container_of(desc, struct ablkcipher_edesc, hw_desc[0]);
offsetof(struct ablkcipher_edesc, hw_desc));
if (err) if (err)
caam_jr_strstatus(jrdev, err); caam_jr_strstatus(jrdev, err);
......
...@@ -636,8 +636,7 @@ static void ahash_done(struct device *jrdev, u32 *desc, u32 err, ...@@ -636,8 +636,7 @@ static void ahash_done(struct device *jrdev, u32 *desc, u32 err,
dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err); dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err);
#endif #endif
edesc = (struct ahash_edesc *)((char *)desc - edesc = container_of(desc, struct ahash_edesc, hw_desc[0]);
offsetof(struct ahash_edesc, hw_desc));
if (err) if (err)
caam_jr_strstatus(jrdev, err); caam_jr_strstatus(jrdev, err);
...@@ -671,8 +670,7 @@ static void ahash_done_bi(struct device *jrdev, u32 *desc, u32 err, ...@@ -671,8 +670,7 @@ static void ahash_done_bi(struct device *jrdev, u32 *desc, u32 err,
dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err); dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err);
#endif #endif
edesc = (struct ahash_edesc *)((char *)desc - edesc = container_of(desc, struct ahash_edesc, hw_desc[0]);
offsetof(struct ahash_edesc, hw_desc));
if (err) if (err)
caam_jr_strstatus(jrdev, err); caam_jr_strstatus(jrdev, err);
...@@ -706,8 +704,7 @@ static void ahash_done_ctx_src(struct device *jrdev, u32 *desc, u32 err, ...@@ -706,8 +704,7 @@ static void ahash_done_ctx_src(struct device *jrdev, u32 *desc, u32 err,
dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err); dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err);
#endif #endif
edesc = (struct ahash_edesc *)((char *)desc - edesc = container_of(desc, struct ahash_edesc, hw_desc[0]);
offsetof(struct ahash_edesc, hw_desc));
if (err) if (err)
caam_jr_strstatus(jrdev, err); caam_jr_strstatus(jrdev, err);
...@@ -741,8 +738,7 @@ static void ahash_done_ctx_dst(struct device *jrdev, u32 *desc, u32 err, ...@@ -741,8 +738,7 @@ static void ahash_done_ctx_dst(struct device *jrdev, u32 *desc, u32 err,
dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err); dev_err(jrdev, "%s %d: err 0x%x\n", __func__, __LINE__, err);
#endif #endif
edesc = (struct ahash_edesc *)((char *)desc - edesc = container_of(desc, struct ahash_edesc, hw_desc[0]);
offsetof(struct ahash_edesc, hw_desc));
if (err) if (err)
caam_jr_strstatus(jrdev, err); caam_jr_strstatus(jrdev, err);
......
...@@ -100,8 +100,7 @@ static void rng_done(struct device *jrdev, u32 *desc, u32 err, void *context) ...@@ -100,8 +100,7 @@ static void rng_done(struct device *jrdev, u32 *desc, u32 err, void *context)
{ {
struct buf_data *bd; struct buf_data *bd;
bd = (struct buf_data *)((char *)desc - bd = container_of(desc, struct buf_data, hw_desc[0]);
offsetof(struct buf_data, hw_desc));
if (err) if (err)
caam_jr_strstatus(jrdev, err); caam_jr_strstatus(jrdev, err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment