aboutsummaryrefslogtreecommitdiff
path: root/fs/btrfs/compat.h
diff options
context:
space:
mode:
authorQu Wenruo <wqu@suse.com>2020-06-24 18:02:53 +0200
committerTom Rini <trini@konsulko.com>2020-09-07 20:57:27 -0400
commitbe3594254605047d0623f905329d160544ca925c (patch)
treea5f3ddd61bbb247025d666af0f98f2afe20815d3 /fs/btrfs/compat.h
parent9a9be5ec17d24779945a8b3e595c105d98596bdd (diff)
downloadu-boot-be3594254605047d0623f905329d160544ca925c.zip
u-boot-be3594254605047d0623f905329d160544ca925c.tar.gz
u-boot-be3594254605047d0623f905329d160544ca925c.tar.bz2
fs: btrfs: Crossport structure accessor into ctree.h
This brings all structure accessors from btrfs-progs/ctree.h, as in kernel's ctree.h. All these accessors handle the endian convert at runtime, and since all of them are defined as static inline functions, those which aren't used won't take space in resulting binary. Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: Marek BehĂșn <marek.behun@nic.cz>
Diffstat (limited to 'fs/btrfs/compat.h')
-rw-r--r--fs/btrfs/compat.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/fs/btrfs/compat.h b/fs/btrfs/compat.h
index b354c17..12fb9f8 100644
--- a/fs/btrfs/compat.h
+++ b/fs/btrfs/compat.h
@@ -24,6 +24,20 @@
#define __le8 u8
/*
+ * Macros to generate set/get funcs for the struct fields
+ * assume there is a lefoo_to_cpu for every type, so lets make a simple
+ * one for u8:
+ */
+#define le8_to_cpu(v) (v)
+#define cpu_to_le8(v) (v)
+#define __le8 u8
+
+#define get_unaligned_le8(p) (*((u8 *)(p)))
+#define get_unaligned_8(p) (*((u8 *)(p)))
+#define put_unaligned_le8(val,p) ((*((u8 *)(p))) = (val))
+#define put_unaligned_8(val,p) ((*((u8 *)(p))) = (val))
+
+/*
* Read data from device specified by @desc and @part
*
* U-boot equivalent of pread().