lkml.org 
[lkml]   [2018]   [Dec]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v13 1/6] x86/boot: Introduce kstrtoull() to boot directory instead of simple_strtoull()
On Wed, Dec 12, 2018 at 11:10:48AM +0800, Chao Fan wrote:
> Introduce kstrtoull() from lib/kstrtox.c to boot directory so that code
> in boot/ can use kstrtoull() and the old simple_strtoull() can be
> replaced.
>
> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
> ---
> arch/x86/boot/string.c | 137 +++++++++++++++++++++++++++++++++++++++++
> arch/x86/boot/string.h | 2 +
> 2 files changed, 139 insertions(+)
>
> diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c
> index c4428a176973..e02405f20f98 100644
> --- a/arch/x86/boot/string.c
> +++ b/arch/x86/boot/string.c
> @@ -12,7 +12,10 @@
> * Very basic string functions
> */
>
> +#define _LINUX_CTYPE_H
> #include <linux/types.h>
> +#include <linux/kernel.h>
> +#include <linux/errno.h>
> #include <asm/asm.h>
> #include "ctype.h"
> #include "string.h"
> @@ -187,3 +190,137 @@ char *strchr(const char *s, int c)
> return NULL;
> return (char *)s;
> }
> +
> +static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
> +{
> + union {
> + u64 v64;
> + u32 v32[2];
> + } d = { dividend };
> + u32 upper;
> +
> + upper = d.v32[1];
> + d.v32[1] = 0;
> + if (upper >= divisor) {
> + d.v32[1] = upper / divisor;
> + upper %= divisor;
> + }
> + asm ("divl %2" : "=a" (d.v32[0]), "=d" (*remainder) :
> + "rm" (divisor), "0" (d.v32[0]), "1" (upper));
> + return d.v64;
> +}

Why aren't you using the simple one from include/linux/math64.h ?

Rest looks ok.

--
Regards/Gruss,
Boris.

Good mailing practices for 400: avoid top-posting and trim the reply.

\
 
 \ /
  Last update: 2018-12-13 13:51    [W:1.152 / U:0.008 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site