Commit c3878a78 authored by Giovanni Cabiddu's avatar Giovanni Cabiddu Committed by Herbert Xu
Browse files

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: default avatarGiovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: default avatarMarco Chiappero <marco.chiappero@intel.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent b79c7532
Loading
Loading
Loading
Loading
+2 −14
Original line number Original line Diff line number Diff line
@@ -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 adf_gen2_get_num_accels(struct adf_hw_device_data *self)
{
{
	u32 i, ctr = 0;

	if (!self || !self->accel_mask)
	if (!self || !self->accel_mask)
		return 0;
		return 0;


	for (i = 0; i < self->num_accel; i++)
	return hweight16(self->accel_mask);
		if (self->accel_mask & (1 << i))
			ctr++;

	return ctr;
}
}
EXPORT_SYMBOL_GPL(adf_gen2_get_num_accels);
EXPORT_SYMBOL_GPL(adf_gen2_get_num_accels);


u32 adf_gen2_get_num_aes(struct adf_hw_device_data *self)
u32 adf_gen2_get_num_aes(struct adf_hw_device_data *self)
{
{
	u32 i, ctr = 0;

	if (!self || !self->ae_mask)
	if (!self || !self->ae_mask)
		return 0;
		return 0;


	for (i = 0; i < self->num_engines; i++)
	return hweight32(self->ae_mask);
		if (self->ae_mask & (1 << i))
			ctr++;

	return ctr;
}
}
EXPORT_SYMBOL_GPL(adf_gen2_get_num_aes);
EXPORT_SYMBOL_GPL(adf_gen2_get_num_aes);