Skip to content

Commit 18e732b

Browse files
nathanchanceherbertx
authored andcommitted
crypto: ccree - avoid implicit enum conversion
Clang warns when one enumerated type is implicitly converted to another and this happens in several locations in this driver, ultimately related to the set_cipher_{mode,config0} functions. set_cipher_mode expects a mode of type drv_cipher_mode and set_cipher_config0 expects a mode of type drv_crypto_direction. drivers/crypto/ccree/cc_ivgen.c:58:35: warning: implicit conversion from enumeration type 'enum cc_desc_direction' to different enumeration type 'enum drv_crypto_direction' [-Wenum-conversion] set_cipher_config0(&iv_seq[idx], DESC_DIRECTION_ENCRYPT_ENCRYPT); drivers/crypto/ccree/cc_hash.c:99:28: warning: implicit conversion from enumeration type 'enum cc_hash_conf_pad' to different enumeration type 'enum drv_crypto_direction' [-Wenum-conversion] set_cipher_config0(desc, HASH_DIGEST_RESULT_LITTLE_ENDIAN); drivers/crypto/ccree/cc_aead.c:1643:30: warning: implicit conversion from enumeration type 'enum drv_hash_hw_mode' to different enumeration type 'enum drv_cipher_mode' [-Wenum-conversion] set_cipher_mode(&desc[idx], DRV_HASH_HW_GHASH); Since this fundamentally isn't a problem because these values just represent simple integers for a shift operation, make it clear to Clang that this is okay by making the mode parameter in both functions an int. Link: ClangBuiltLinux#46 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> Acked-by: Gilad Ben-Yossef <gilad@benyossef.com> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 618b5dc commit 18e732b

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/crypto/ccree/cc_hw_queue_defs.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,7 @@ static inline void set_flow_mode(struct cc_hw_desc *pdesc,
449449
* @pdesc: pointer HW descriptor struct
450450
* @mode: Any one of the modes defined in [CC7x-DESC]
451451
*/
452-
static inline void set_cipher_mode(struct cc_hw_desc *pdesc,
453-
enum drv_cipher_mode mode)
452+
static inline void set_cipher_mode(struct cc_hw_desc *pdesc, int mode)
454453
{
455454
pdesc->word[4] |= FIELD_PREP(WORD4_CIPHER_MODE, mode);
456455
}
@@ -461,8 +460,7 @@ static inline void set_cipher_mode(struct cc_hw_desc *pdesc,
461460
* @pdesc: pointer HW descriptor struct
462461
* @mode: Any one of the modes defined in [CC7x-DESC]
463462
*/
464-
static inline void set_cipher_config0(struct cc_hw_desc *pdesc,
465-
enum drv_crypto_direction mode)
463+
static inline void set_cipher_config0(struct cc_hw_desc *pdesc, int mode)
466464
{
467465
pdesc->word[4] |= FIELD_PREP(WORD4_CIPHER_CONF0, mode);
468466
}

0 commit comments

Comments
 (0)