Commit 5876b0cb authored by Geert Uytterhoeven's avatar Geert Uytterhoeven Committed by Herbert Xu

crypto: sa2ul - Use bitfield helpers

Use the FIELD_PREP() helper, instead of open-coding the same operation.
Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 087e1d71
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
* Vitaly Andrianov * Vitaly Andrianov
* Tero Kristo * Tero Kristo
*/ */
#include <linux/bitfield.h>
#include <linux/clk.h> #include <linux/clk.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/dmaengine.h> #include <linux/dmaengine.h>
...@@ -646,8 +647,8 @@ static inline void sa_update_cmdl(struct sa_req *req, u32 *cmdl, ...@@ -646,8 +647,8 @@ static inline void sa_update_cmdl(struct sa_req *req, u32 *cmdl,
cmdl[upd_info->enc_offset.index] &= cmdl[upd_info->enc_offset.index] &=
~SA_CMDL_SOP_BYPASS_LEN_MASK; ~SA_CMDL_SOP_BYPASS_LEN_MASK;
cmdl[upd_info->enc_offset.index] |= cmdl[upd_info->enc_offset.index] |=
((u32)req->enc_offset << FIELD_PREP(SA_CMDL_SOP_BYPASS_LEN_MASK,
__ffs(SA_CMDL_SOP_BYPASS_LEN_MASK)); req->enc_offset);
if (likely(upd_info->flags & SA_CMDL_UPD_ENC_IV)) { if (likely(upd_info->flags & SA_CMDL_UPD_ENC_IV)) {
__be32 *data = (__be32 *)&cmdl[upd_info->enc_iv.index]; __be32 *data = (__be32 *)&cmdl[upd_info->enc_iv.index];
...@@ -666,8 +667,8 @@ static inline void sa_update_cmdl(struct sa_req *req, u32 *cmdl, ...@@ -666,8 +667,8 @@ static inline void sa_update_cmdl(struct sa_req *req, u32 *cmdl,
cmdl[upd_info->auth_offset.index] &= cmdl[upd_info->auth_offset.index] &=
~SA_CMDL_SOP_BYPASS_LEN_MASK; ~SA_CMDL_SOP_BYPASS_LEN_MASK;
cmdl[upd_info->auth_offset.index] |= cmdl[upd_info->auth_offset.index] |=
((u32)req->auth_offset << FIELD_PREP(SA_CMDL_SOP_BYPASS_LEN_MASK,
__ffs(SA_CMDL_SOP_BYPASS_LEN_MASK)); req->auth_offset);
if (upd_info->flags & SA_CMDL_UPD_AUTH_IV) { if (upd_info->flags & SA_CMDL_UPD_AUTH_IV) {
sa_copy_iv((void *)&cmdl[upd_info->auth_iv.index], sa_copy_iv((void *)&cmdl[upd_info->auth_iv.index],
req->auth_iv, req->auth_iv,
...@@ -689,16 +690,16 @@ void sa_set_swinfo(u8 eng_id, u16 sc_id, dma_addr_t sc_phys, ...@@ -689,16 +690,16 @@ void sa_set_swinfo(u8 eng_id, u16 sc_id, dma_addr_t sc_phys,
u8 hash_size, u32 *swinfo) u8 hash_size, u32 *swinfo)
{ {
swinfo[0] = sc_id; swinfo[0] = sc_id;
swinfo[0] |= (flags << __ffs(SA_SW0_FLAGS_MASK)); swinfo[0] |= FIELD_PREP(SA_SW0_FLAGS_MASK, flags);
if (likely(cmdl_present)) if (likely(cmdl_present))
swinfo[0] |= ((cmdl_offset | SA_SW0_CMDL_PRESENT) << swinfo[0] |= FIELD_PREP(SA_SW0_CMDL_INFO_MASK,
__ffs(SA_SW0_CMDL_INFO_MASK)); cmdl_offset | SA_SW0_CMDL_PRESENT);
swinfo[0] |= (eng_id << __ffs(SA_SW0_ENG_ID_MASK)); swinfo[0] |= FIELD_PREP(SA_SW0_ENG_ID_MASK, eng_id);
swinfo[0] |= SA_SW0_DEST_INFO_PRESENT; swinfo[0] |= SA_SW0_DEST_INFO_PRESENT;
swinfo[1] = (u32)(sc_phys & 0xFFFFFFFFULL); swinfo[1] = (u32)(sc_phys & 0xFFFFFFFFULL);
swinfo[2] = (u32)((sc_phys & 0xFFFFFFFF00000000ULL) >> 32); swinfo[2] = (u32)((sc_phys & 0xFFFFFFFF00000000ULL) >> 32);
swinfo[2] |= (hash_size << __ffs(SA_SW2_EGRESS_LENGTH)); swinfo[2] |= FIELD_PREP(SA_SW2_EGRESS_LENGTH, hash_size);
} }
/* Dump the security context */ /* Dump the security context */
......
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