[Concept,02/21] ext4l: Make use of log.2 instead of defining locally

Message ID 20260108185149.1995917-3-sjg@u-boot.org
State New
Headers
Series ext4l: Add Kconfig options to reduce binary size (part P) |

Commit Message

Simon Glass Jan. 8, 2026, 6:51 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Make use of the existing linux/log.h header which is supported on most
boards. Drop the unnecessary code in the header and stub files.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 fs/ext4l/ext4_uboot.h | 14 ++------------
 fs/ext4l/stub.c       | 15 ---------------
 2 files changed, 2 insertions(+), 27 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 04b76af7f09..c975396dec4 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -19,6 +19,7 @@ 
 #pragma GCC diagnostic ignored "-Wunused-function"
 #pragma GCC diagnostic ignored "-Wunused-variable"
 
+#include <div64.h>
 #include <linux/types.h>
 #include <linux/bitops.h>
 #include <vsprintf.h>		/* For panic() */
@@ -28,6 +29,7 @@ 
 #include <linux/errno.h>
 #include <linux/err.h>
 #include <linux/list.h>
+#include <linux/log2.h>
 #include <linux/init.h>
 #include <linux/workqueue.h>
 #include <linux/cred.h>
@@ -36,7 +38,6 @@ 
 #include <linux/seq_file.h>
 #include <linux/rbtree.h>	/* Real rbtree implementation */
 #include <u-boot/crc.h>		/* For crc32() used by crc32_be */
-#include <div64.h>
 
 /*
  * Enable ext4_msg() and other diagnostic macros to pass full messages.
@@ -1458,10 +1459,6 @@  typedef unsigned int projid_t;
 	__ret == __old;				\
 })
 
-/* ilog2 - log base 2 */
-#include <log.h>
-#define ilog2(n) (fls(n) - 1)
-
 /* hash_64 - simple 64-bit hash */
 #define hash_64(val, bits)	((unsigned long)((val) >> (64 - (bits))))
 
@@ -2370,10 +2367,6 @@  void fscrypt_show_test_dummy_encryption(struct seq_file *seq, char sep,
 /* Memory allocation - declarations for stub.c */
 void *kvzalloc(size_t size, gfp_t flags);
 #define kvmalloc(size, flags)	kvzalloc(size, flags)
-unsigned long roundup_pow_of_two(unsigned long n);
-
-/* Power of 2 check - declaration for stub.c */
-int is_power_of_2(unsigned long n);
 
 /* Time operations */
 #define ktime_get_ns()			(0ULL)
@@ -2651,9 +2644,6 @@  struct seq_operations {
 /* Block layer constants */
 #define BLK_MAX_SEGMENT_SIZE		65536
 
-/* order_base_2 - log2 rounded up */
-#define order_base_2(n)			ilog2(roundup_pow_of_two(n))
-
 /* num_possible_cpus - number of possible CPUs (always 1 in U-Boot) */
 #define num_possible_cpus()		1
 
diff --git a/fs/ext4l/stub.c b/fs/ext4l/stub.c
index d328c6821a9..af0bb045d5f 100644
--- a/fs/ext4l/stub.c
+++ b/fs/ext4l/stub.c
@@ -360,15 +360,6 @@  void ext4_force_shutdown(void *sb, int flags)
 }
 
 /* Memory stubs */
-unsigned long roundup_pow_of_two(unsigned long n)
-{
-	unsigned long ret = 1;
-
-	while (ret < n)
-		ret <<= 1;
-	return ret;
-}
-
 void *kvzalloc(size_t size, gfp_t flags)
 {
 	return calloc(1, size);
@@ -525,12 +516,6 @@  int sb_set_blocksize(struct super_block *sb, int size)
 	return size;
 }
 
-/* Power of 2 check */
-int is_power_of_2(unsigned long n)
-{
-	return n != 0 && (n & (n - 1)) == 0;
-}
-
 /* strscpy_pad is now a macro in ext4_uboot.h */
 /* kmemdup_nul is defined earlier in this file */