summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorGiovanni Cabiddu <giovanni.cabiddu@intel.com>2021-09-28 14:44:34 +0300
committerHerbert Xu <herbert@gondor.apana.org.au>2021-10-08 15:02:42 +0300
commitc3878a786be09d3f7df17936c922be430cdd4e8e (patch)
tree1d9f0488df16d65aff890eede6791fe1151db8b0 /drivers
parentb79c7532dc337c87365fda62914eaeb0e038160d (diff)
downloadlinux-c3878a786be09d3f7df17936c922be430cdd4e8e.tar.xz
crypto: qat - use hweight for bit counting
Replace homegrown bit counting logic in adf_gen2_get_num_accels() and adf_gen2_get_num_aes() with the functions hweight16() and hweight32(), respectively. Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Reviewed-by: Marco Chiappero <marco.chiappero@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/crypto/qat/qat_common/adf_gen2_hw_data.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/drivers/crypto/qat/qat_common/adf_gen2_hw_data.c b/drivers/crypto/qat/qat_common/adf_gen2_hw_data.c
index 1deeeaed9a8c..262bdc05dab4 100644
--- a/drivers/crypto/qat/qat_common/adf_gen2_hw_data.c
+++ b/drivers/crypto/qat/qat_common/adf_gen2_hw_data.c
@@ -54,31 +54,19 @@ EXPORT_SYMBOL_GPL(adf_gen2_disable_vf2pf_interrupts);
u32 adf_gen2_get_num_accels(struct adf_hw_device_data *self)
{
- u32 i, ctr = 0;
-
if (!self || !self->accel_mask)
return 0;
- for (i = 0; i < self->num_accel; i++)
- if (self->accel_mask & (1 << i))
- ctr++;
-
- return ctr;
+ return hweight16(self->accel_mask);
}
EXPORT_SYMBOL_GPL(adf_gen2_get_num_accels);
u32 adf_gen2_get_num_aes(struct adf_hw_device_data *self)
{
- u32 i, ctr = 0;
-
if (!self || !self->ae_mask)
return 0;
- for (i = 0; i < self->num_engines; i++)
- if (self->ae_mask & (1 << i))
- ctr++;
-
- return ctr;
+ return hweight32(self->ae_mask);
}
EXPORT_SYMBOL_GPL(adf_gen2_get_num_aes);