[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] xen/lib: Switch to xen/byteorder.h



commit 9aaae6cb4df2a4a98147ca7b49a6e97fc3bbb9ad
Author:     Lin Liu <lin.liu@xxxxxxxxxx>
AuthorDate: Wed Oct 20 04:29:46 2021 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Fri Apr 18 15:16:12 2025 +0100

    xen/lib: Switch to xen/byteorder.h
    
    In divmod.c, additionally swap xen/lib.h for xen/macros.h as only ABS() is
    needed.
    
    In find-next-bit.c, ext2 has nothing to do with this logic.  It was a local
    modification when the logic was imported from Linux, because Xen didn't 
have a
    suitable helper at the time.
    
    The new infrastructure does have a suitable primitive, so use it.
    
    No functional change.
    
    Signed-off-by: Lin Liu <lin.liu@xxxxxxxxxx>
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/lib/divmod.c        |  4 ++--
 xen/lib/find-next-bit.c | 39 +++++++--------------------------------
 2 files changed, 9 insertions(+), 34 deletions(-)

diff --git a/xen/lib/divmod.c b/xen/lib/divmod.c
index 0377d62130..063e867a81 100644
--- a/xen/lib/divmod.c
+++ b/xen/lib/divmod.c
@@ -1,6 +1,6 @@
-#include <xen/lib.h>
+#include <xen/byteorder.h>
+#include <xen/macros.h>
 #include <xen/types.h>
-#include <asm/byteorder.h>
 
 /*
  * A couple of 64 bit operations ported from FreeBSD.
diff --git a/xen/lib/find-next-bit.c b/xen/lib/find-next-bit.c
index 761b027398..9b8d7814f2 100644
--- a/xen/lib/find-next-bit.c
+++ b/xen/lib/find-next-bit.c
@@ -9,8 +9,7 @@
  * 2 of the License, or (at your option) any later version.
  */
 #include <xen/bitops.h>
-
-#include <asm/byteorder.h>
+#include <xen/byteorder.h>
 
 #define __ffs(x) (ffsl(x) - 1)
 #define ffz(x) __ffs(~(x))
@@ -164,30 +163,6 @@ EXPORT_SYMBOL(find_first_zero_bit);
 
 #ifdef __BIG_ENDIAN
 
-/* include/linux/byteorder does not support "unsigned long" type */
-static inline unsigned long ext2_swabp(const unsigned long * x)
-{
-#if BITS_PER_LONG == 64
-       return (unsigned long) __swab64p((u64 *) x);
-#elif BITS_PER_LONG == 32
-       return (unsigned long) __swab32p((u32 *) x);
-#else
-#error BITS_PER_LONG not defined
-#endif
-}
-
-/* include/linux/byteorder doesn't support "unsigned long" type */
-static inline unsigned long ext2_swab(const unsigned long y)
-{
-#if BITS_PER_LONG == 64
-       return (unsigned long) __swab64((u64) y);
-#elif BITS_PER_LONG == 32
-       return (unsigned long) __swab32((u32) y);
-#else
-#error BITS_PER_LONG not defined
-#endif
-}
-
 #ifndef find_next_zero_bit_le
 unsigned long find_next_zero_bit_le(const void *addr, unsigned
                long size, unsigned long offset)
@@ -202,7 +177,7 @@ unsigned long find_next_zero_bit_le(const void *addr, 
unsigned
        size -= result;
        offset &= (BITS_PER_LONG - 1UL);
        if (offset) {
-               tmp = ext2_swabp(p++);
+               tmp = bswapl(*p++);
                tmp |= (~0UL >> (BITS_PER_LONG - offset));
                if (size < BITS_PER_LONG)
                        goto found_first;
@@ -220,7 +195,7 @@ unsigned long find_next_zero_bit_le(const void *addr, 
unsigned
        }
        if (!size)
                return result;
-       tmp = ext2_swabp(p);
+       tmp = bswapl(*p);
 found_first:
        tmp |= ~0UL << size;
        if (tmp == ~0UL)        /* Are any bits zero? */
@@ -229,7 +204,7 @@ found_middle:
        return result + ffz(tmp);
 
 found_middle_swap:
-       return result + ffz(ext2_swab(tmp));
+       return result + ffz(bswapl(tmp));
 }
 EXPORT_SYMBOL(find_next_zero_bit_le);
 #endif
@@ -248,7 +223,7 @@ unsigned long find_next_bit_le(const void *addr, unsigned
        size -= result;
        offset &= (BITS_PER_LONG - 1UL);
        if (offset) {
-               tmp = ext2_swabp(p++);
+               tmp = bswapl(*p++);
                tmp &= (~0UL << offset);
                if (size < BITS_PER_LONG)
                        goto found_first;
@@ -267,7 +242,7 @@ unsigned long find_next_bit_le(const void *addr, unsigned
        }
        if (!size)
                return result;
-       tmp = ext2_swabp(p);
+       tmp = bswapl(*p);
 found_first:
        tmp &= (~0UL >> (BITS_PER_LONG - size));
        if (tmp == 0UL)         /* Are any bits set? */
@@ -276,7 +251,7 @@ found_middle:
        return result + __ffs(tmp);
 
 found_middle_swap:
-       return result + __ffs(ext2_swab(tmp));
+       return result + __ffs(bswapl(tmp));
 }
 EXPORT_SYMBOL(find_next_bit_le);
 #endif
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.