Commit 9867fc9d authored by Arvind Sankar's avatar Arvind Sankar Committed by Ard Biesheuvel

efi/gop: Use helper macros for find_bits

Use the __ffs/__fls macros to calculate the position and size of the
mask.

Correct type of mask to u32 instead of unsigned long.
Signed-off-by: default avatarArvind Sankar <nivedita@alum.mit.edu>
Link: https://lore.kernel.org/r/20200320020028.1936003-9-nivedita@alum.mit.eduSigned-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent f1d1853b
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* *
* ----------------------------------------------------------------------- */ * ----------------------------------------------------------------------- */
#include <linux/bitops.h>
#include <linux/efi.h> #include <linux/efi.h>
#include <linux/screen_info.h> #include <linux/screen_info.h>
#include <asm/efi.h> #include <asm/efi.h>
...@@ -12,27 +13,16 @@ ...@@ -12,27 +13,16 @@
#include "efistub.h" #include "efistub.h"
static void find_bits(unsigned long mask, u8 *pos, u8 *size) static void find_bits(u32 mask, u8 *pos, u8 *size)
{ {
u8 first, len; if (!mask) {
*pos = *size = 0;
first = 0; return;
len = 0;
if (mask) {
while (!(mask & 0x1)) {
mask = mask >> 1;
first++;
}
while (mask & 0x1) {
mask = mask >> 1;
len++;
}
} }
*pos = first; /* UEFI spec guarantees that the set bits are contiguous */
*size = len; *pos = __ffs(mask);
*size = __fls(mask) - *pos + 1;
} }
static void static void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment