[Concept,13/19] linux: Add kobject.h header with kobject stubs

Message ID 20260117011448.3007171-14-sjg@u-boot.org
State New
Headers
Series ext4l: Reduce ext4_uboot.h size by moving code to include/linux |

Commit Message

Simon Glass Jan. 17, 2026, 1:14 a.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Move kobject type and related stubs to a dedicated header file
that mirrors the Linux kernel organisation.

kobject.h provides:
- struct kobject with minimal fields (just name)
- kobject_put() declaration
- super_set_sysfs_name_bdev() stub macro

These are minimal stubs since U-Boot doesn't have sysfs or the
full kobject infrastructure.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 fs/ext4l/ext4_uboot.h   | 11 ++++-------
 include/linux/kobject.h | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 7 deletions(-)
 create mode 100644 include/linux/kobject.h
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index 4fe7d40c37f..655d64398d5 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -112,10 +112,8 @@  typedef struct { unsigned int val; } kprojid_t;
 #define from_kprojid(ns, kprojid)	((kprojid).val)
 #define projid_eq(a, b)		((a).val == (b).val)
 
-/* kobject - stub */
-struct kobject {
-	const char *name;
-};
+/* kobject is now in linux/kobject.h */
+#include <linux/kobject.h>
 
 /* lockdep stubs - needed before jbd2.h is included */
 #include <linux/lockdep.h>
@@ -1489,8 +1487,7 @@  struct block_device *file_bdev(struct file *file);
 int sync_blockdev(struct block_device *bdev);
 void invalidate_bdev(struct block_device *bdev);
 
-/* Kobject - declarations for stub.c */
-void kobject_put(struct kobject *kobj);
+/* kobject_put is now in linux/kobject.h */
 /* wait_for_completion is now a macro in linux/completion.h */
 
 /* DAX - declaration for stub.c */
@@ -1591,7 +1588,7 @@  static inline void super_set_uuid(struct super_block *sb, const u8 *uuid,
 	memcpy(sb->s_uuid.b, uuid, len);
 }
 
-#define super_set_sysfs_name_bdev(sb)		do { } while (0)
+/* super_set_sysfs_name_bdev is now in linux/kobject.h */
 
 /*
  * mb_cache - metadata block cache stubs for xattr.c
diff --git a/include/linux/kobject.h b/include/linux/kobject.h
new file mode 100644
index 00000000000..f6427724d00
--- /dev/null
+++ b/include/linux/kobject.h
@@ -0,0 +1,34 @@ 
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Kobject stubs for U-Boot
+ *
+ * U-Boot doesn't have sysfs or the full kobject infrastructure,
+ * so these are minimal stubs.
+ */
+#ifndef _LINUX_KOBJECT_H
+#define _LINUX_KOBJECT_H
+
+#include <linux/types.h>
+
+/**
+ * struct kobject - kernel object
+ * @name: name of the object
+ *
+ * U-Boot stub - minimal structure for filesystem code.
+ */
+struct kobject {
+	const char *name;
+};
+
+/**
+ * kobject_put() - decrement refcount on kobject
+ * @kobj: object to release
+ *
+ * U-Boot stub - declared here, implemented in stub.c.
+ */
+void kobject_put(struct kobject *kobj);
+
+/* sysfs stubs */
+#define super_set_sysfs_name_bdev(sb)	do { } while (0)
+
+#endif /* _LINUX_KOBJECT_H */