Skip to content

Commit c441a90

Browse files
ebiggersherbertx
authored andcommitted
crypto: compress - remove crt_u.compress (struct compress_tfm)
crt_u.compress (struct compress_tfm) is pointless because its two fields, ->cot_compress() and ->cot_decompress(), always point to crypto_compress() and crypto_decompress(). Remove this pointless indirection, and just make crypto_comp_compress() and crypto_comp_decompress() be direct calls to what used to be crypto_compress() and crypto_decompress(). Also remove the unused function crypto_comp_cast(). Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 49763fc commit c441a90

File tree

4 files changed

+19
-58
lines changed

4 files changed

+19
-58
lines changed

crypto/api.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static int crypto_init_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
301301
return crypto_init_cipher_ops(tfm);
302302

303303
case CRYPTO_ALG_TYPE_COMPRESS:
304-
return crypto_init_compress_ops(tfm);
304+
return 0;
305305

306306
default:
307307
break;

crypto/compress.c

+12-19
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,27 @@
66
*
77
* Copyright (c) 2002 James Morris <[email protected]>
88
*/
9-
#include <linux/types.h>
109
#include <linux/crypto.h>
11-
#include <linux/errno.h>
12-
#include <linux/string.h>
1310
#include "internal.h"
1411

15-
static int crypto_compress(struct crypto_tfm *tfm,
16-
const u8 *src, unsigned int slen,
17-
u8 *dst, unsigned int *dlen)
12+
int crypto_comp_compress(struct crypto_comp *comp,
13+
const u8 *src, unsigned int slen,
14+
u8 *dst, unsigned int *dlen)
1815
{
16+
struct crypto_tfm *tfm = crypto_comp_tfm(comp);
17+
1918
return tfm->__crt_alg->cra_compress.coa_compress(tfm, src, slen, dst,
2019
dlen);
2120
}
21+
EXPORT_SYMBOL_GPL(crypto_comp_compress);
2222

23-
static int crypto_decompress(struct crypto_tfm *tfm,
24-
const u8 *src, unsigned int slen,
25-
u8 *dst, unsigned int *dlen)
23+
int crypto_comp_decompress(struct crypto_comp *comp,
24+
const u8 *src, unsigned int slen,
25+
u8 *dst, unsigned int *dlen)
2626
{
27+
struct crypto_tfm *tfm = crypto_comp_tfm(comp);
28+
2729
return tfm->__crt_alg->cra_compress.coa_decompress(tfm, src, slen, dst,
2830
dlen);
2931
}
30-
31-
int crypto_init_compress_ops(struct crypto_tfm *tfm)
32-
{
33-
struct compress_tfm *ops = &tfm->crt_compress;
34-
35-
ops->cot_compress = crypto_compress;
36-
ops->cot_decompress = crypto_decompress;
37-
38-
return 0;
39-
}
32+
EXPORT_SYMBOL_GPL(crypto_comp_decompress);

crypto/internal.h

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ struct crypto_alg *crypto_mod_get(struct crypto_alg *alg);
5959
struct crypto_alg *crypto_alg_mod_lookup(const char *name, u32 type, u32 mask);
6060

6161
int crypto_init_cipher_ops(struct crypto_tfm *tfm);
62-
int crypto_init_compress_ops(struct crypto_tfm *tfm);
6362

6463
struct crypto_larval *crypto_larval_alloc(const char *name, u32 type, u32 mask);
6564
void crypto_larval_kill(struct crypto_alg *alg);

include/linux/crypto.h

+6-37
Original file line numberDiff line numberDiff line change
@@ -606,25 +606,14 @@ struct cipher_tfm {
606606
void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
607607
};
608608

609-
struct compress_tfm {
610-
int (*cot_compress)(struct crypto_tfm *tfm,
611-
const u8 *src, unsigned int slen,
612-
u8 *dst, unsigned int *dlen);
613-
int (*cot_decompress)(struct crypto_tfm *tfm,
614-
const u8 *src, unsigned int slen,
615-
u8 *dst, unsigned int *dlen);
616-
};
617-
618609
#define crt_cipher crt_u.cipher
619-
#define crt_compress crt_u.compress
620610

621611
struct crypto_tfm {
622612

623613
u32 crt_flags;
624614

625615
union {
626616
struct cipher_tfm cipher;
627-
struct compress_tfm compress;
628617
} crt_u;
629618

630619
void (*exit)(struct crypto_tfm *tfm);
@@ -928,13 +917,6 @@ static inline struct crypto_comp *__crypto_comp_cast(struct crypto_tfm *tfm)
928917
return (struct crypto_comp *)tfm;
929918
}
930919

931-
static inline struct crypto_comp *crypto_comp_cast(struct crypto_tfm *tfm)
932-
{
933-
BUG_ON((crypto_tfm_alg_type(tfm) ^ CRYPTO_ALG_TYPE_COMPRESS) &
934-
CRYPTO_ALG_TYPE_MASK);
935-
return __crypto_comp_cast(tfm);
936-
}
937-
938920
static inline struct crypto_comp *crypto_alloc_comp(const char *alg_name,
939921
u32 type, u32 mask)
940922
{
@@ -969,26 +951,13 @@ static inline const char *crypto_comp_name(struct crypto_comp *tfm)
969951
return crypto_tfm_alg_name(crypto_comp_tfm(tfm));
970952
}
971953

972-
static inline struct compress_tfm *crypto_comp_crt(struct crypto_comp *tfm)
973-
{
974-
return &crypto_comp_tfm(tfm)->crt_compress;
975-
}
976-
977-
static inline int crypto_comp_compress(struct crypto_comp *tfm,
978-
const u8 *src, unsigned int slen,
979-
u8 *dst, unsigned int *dlen)
980-
{
981-
return crypto_comp_crt(tfm)->cot_compress(crypto_comp_tfm(tfm),
982-
src, slen, dst, dlen);
983-
}
954+
int crypto_comp_compress(struct crypto_comp *tfm,
955+
const u8 *src, unsigned int slen,
956+
u8 *dst, unsigned int *dlen);
984957

985-
static inline int crypto_comp_decompress(struct crypto_comp *tfm,
986-
const u8 *src, unsigned int slen,
987-
u8 *dst, unsigned int *dlen)
988-
{
989-
return crypto_comp_crt(tfm)->cot_decompress(crypto_comp_tfm(tfm),
990-
src, slen, dst, dlen);
991-
}
958+
int crypto_comp_decompress(struct crypto_comp *tfm,
959+
const u8 *src, unsigned int slen,
960+
u8 *dst, unsigned int *dlen);
992961

993962
#endif /* _LINUX_CRYPTO_H */
994963

0 commit comments

Comments
 (0)