Skip to content

Commit 5a17eae

Browse files
committed
crypto: bcm - Fix sparse warnings
This patch fixes a number of sparse warnings in the bcm driver. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 660d206 commit 5a17eae

File tree

7 files changed

+48
-40
lines changed

7 files changed

+48
-40
lines changed

drivers/crypto/bcm/cipher.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,8 @@ static int handle_skcipher_req(struct iproc_reqctx_s *rctx)
471471
static void handle_skcipher_resp(struct iproc_reqctx_s *rctx)
472472
{
473473
struct spu_hw *spu = &iproc_priv.spu;
474-
#ifdef DEBUG
475474
struct crypto_async_request *areq = rctx->parent;
476475
struct skcipher_request *req = skcipher_request_cast(areq);
477-
#endif
478476
struct iproc_ctx_s *ctx = rctx->ctx;
479477
u32 payload_len;
480478

@@ -996,13 +994,11 @@ static int ahash_req_done(struct iproc_reqctx_s *rctx)
996994
static void handle_ahash_resp(struct iproc_reqctx_s *rctx)
997995
{
998996
struct iproc_ctx_s *ctx = rctx->ctx;
999-
#ifdef DEBUG
1000997
struct crypto_async_request *areq = rctx->parent;
1001998
struct ahash_request *req = ahash_request_cast(areq);
1002999
struct crypto_ahash *ahash = crypto_ahash_reqtfm(req);
10031000
unsigned int blocksize =
10041001
crypto_tfm_alg_blocksize(crypto_ahash_tfm(ahash));
1005-
#endif
10061002
/*
10071003
* Save hash to use as input to next op if incremental. Might be copying
10081004
* too much, but that's easier than figuring out actual digest size here

drivers/crypto/bcm/spu.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void spum_dump_msg_hdr(u8 *buf, unsigned int buf_len)
4141
packet_log("SPU Message header %p len: %u\n", buf, buf_len);
4242

4343
/* ========== Decode MH ========== */
44-
packet_log(" MH 0x%08x\n", be32_to_cpu(*((u32 *)ptr)));
44+
packet_log(" MH 0x%08x\n", be32_to_cpup((__be32 *)ptr));
4545
if (spuh->mh.flags & MH_SCTX_PRES)
4646
packet_log(" SCTX present\n");
4747
if (spuh->mh.flags & MH_BDESC_PRES)
@@ -273,22 +273,21 @@ void spum_dump_msg_hdr(u8 *buf, unsigned int buf_len)
273273

274274
/* ========== Decode BDESC ========== */
275275
if (spuh->mh.flags & MH_BDESC_PRES) {
276-
#ifdef DEBUG
277276
struct BDESC_HEADER *bdesc = (struct BDESC_HEADER *)ptr;
278-
#endif
279-
packet_log(" BDESC[0] 0x%08x\n", be32_to_cpu(*((u32 *)ptr)));
277+
278+
packet_log(" BDESC[0] 0x%08x\n", be32_to_cpup((__be32 *)ptr));
280279
packet_log(" OffsetMAC:%u LengthMAC:%u\n",
281280
be16_to_cpu(bdesc->offset_mac),
282281
be16_to_cpu(bdesc->length_mac));
283282
ptr += sizeof(u32);
284283

285-
packet_log(" BDESC[1] 0x%08x\n", be32_to_cpu(*((u32 *)ptr)));
284+
packet_log(" BDESC[1] 0x%08x\n", be32_to_cpup((__be32 *)ptr));
286285
packet_log(" OffsetCrypto:%u LengthCrypto:%u\n",
287286
be16_to_cpu(bdesc->offset_crypto),
288287
be16_to_cpu(bdesc->length_crypto));
289288
ptr += sizeof(u32);
290289

291-
packet_log(" BDESC[2] 0x%08x\n", be32_to_cpu(*((u32 *)ptr)));
290+
packet_log(" BDESC[2] 0x%08x\n", be32_to_cpup((__be32 *)ptr));
292291
packet_log(" OffsetICV:%u OffsetIV:%u\n",
293292
be16_to_cpu(bdesc->offset_icv),
294293
be16_to_cpu(bdesc->offset_iv));
@@ -297,10 +296,9 @@ void spum_dump_msg_hdr(u8 *buf, unsigned int buf_len)
297296

298297
/* ========== Decode BD ========== */
299298
if (spuh->mh.flags & MH_BD_PRES) {
300-
#ifdef DEBUG
301299
struct BD_HEADER *bd = (struct BD_HEADER *)ptr;
302-
#endif
303-
packet_log(" BD[0] 0x%08x\n", be32_to_cpu(*((u32 *)ptr)));
300+
301+
packet_log(" BD[0] 0x%08x\n", be32_to_cpup((__be32 *)ptr));
304302
packet_log(" Size:%ubytes PrevLength:%u\n",
305303
be16_to_cpu(bd->size), be16_to_cpu(bd->prev_length));
306304
ptr += 4;
@@ -1056,9 +1054,9 @@ void spum_request_pad(u8 *pad_start,
10561054

10571055
/* add the size at the end as required per alg */
10581056
if (auth_alg == HASH_ALG_MD5)
1059-
*(u64 *)ptr = cpu_to_le64((u64)total_sent * 8);
1057+
*(__le64 *)ptr = cpu_to_le64(total_sent * 8ull);
10601058
else /* SHA1, SHA2-224, SHA2-256 */
1061-
*(u64 *)ptr = cpu_to_be64((u64)total_sent * 8);
1059+
*(__be64 *)ptr = cpu_to_be64(total_sent * 8ull);
10621060
ptr += sizeof(u64);
10631061
}
10641062
}

drivers/crypto/bcm/spu2.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,6 @@ u32 spu2_create_request(u8 *spu_hdr,
964964
unsigned int cipher_offset = aead_parms->assoc_size +
965965
aead_parms->aad_pad_len + aead_parms->iv_len;
966966

967-
#ifdef DEBUG
968967
/* total size of the data following OMD (without STAT word padding) */
969968
unsigned int real_db_size = spu_real_db_size(aead_parms->assoc_size,
970969
aead_parms->iv_len,
@@ -973,7 +972,6 @@ u32 spu2_create_request(u8 *spu_hdr,
973972
aead_parms->aad_pad_len,
974973
aead_parms->data_pad_len,
975974
hash_parms->pad_len);
976-
#endif
977975
unsigned int assoc_size = aead_parms->assoc_size;
978976

979977
if (req_opts->is_aead &&
@@ -1263,9 +1261,9 @@ void spu2_request_pad(u8 *pad_start, u32 gcm_padding, u32 hash_pad_len,
12631261

12641262
/* add the size at the end as required per alg */
12651263
if (auth_alg == HASH_ALG_MD5)
1266-
*(u64 *)ptr = cpu_to_le64((u64)total_sent * 8);
1264+
*(__le64 *)ptr = cpu_to_le64(total_sent * 8ull);
12671265
else /* SHA1, SHA2-224, SHA2-256 */
1268-
*(u64 *)ptr = cpu_to_be64((u64)total_sent * 8);
1266+
*(__be64 *)ptr = cpu_to_be64(total_sent * 8ull);
12691267
ptr += sizeof(u64);
12701268
}
12711269

drivers/crypto/bcm/spu2.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ enum spu2_ret_md_opts {
7373

7474
/* Fixed Metadata format */
7575
struct SPU2_FMD {
76-
u64 ctrl0;
77-
u64 ctrl1;
78-
u64 ctrl2;
79-
u64 ctrl3;
76+
__le64 ctrl0;
77+
__le64 ctrl1;
78+
__le64 ctrl2;
79+
__le64 ctrl3;
8080
};
8181

8282
#define FMD_SIZE sizeof(struct SPU2_FMD)

drivers/crypto/bcm/spum.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,18 @@
6969

7070
/* Buffer Descriptor Header [BDESC]. SPU in big-endian mode. */
7171
struct BDESC_HEADER {
72-
u16 offset_mac; /* word 0 [31-16] */
73-
u16 length_mac; /* word 0 [15-0] */
74-
u16 offset_crypto; /* word 1 [31-16] */
75-
u16 length_crypto; /* word 1 [15-0] */
76-
u16 offset_icv; /* word 2 [31-16] */
77-
u16 offset_iv; /* word 2 [15-0] */
72+
__be16 offset_mac; /* word 0 [31-16] */
73+
__be16 length_mac; /* word 0 [15-0] */
74+
__be16 offset_crypto; /* word 1 [31-16] */
75+
__be16 length_crypto; /* word 1 [15-0] */
76+
__be16 offset_icv; /* word 2 [31-16] */
77+
__be16 offset_iv; /* word 2 [15-0] */
7878
};
7979

8080
/* Buffer Data Header [BD]. SPU in big-endian mode. */
8181
struct BD_HEADER {
82-
u16 size;
83-
u16 prev_length;
82+
__be16 size;
83+
__be16 prev_length;
8484
};
8585

8686
/* Command Context Header. SPU-M in big endian mode. */
@@ -144,13 +144,13 @@ struct MHEADER {
144144
/* Generic Mode Security Context Structure [SCTX] */
145145
struct SCTX {
146146
/* word 0: protocol flags */
147-
u32 proto_flags;
147+
__be32 proto_flags;
148148

149149
/* word 1: cipher flags */
150-
u32 cipher_flags;
150+
__be32 cipher_flags;
151151

152152
/* word 2: Extended cipher flags */
153-
u32 ecf;
153+
__be32 ecf;
154154

155155
};
156156

drivers/crypto/bcm/util.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ int do_shash(unsigned char *name, unsigned char *result,
268268
return rc;
269269
}
270270

271+
#ifdef DEBUG
271272
/* Dump len bytes of a scatterlist starting at skip bytes into the sg */
272273
void __dump_sg(struct scatterlist *sg, unsigned int skip, unsigned int len)
273274
{
@@ -289,6 +290,7 @@ void __dump_sg(struct scatterlist *sg, unsigned int skip, unsigned int len)
289290
if (debug_logging_sleep)
290291
msleep(debug_logging_sleep);
291292
}
293+
#endif
292294

293295
/* Returns the name for a given cipher alg/mode */
294296
char *spu_alg_name(enum spu_cipher_alg alg, enum spu_cipher_mode mode)

drivers/crypto/bcm/util.h

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,26 @@ void __dump_sg(struct scatterlist *sg, unsigned int skip, unsigned int len);
5858

5959
#else /* !DEBUG_ON */
6060

61-
#define flow_log(...) do {} while (0)
62-
#define flow_dump(msg, var, var_len) do {} while (0)
63-
#define packet_log(...) do {} while (0)
64-
#define packet_dump(msg, var, var_len) do {} while (0)
65-
66-
#define dump_sg(sg, skip, len) do {} while (0)
61+
static inline void flow_log(const char *format, ...)
62+
{
63+
}
64+
65+
static inline void flow_dump(const char *msg, const void *var, size_t var_len)
66+
{
67+
}
68+
69+
static inline void packet_log(const char *format, ...)
70+
{
71+
}
72+
73+
static inline void packet_dump(const char *msg, const void *var, size_t var_len)
74+
{
75+
}
76+
77+
static inline void dump_sg(struct scatterlist *sg, unsigned int skip,
78+
unsigned int len)
79+
{
80+
}
6781

6882
#endif /* DEBUG_ON */
6983

0 commit comments

Comments
 (0)