crypto: qat - refactor long expressions

Replace long expressions with local variables in the functions
qat_uclo_wr_uimage_page(), qat_uclo_init_globals() and
qat_uclo_init_umem_seg() to improve readability.

Signed-off-by: Jack Xu <jack.xu@intel.com>
Co-developed-by: Wojciech Ziemba <wojciech.ziemba@intel.com>
Signed-off-by: Wojciech Ziemba <wojciech.ziemba@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Jack Xu 2020-11-06 19:27:53 +08:00 committed by Herbert Xu
parent ecb917ad0f
commit 58c173b9cb
1 changed files with 23 additions and 18 deletions

View File

@ -324,6 +324,7 @@ static int qat_uclo_init_umem_seg(struct icp_qat_fw_loader_handle *handle,
{ {
struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
unsigned int ae, ustore_size, uaddr, i; unsigned int ae, ustore_size, uaddr, i;
struct icp_qat_uclo_aedata *aed;
ustore_size = obj_handle->ustore_phy_size; ustore_size = obj_handle->ustore_phy_size;
if (qat_uclo_fetch_initmem_ae(handle, init_mem, ustore_size, &ae)) if (qat_uclo_fetch_initmem_ae(handle, init_mem, ustore_size, &ae))
@ -333,11 +334,10 @@ static int qat_uclo_init_umem_seg(struct icp_qat_fw_loader_handle *handle,
return -EINVAL; return -EINVAL;
/* set the highest ustore address referenced */ /* set the highest ustore address referenced */
uaddr = (init_mem->addr + init_mem->num_in_bytes) >> 0x2; uaddr = (init_mem->addr + init_mem->num_in_bytes) >> 0x2;
for (i = 0; i < obj_handle->ae_data[ae].slice_num; i++) { aed = &obj_handle->ae_data[ae];
if (obj_handle->ae_data[ae].ae_slices[i]. for (i = 0; i < aed->slice_num; i++) {
encap_image->uwords_num < uaddr) if (aed->ae_slices[i].encap_image->uwords_num < uaddr)
obj_handle->ae_data[ae].ae_slices[i]. aed->ae_slices[i].encap_image->uwords_num = uaddr;
encap_image->uwords_num = uaddr;
} }
return 0; return 0;
} }
@ -845,6 +845,7 @@ static int qat_uclo_init_reg_sym(struct icp_qat_fw_loader_handle *handle,
static int qat_uclo_init_globals(struct icp_qat_fw_loader_handle *handle) static int qat_uclo_init_globals(struct icp_qat_fw_loader_handle *handle)
{ {
struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
struct icp_qat_uclo_aedata *aed;
unsigned int s, ae; unsigned int s, ae;
if (obj_handle->global_inited) if (obj_handle->global_inited)
@ -855,13 +856,13 @@ static int qat_uclo_init_globals(struct icp_qat_fw_loader_handle *handle)
return -EINVAL; return -EINVAL;
} }
} }
for (ae = 0; ae < handle->hal_handle->ae_max_num; ae++) { for (ae = 0; ae < handle->hal_handle->ae_max_num; ae++) {
for (s = 0; s < obj_handle->ae_data[ae].slice_num; s++) { aed = &obj_handle->ae_data[ae];
if (!obj_handle->ae_data[ae].ae_slices[s].encap_image) for (s = 0; s < aed->slice_num; s++) {
if (!aed->ae_slices[s].encap_image)
continue; continue;
if (qat_uclo_init_reg_sym(handle, ae, if (qat_uclo_init_reg_sym(handle, ae, aed->ae_slices[s].encap_image))
obj_handle->ae_data[ae].
ae_slices[s].encap_image))
return -EINVAL; return -EINVAL;
} }
} }
@ -1820,6 +1821,8 @@ static void qat_uclo_wr_uimage_page(struct icp_qat_fw_loader_handle *handle,
struct icp_qat_uof_image *image) struct icp_qat_uof_image *image)
{ {
struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle; struct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;
unsigned long ae_assigned = image->ae_assigned;
struct icp_qat_uclo_aedata *aed;
unsigned int ctx_mask, s; unsigned int ctx_mask, s;
struct icp_qat_uclo_page *page; struct icp_qat_uclo_page *page;
unsigned char ae; unsigned char ae;
@ -1832,24 +1835,26 @@ static void qat_uclo_wr_uimage_page(struct icp_qat_fw_loader_handle *handle,
/* load the default page and set assigned CTX PC /* load the default page and set assigned CTX PC
* to the entrypoint address */ * to the entrypoint address */
for (ae = 0; ae < handle->hal_handle->ae_max_num; ae++) { for (ae = 0; ae < handle->hal_handle->ae_max_num; ae++) {
if (!test_bit(ae, (unsigned long *)&image->ae_assigned)) if (!test_bit(ae, &ae_assigned))
continue; continue;
aed = &obj_handle->ae_data[ae];
/* find the slice to which this image is assigned */ /* find the slice to which this image is assigned */
for (s = 0; s < obj_handle->ae_data[ae].slice_num; s++) { for (s = 0; s < aed->slice_num; s++) {
if (image->ctx_assigned & obj_handle->ae_data[ae]. if (image->ctx_assigned &
ae_slices[s].ctx_mask_assigned) aed->ae_slices[s].ctx_mask_assigned)
break; break;
} }
if (s >= obj_handle->ae_data[ae].slice_num) if (s >= aed->slice_num)
continue; continue;
page = obj_handle->ae_data[ae].ae_slices[s].page; page = aed->ae_slices[s].page;
if (!page->encap_page->def_page) if (!page->encap_page->def_page)
continue; continue;
qat_uclo_wr_uimage_raw_page(handle, page->encap_page, ae); qat_uclo_wr_uimage_raw_page(handle, page->encap_page, ae);
page = obj_handle->ae_data[ae].ae_slices[s].page; page = aed->ae_slices[s].page;
for (ctx = 0; ctx < ICP_QAT_UCLO_MAX_CTX; ctx++) for (ctx = 0; ctx < ICP_QAT_UCLO_MAX_CTX; ctx++)
obj_handle->ae_data[ae].ae_slices[s].cur_page[ctx] = aed->ae_slices[s].cur_page[ctx] =
(ctx_mask & (1 << ctx)) ? page : NULL; (ctx_mask & (1 << ctx)) ? page : NULL;
qat_hal_set_live_ctx(handle, (unsigned char)ae, qat_hal_set_live_ctx(handle, (unsigned char)ae,
image->ctx_assigned); image->ctx_assigned);