summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2012-09-14 16:34:23 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-09-17 12:09:07 (GMT)
commitd6f015b6ad035d465d0ab30e9a441e5e8d18d4b7 (patch)
tree32e1fc2bd5e5a378d5f30e3312750ac8bba2f195 /drivers/staging/comedi/drivers
parent7d24e1ac00173a5a271bf1353d4216836dab55e6 (diff)
downloadlinux-fsl-qoriq-d6f015b6ad035d465d0ab30e9a441e5e8d18d4b7.tar.xz
staging: comedi: mite: use ilog2()
The static inline functions `MITE_IODWBSR_1_WSIZE_bits()` and `CR_RL()` in "mite.h" work out a base-2 logarithm using a `while` loop. Change them to use `ilog2()`. Also change `CR_RL()` to clamp the maximum value instead of printing an error. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers')
-rw-r--r--drivers/staging/comedi/drivers/mite.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h
index 1e04b09..0c5736c 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -25,6 +25,7 @@
#define _MITE_H_
#include <linux/pci.h>
+#include <linux/log2.h>
#include "../comedidev.h"
/* #define DEBUG_MITE */
@@ -245,8 +246,9 @@ enum MITE_IODWBSR_bits {
static inline unsigned MITE_IODWBSR_1_WSIZE_bits(unsigned size)
{
unsigned order = 0;
- while (size >>= 1)
- ++order;
+
+ BUG_ON(size == 0);
+ order = ilog2(size);
BUG_ON(order < 1);
return (order - 1) & 0x1f;
}
@@ -393,12 +395,10 @@ static inline int CR_RL(unsigned int retry_limit)
{
int value = 0;
- while (retry_limit) {
- retry_limit >>= 1;
- value++;
- }
+ if (retry_limit)
+ value = 1 + ilog2(retry_limit);
if (value > 0x7)
- printk("comedi: bug! retry_limit too large\n");
+ value = 0x7;
return (value & 0x7) << 21;
}