Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: qat - replace CHECK_STAT macro with static inline function

The macro CHECK_STAT is used to check that all ring statuses match the
saved state during restoring the state of bank.

Replace the CHECK_STAT macro with the static inline function `check_stat()`
to improve type safety, readability, and debuggability.

This does not introduce any functional change.

Signed-off-by: Suman Kumar Chakraborty <suman.kumar.chakraborty@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Suman Kumar Chakraborty and committed by
Herbert Xu
18126fdf 7ea5ea3e

+19 -14
+19 -14
drivers/crypto/intel/qat/qat_common/adf_gen4_hw_data.c
··· 521 521 } 522 522 } 523 523 524 - #define CHECK_STAT(op, expect_val, name, args...) \ 525 - ({ \ 526 - u32 __expect_val = (expect_val); \ 527 - u32 actual_val = op(args); \ 528 - (__expect_val == actual_val) ? 0 : \ 529 - (pr_err("Fail to restore %s register. Expected 0x%x, actual 0x%x\n", \ 530 - name, __expect_val, actual_val), -EINVAL); \ 531 - }) 524 + static inline int check_stat(u32 (*op)(void __iomem *, u32), u32 expect_val, 525 + const char *name, void __iomem *base, u32 bank) 526 + { 527 + u32 actual_val = op(base, bank); 528 + 529 + if (expect_val == actual_val) 530 + return 0; 531 + 532 + pr_err("Fail to restore %s register. Expected %#x, actual %#x\n", 533 + name, expect_val, actual_val); 534 + 535 + return -EINVAL; 536 + } 532 537 533 538 static int bank_state_restore(struct adf_hw_csr_ops *ops, void __iomem *base, 534 539 u32 bank, struct bank_state *state, u32 num_rings, ··· 616 611 ops->write_csr_ring_srv_arb_en(base, bank, state->ringsrvarben); 617 612 618 613 /* Check that all ring statuses match the saved state. */ 619 - ret = CHECK_STAT(ops->read_csr_stat, state->ringstat0, "ringstat", 614 + ret = check_stat(ops->read_csr_stat, state->ringstat0, "ringstat", 620 615 base, bank); 621 616 if (ret) 622 617 return ret; 623 618 624 - ret = CHECK_STAT(ops->read_csr_e_stat, state->ringestat, "ringestat", 619 + ret = check_stat(ops->read_csr_e_stat, state->ringestat, "ringestat", 625 620 base, bank); 626 621 if (ret) 627 622 return ret; 628 623 629 - ret = CHECK_STAT(ops->read_csr_ne_stat, state->ringnestat, "ringnestat", 624 + ret = check_stat(ops->read_csr_ne_stat, state->ringnestat, "ringnestat", 630 625 base, bank); 631 626 if (ret) 632 627 return ret; 633 628 634 - ret = CHECK_STAT(ops->read_csr_nf_stat, state->ringnfstat, "ringnfstat", 629 + ret = check_stat(ops->read_csr_nf_stat, state->ringnfstat, "ringnfstat", 635 630 base, bank); 636 631 if (ret) 637 632 return ret; 638 633 639 - ret = CHECK_STAT(ops->read_csr_f_stat, state->ringfstat, "ringfstat", 634 + ret = check_stat(ops->read_csr_f_stat, state->ringfstat, "ringfstat", 640 635 base, bank); 641 636 if (ret) 642 637 return ret; 643 638 644 - ret = CHECK_STAT(ops->read_csr_c_stat, state->ringcstat0, "ringcstat", 639 + ret = check_stat(ops->read_csr_c_stat, state->ringcstat0, "ringcstat", 645 640 base, bank); 646 641 if (ret) 647 642 return ret;