qcacmn: add generic hweight16,32 implementation
In driver there are multiple implementations to read the number of 1's set, have a generic qdf implementation to get the same. Change-Id: Idf769c221b33e867720943fb8c42158edd9600de CRs-Fixed: 2716525
This commit is contained in:

committed by
nshrivas

parent
1c487473e3
commit
a8c41c0988
@@ -631,10 +631,10 @@ int qdf_get_cpu(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qdf_get_hweight8() - count num of 1's in bitmap
|
* qdf_get_hweight8() - count num of 1's in 8-bit bitmap
|
||||||
* @value: input bitmap
|
* @value: input bitmap
|
||||||
*
|
*
|
||||||
* Count num of 1's set in the bitmap
|
* Count num of 1's set in the 8-bit bitmap
|
||||||
*
|
*
|
||||||
* Return: num of 1's
|
* Return: num of 1's
|
||||||
*/
|
*/
|
||||||
@@ -646,6 +646,43 @@ unsigned int qdf_get_hweight8(unsigned int w)
|
|||||||
return (res + (res >> 4)) & 0x0F;
|
return (res + (res >> 4)) & 0x0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* qdf_get_hweight16() - count num of 1's in 16-bit bitmap
|
||||||
|
* @value: input bitmap
|
||||||
|
*
|
||||||
|
* Count num of 1's set in the 16-bit bitmap
|
||||||
|
*
|
||||||
|
* Return: num of 1's
|
||||||
|
*/
|
||||||
|
static inline
|
||||||
|
unsigned int qdf_get_hweight16(unsigned int w)
|
||||||
|
{
|
||||||
|
unsigned int res = (w & 0x5555) + ((w >> 1) & 0x5555);
|
||||||
|
|
||||||
|
res = (res & 0x3333) + ((res >> 2) & 0x3333);
|
||||||
|
res = (res & 0x0F0F) + ((res >> 4) & 0x0F0F);
|
||||||
|
return (res & 0x00FF) + ((res >> 8) & 0x00FF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* qdf_get_hweight32() - count num of 1's in 32-bit bitmap
|
||||||
|
* @value: input bitmap
|
||||||
|
*
|
||||||
|
* Count num of 1's set in the 32-bit bitmap
|
||||||
|
*
|
||||||
|
* Return: num of 1's
|
||||||
|
*/
|
||||||
|
static inline
|
||||||
|
unsigned int qdf_get_hweight32(unsigned int w)
|
||||||
|
{
|
||||||
|
unsigned int res = (w & 0x55555555) + ((w >> 1) & 0x55555555);
|
||||||
|
|
||||||
|
res = (res & 0x33333333) + ((res >> 2) & 0x33333333);
|
||||||
|
res = (res & 0x0F0F0F0F) + ((res >> 4) & 0x0F0F0F0F);
|
||||||
|
res = (res & 0x00FF00FF) + ((res >> 8) & 0x00FF00FF);
|
||||||
|
return (res & 0x0000FFFF) + ((res >> 16) & 0x0000FFFF);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* qdf_device_init_wakeup() - allow a device to wake up the aps system
|
* qdf_device_init_wakeup() - allow a device to wake up the aps system
|
||||||
* @qdf_dev: the qdf device context
|
* @qdf_dev: the qdf device context
|
||||||
|
Reference in New Issue
Block a user