Message ID | 1505297804-26648-1-git-send-email-yamada.masahiro@socionext.com |
---|---|
State | Accepted |
Commit | 84570a0c111ac50372d51271eadc13ff5cbb1a54 |
Headers | show |
Series | linux/kernel.h: import DIV_ROUND_{DOWN, UP}_ULL from Linux | expand |
Hi Tom, 2017-09-13 19:16 GMT+09:00 Masahiro Yamada <yamada.masahiro@socionext.com>: > These macros are useful to avoid link error on 32-bit systems. > > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> > --- > > include/linux/kernel.h | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/include/linux/kernel.h b/include/linux/kernel.h > index 0b61671..87d2d95 100644 > --- a/include/linux/kernel.h > +++ b/include/linux/kernel.h > @@ -57,6 +57,11 @@ > #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) > #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) > > +#define DIV_ROUND_DOWN_ULL(ll, d) \ > + ({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; }) > + > +#define DIV_ROUND_UP_ULL(ll, d) DIV_ROUND_DOWN_ULL((ll) + (d) - 1, (d)) > + > #if BITS_PER_LONG == 32 > # define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP_ULL(ll, d) > #else > -- > 2.7.4 Could you pick this up, if you missed it. I am just copying these two macros from Linux. I do not think it is controversial.
On Wed, Sep 13, 2017 at 07:16:44PM +0900, Masahiro Yamada wrote: > These macros are useful to avoid link error on 32-bit systems. > > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Applied to u-boot/master, thanks! -- Tom
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 0b61671..87d2d95 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -57,6 +57,11 @@ #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) #define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) +#define DIV_ROUND_DOWN_ULL(ll, d) \ + ({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; }) + +#define DIV_ROUND_UP_ULL(ll, d) DIV_ROUND_DOWN_ULL((ll) + (d) - 1, (d)) + #if BITS_PER_LONG == 32 # define DIV_ROUND_UP_SECTOR_T(ll,d) DIV_ROUND_UP_ULL(ll, d) #else
These macros are useful to avoid link error on 32-bit systems. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> --- include/linux/kernel.h | 5 +++++ 1 file changed, 5 insertions(+)