From: Linus Torvalds Date: Tue, 17 Sep 2019 21:30:30 +0000 (-0700) Subject: Merge tag 'asm-generic-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd... X-Git-Tag: v5.4-rc1~154 X-Git-Url: https://repo.jachan.dev/linux.git/commitdiff_plain/b8456f945955e663853eecbbf1bd27e4390ce6d6?hp=-c Merge tag 'asm-generic-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic Pull asm-generic updates from Arnd Bergmann: "Here are three small cleanup patches for the include/asm-generic directory. Christoph removes the __ioremap as part of a cleanup, Nico improves the constant do_div() optimization, and Denis changes BUG_ON() to be consistent with other implementations" * tag 'asm-generic-5.4' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic: asm-generic: add unlikely to default BUG_ON(x) __div64_const32(): improve the generic C version asm-generic: don't provide __ioremap --- b8456f945955e663853eecbbf1bd27e4390ce6d6 diff --combined include/asm-generic/div64.h index b2a9c74efa55,33358245b4fa..a3b98c86f077 --- a/include/asm-generic/div64.h +++ b/include/asm-generic/div64.h @@@ -28,12 -28,12 +28,12 @@@ /** * do_div - returns 2 values: calculate remainder and update new dividend - * @n: pointer to uint64_t dividend (will be updated) + * @n: uint64_t dividend (will be updated) * @base: uint32_t divisor * * Summary: - * ``uint32_t remainder = *n % base;`` - * ``*n = *n / base;`` + * ``uint32_t remainder = n % base;`` + * ``n = n / base;`` * * Return: (uint32_t)remainder * @@@ -178,7 -178,8 +178,8 @@@ static inline uint64_t __arch_xprod_64( uint32_t m_hi = m >> 32; uint32_t n_lo = n; uint32_t n_hi = n >> 32; - uint64_t res, tmp; + uint64_t res; + uint32_t res_lo, res_hi, tmp; if (!bias) { res = ((uint64_t)m_lo * n_lo) >> 32; @@@ -187,8 -188,9 +188,9 @@@ res = (m + (uint64_t)m_lo * n_lo) >> 32; } else { res = m + (uint64_t)m_lo * n_lo; - tmp = (res < m) ? (1ULL << 32) : 0; - res = (res >> 32) + tmp; + res_lo = res >> 32; + res_hi = (res_lo < m_hi); + res = res_lo | ((uint64_t)res_hi << 32); } if (!(m & ((1ULL << 63) | (1ULL << 31)))) { @@@ -197,10 -199,12 +199,12 @@@ res += (uint64_t)m_hi * n_lo; res >>= 32; } else { - tmp = res += (uint64_t)m_lo * n_hi; + res += (uint64_t)m_lo * n_hi; + tmp = res >> 32; res += (uint64_t)m_hi * n_lo; - tmp = (res < tmp) ? (1ULL << 32) : 0; - res = (res >> 32) + tmp; + res_lo = res >> 32; + res_hi = (res_lo < tmp); + res = res_lo | ((uint64_t)res_hi << 32); } res += (uint64_t)m_hi * n_hi;