summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2017-10-05 16:14:14 +0200
committerAlexander Graf <agraf@suse.de>2017-10-09 07:00:29 +0200
commit7d963323a25f87f701aab6ced99a912230f19776 (patch)
treec9bc7fc22a45df0cb138d3f5f165c08b179c448f /lib
parent332468f7fca8d6089367083f4386478793e3b544 (diff)
efi_loader: replace efi_div10 by do_div
We should use the existing 64bit division instead of reinventing the wheel. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/efi_loader/efi_boottime.c36
1 files changed, 2 insertions, 34 deletions
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index df75dd90322..66ce92f6548 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -7,6 +7,7 @@
*/
#include <common.h>
+#include <div64.h>
#include <efi_loader.h>
#include <environment.h>
#include <malloc.h>
@@ -128,39 +129,6 @@ const char *__efi_nesting_dec(void)
return indent_string(--nesting_level);
}
-/* Low 32 bit */
-#define EFI_LOW32(a) (a & 0xFFFFFFFFULL)
-/* High 32 bit */
-#define EFI_HIGH32(a) (a >> 32)
-
-/*
- * 64bit division by 10 implemented as multiplication by 1 / 10
- *
- * Decimals of one tenth: 0x1 / 0xA = 0x0.19999...
- */
-#define EFI_TENTH 0x199999999999999A
-static u64 efi_div10(u64 a)
-{
- u64 prod;
- u64 rem;
- u64 ret;
-
- ret = EFI_HIGH32(a) * EFI_HIGH32(EFI_TENTH);
- prod = EFI_HIGH32(a) * EFI_LOW32(EFI_TENTH);
- rem = EFI_LOW32(prod);
- ret += EFI_HIGH32(prod);
- prod = EFI_LOW32(a) * EFI_HIGH32(EFI_TENTH);
- rem += EFI_LOW32(prod);
- ret += EFI_HIGH32(prod);
- prod = EFI_LOW32(a) * EFI_LOW32(EFI_TENTH);
- rem += EFI_HIGH32(prod);
- ret += EFI_HIGH32(rem);
- /* Round to nearest integer */
- if (rem >= (1 << 31))
- ++ret;
- return ret;
-}
-
/*
* Queue an EFI event.
*
@@ -523,7 +491,7 @@ efi_status_t efi_set_timer(struct efi_event *event, enum efi_timer_delay type,
* The parameter defines a multiple of 100ns.
* We use multiples of 1000ns. So divide by 10.
*/
- trigger_time = efi_div10(trigger_time);
+ do_div(trigger_time, 10);
for (i = 0; i < ARRAY_SIZE(efi_events); ++i) {
if (event != &efi_events[i])