Skip to content

Commit a1b8001

Browse files
noctuellesherbertx
authored andcommitted
crypto: talitos - rename first/last to first_desc/last_desc
Previous commit introduces a new last_request variable in the context structure. Renaming the first/last existing member variable in the context structure to improve readability. Cc: stable@vger.kernel.org Signed-off-by: Paul Louvel <paul.louvel@bootlin.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 655ef63 commit a1b8001

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

drivers/crypto/talitos.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -869,8 +869,8 @@ struct talitos_ahash_req_ctx {
869869
u8 buf[2][HASH_MAX_BLOCK_SIZE];
870870
int buf_idx;
871871
unsigned int swinit;
872-
unsigned int first;
873-
unsigned int last;
872+
unsigned int first_desc;
873+
unsigned int last_desc;
874874
unsigned int last_request;
875875
unsigned int to_hash_later;
876876
unsigned int nbuf;
@@ -889,8 +889,8 @@ struct talitos_export_state {
889889
u32 hw_context[TALITOS_MDEU_MAX_CONTEXT_SIZE / sizeof(u32)];
890890
u8 buf[HASH_MAX_BLOCK_SIZE];
891891
unsigned int swinit;
892-
unsigned int first;
893-
unsigned int last;
892+
unsigned int first_desc;
893+
unsigned int last_desc;
894894
unsigned int to_hash_later;
895895
unsigned int nbuf;
896896
};
@@ -1722,7 +1722,7 @@ static void common_nonsnoop_hash_unmap(struct device *dev,
17221722
if (desc->next_desc &&
17231723
desc->ptr[5].ptr != desc2->ptr[5].ptr)
17241724
unmap_single_talitos_ptr(dev, &desc2->ptr[5], DMA_FROM_DEVICE);
1725-
if (req_ctx->last)
1725+
if (req_ctx->last_desc)
17261726
memcpy(areq->result, req_ctx->hw_context,
17271727
crypto_ahash_digestsize(tfm));
17281728

@@ -1759,7 +1759,7 @@ static void ahash_done(struct device *dev,
17591759
container_of(desc, struct talitos_edesc, desc);
17601760
struct talitos_ahash_req_ctx *req_ctx = ahash_request_ctx(areq);
17611761

1762-
if (!req_ctx->last && req_ctx->to_hash_later) {
1762+
if (!req_ctx->last_desc && req_ctx->to_hash_later) {
17631763
/* Position any partial block for next update/final/finup */
17641764
req_ctx->buf_idx = (req_ctx->buf_idx + 1) & 1;
17651765
req_ctx->nbuf = req_ctx->to_hash_later;
@@ -1825,15 +1825,15 @@ static int common_nonsnoop_hash(struct talitos_edesc *edesc,
18251825
/* first DWORD empty */
18261826

18271827
/* hash context in */
1828-
if (!req_ctx->first || req_ctx->swinit) {
1828+
if (!req_ctx->first_desc || req_ctx->swinit) {
18291829
map_single_talitos_ptr_nosync(dev, &desc->ptr[1],
18301830
req_ctx->hw_context_size,
18311831
req_ctx->hw_context,
18321832
DMA_TO_DEVICE);
18331833
req_ctx->swinit = 0;
18341834
}
18351835
/* Indicate next op is not the first. */
1836-
req_ctx->first = 0;
1836+
req_ctx->first_desc = 0;
18371837

18381838
/* HMAC key */
18391839
if (ctx->keylen)
@@ -1866,7 +1866,7 @@ static int common_nonsnoop_hash(struct talitos_edesc *edesc,
18661866
/* fifth DWORD empty */
18671867

18681868
/* hash/HMAC out -or- hash context out */
1869-
if (req_ctx->last)
1869+
if (req_ctx->last_desc)
18701870
map_single_talitos_ptr(dev, &desc->ptr[5],
18711871
crypto_ahash_digestsize(tfm),
18721872
req_ctx->hw_context, DMA_FROM_DEVICE);
@@ -1908,7 +1908,7 @@ static int common_nonsnoop_hash(struct talitos_edesc *edesc,
19081908
if (sg_count > 1)
19091909
sync_needed = true;
19101910
copy_talitos_ptr(&desc2->ptr[5], &desc->ptr[5], is_sec1);
1911-
if (req_ctx->last)
1911+
if (req_ctx->last_desc)
19121912
map_single_talitos_ptr_nosync(dev, &desc->ptr[5],
19131913
req_ctx->hw_context_size,
19141914
req_ctx->hw_context,
@@ -1964,7 +1964,7 @@ static int ahash_process_req_one(struct ahash_request *areq, unsigned int nbytes
19641964
bool is_sec1 = has_ftr_sec1(priv);
19651965
u8 *ctx_buf = req_ctx->buf[req_ctx->buf_idx];
19661966

1967-
if (!req_ctx->last && (nbytes + req_ctx->nbuf <= blocksize)) {
1967+
if (!req_ctx->last_desc && (nbytes + req_ctx->nbuf <= blocksize)) {
19681968
/* Buffer up to one whole block */
19691969
nents = sg_nents_for_len(req_ctx->request_sl, nbytes);
19701970
if (nents < 0) {
@@ -1981,7 +1981,7 @@ static int ahash_process_req_one(struct ahash_request *areq, unsigned int nbytes
19811981
nbytes_to_hash = nbytes + req_ctx->nbuf;
19821982
to_hash_later = nbytes_to_hash & (blocksize - 1);
19831983

1984-
if (req_ctx->last)
1984+
if (req_ctx->last_desc)
19851985
to_hash_later = 0;
19861986
else if (to_hash_later)
19871987
/* There is a partial block. Hash the full block(s) now */
@@ -2041,19 +2041,19 @@ static int ahash_process_req_one(struct ahash_request *areq, unsigned int nbytes
20412041
edesc->desc.hdr = ctx->desc_hdr_template;
20422042

20432043
/* On last one, request SEC to pad; otherwise continue */
2044-
if (req_ctx->last)
2044+
if (req_ctx->last_desc)
20452045
edesc->desc.hdr |= DESC_HDR_MODE0_MDEU_PAD;
20462046
else
20472047
edesc->desc.hdr |= DESC_HDR_MODE0_MDEU_CONT;
20482048

20492049
/* request SEC to INIT hash. */
2050-
if (req_ctx->first && !req_ctx->swinit)
2050+
if (req_ctx->first_desc && !req_ctx->swinit)
20512051
edesc->desc.hdr |= DESC_HDR_MODE0_MDEU_INIT;
20522052

20532053
/* When the tfm context has a keylen, it's an HMAC.
20542054
* A first or last (ie. not middle) descriptor must request HMAC.
20552055
*/
2056-
if (ctx->keylen && (req_ctx->first || req_ctx->last))
2056+
if (ctx->keylen && (req_ctx->first_desc || req_ctx->last_desc))
20572057
edesc->desc.hdr |= DESC_HDR_MODE0_MDEU_HMAC;
20582058

20592059
return common_nonsnoop_hash(edesc, req_ctx->areq, nbytes_to_hash, ahash_done);
@@ -2076,7 +2076,7 @@ static void sec1_ahash_process_remaining(struct work_struct *work)
20762076
req_ctx->remaining_ahash_request_bytes;
20772077

20782078
if (req_ctx->last_request)
2079-
req_ctx->last = 1;
2079+
req_ctx->last_desc = 1;
20802080
}
20812081

20822082
err = ahash_process_req_one(req_ctx->areq,
@@ -2103,7 +2103,7 @@ static int ahash_process_req(struct ahash_request *areq, unsigned int nbytes)
21032103
if (nbytes > TALITOS1_MAX_DATA_LEN)
21042104
nbytes = TALITOS1_MAX_DATA_LEN;
21052105
else if (req_ctx->last_request)
2106-
req_ctx->last = 1;
2106+
req_ctx->last_desc = 1;
21072107
}
21082108

21092109
req_ctx->current_ahash_request_bytes = nbytes;
@@ -2124,14 +2124,14 @@ static int ahash_init(struct ahash_request *areq)
21242124
/* Initialize the context */
21252125
req_ctx->buf_idx = 0;
21262126
req_ctx->nbuf = 0;
2127-
req_ctx->first = 1; /* first indicates h/w must init its context */
2127+
req_ctx->first_desc = 1; /* first_desc indicates h/w must init its context */
21282128
req_ctx->swinit = 0; /* assume h/w init of context */
21292129
size = (crypto_ahash_digestsize(tfm) <= SHA256_DIGEST_SIZE)
21302130
? TALITOS_MDEU_CONTEXT_SIZE_MD5_SHA1_SHA256
21312131
: TALITOS_MDEU_CONTEXT_SIZE_SHA384_SHA512;
21322132
req_ctx->hw_context_size = size;
21332133
req_ctx->last_request = 0;
2134-
req_ctx->last = 0;
2134+
req_ctx->last_desc = 0;
21352135
INIT_WORK(&req_ctx->sec1_ahash_process_remaining, sec1_ahash_process_remaining);
21362136

21372137
dma = dma_map_single(dev, req_ctx->hw_context, req_ctx->hw_context_size,
@@ -2224,8 +2224,8 @@ static int ahash_export(struct ahash_request *areq, void *out)
22242224
req_ctx->hw_context_size);
22252225
memcpy(export->buf, req_ctx->buf[req_ctx->buf_idx], req_ctx->nbuf);
22262226
export->swinit = req_ctx->swinit;
2227-
export->first = req_ctx->first;
2228-
export->last = req_ctx->last;
2227+
export->first_desc = req_ctx->first_desc;
2228+
export->last_desc = req_ctx->last_desc;
22292229
export->to_hash_later = req_ctx->to_hash_later;
22302230
export->nbuf = req_ctx->nbuf;
22312231

@@ -2250,8 +2250,8 @@ static int ahash_import(struct ahash_request *areq, const void *in)
22502250
memcpy(req_ctx->hw_context, export->hw_context, size);
22512251
memcpy(req_ctx->buf[0], export->buf, export->nbuf);
22522252
req_ctx->swinit = export->swinit;
2253-
req_ctx->first = export->first;
2254-
req_ctx->last = export->last;
2253+
req_ctx->first_desc = export->first_desc;
2254+
req_ctx->last_desc = export->last_desc;
22552255
req_ctx->to_hash_later = export->to_hash_later;
22562256
req_ctx->nbuf = export->nbuf;
22572257

0 commit comments

Comments
 (0)