[Concept,09/12] linux: utsname/proc_fs: Add init_utsname() and proc_ops

Message ID 20260118133734.9.b9bfc3ba68fe6c9c3796ed08e6ea7fa78ab96f2d@changeid
State New
Headers
Series ext4l: Continue reducing ext4_uboot.h size with more headers |

Commit Message

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

Add init_utsname() function to utsname.h for getting the system name.
Add proc_ops structure and procfs operation stubs to proc_fs.h.

Update ext4_uboot.h to use these headers instead of duplicating the
definitions.

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

---

 fs/ext4l/ext4_uboot.h   | 26 +++++---------------------
 include/linux/proc_fs.h | 25 +++++++++++++++++++++++++
 include/linux/utsname.h | 12 ++++++++++++
 3 files changed, 42 insertions(+), 21 deletions(-)
  

Patch

diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h
index f6883d888f4..b5df747b963 100644
--- a/fs/ext4l/ext4_uboot.h
+++ b/fs/ext4l/ext4_uboot.h
@@ -1742,13 +1742,8 @@  int bmap(struct inode *inode, sector_t *block);
 #define seq_open(f, ops)		({ (void)(f); (void)(ops); 0; })
 #define seq_release(i, f)		({ (void)(i); (void)(f); 0; })
 
-/* proc_ops structure for journal.c */
-struct proc_ops {
-	int (*proc_open)(struct inode *, struct file *);
-	ssize_t (*proc_read)(struct file *, char *, size_t, loff_t *);
-	loff_t (*proc_lseek)(struct file *, loff_t, int);
-	int (*proc_release)(struct inode *, struct file *);
-};
+/* proc_ops - use linux/proc_fs.h */
+#include <linux/proc_fs.h>
 
 /* seq_read and seq_lseek declarations (defined in stub.c) */
 ssize_t seq_read(struct file *f, char *b, size_t s, loff_t *p);
@@ -1756,11 +1751,7 @@  loff_t seq_lseek(struct file *f, loff_t o, int w);
 
 /* S_IRUGO is in linux/fs.h */
 
-/* procfs stubs */
-#define proc_mkdir(name, parent)	({ (void)(name); (void)(parent); (struct proc_dir_entry *)NULL; })
-#define proc_create_data(n, m, p, ops, d) \
-	({ (void)(n); (void)(m); (void)(p); (void)(ops); (void)(d); (struct proc_dir_entry *)NULL; })
-#define remove_proc_entry(n, p)		do { (void)(n); (void)(p); } while (0)
+/* procfs stubs are now in linux/proc_fs.h */
 
 /* lockdep_init_map and lock_class_key are in linux/lockdep.h */
 
@@ -1790,15 +1781,8 @@  int bh_read(struct buffer_head *bh, int flags);
  * Stubs for mmp.c
  */
 
-/* init_utsname - returns pointer to system name structure */
-struct new_utsname {
-	char nodename[65];
-};
-static inline struct new_utsname *init_utsname(void)
-{
-	static struct new_utsname uts = { .nodename = "u-boot" };
-	return &uts;
-}
+/* init_utsname - use linux/utsname.h */
+#include <linux/utsname.h>
 
 /*
  * Stubs for move_extent.c
diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
index 838321f62bc..ba674440c44 100644
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -9,5 +9,30 @@ 
 /* proc_fs is not used in U-Boot - provide empty stubs */
 
 struct proc_dir_entry;
+struct inode;
+struct file;
+
+/**
+ * struct proc_ops - proc file operations
+ * @proc_open: open callback
+ * @proc_read: read callback
+ * @proc_lseek: seek callback
+ * @proc_release: release callback
+ */
+struct proc_ops {
+	int (*proc_open)(struct inode *, struct file *);
+	ssize_t (*proc_read)(struct file *, char *, size_t, loff_t *);
+	loff_t (*proc_lseek)(struct file *, loff_t, int);
+	int (*proc_release)(struct inode *, struct file *);
+};
+
+/* procfs stubs - not supported in U-Boot */
+#define proc_mkdir(name, parent) \
+	({ (void)(name); (void)(parent); (struct proc_dir_entry *)NULL; })
+#define proc_create_data(n, m, p, ops, d) \
+	({ (void)(n); (void)(m); (void)(p); (void)(ops); (void)(d); \
+	   (struct proc_dir_entry *)NULL; })
+#define remove_proc_entry(n, p) \
+	do { (void)(n); (void)(p); } while (0)
 
 #endif /* _LINUX_PROC_FS_H */
diff --git a/include/linux/utsname.h b/include/linux/utsname.h
index 4e1c712ee56..7f77e7e9511 100644
--- a/include/linux/utsname.h
+++ b/include/linux/utsname.h
@@ -18,4 +18,16 @@  struct uts_namespace {
 
 extern struct uts_namespace init_uts_ns;
 
+/**
+ * init_utsname() - get initial UTS name structure
+ *
+ * Return: pointer to static utsname structure
+ */
+static inline struct new_utsname *init_utsname(void)
+{
+	static struct new_utsname uts = { .nodename = "u-boot" };
+
+	return &uts;
+}
+
 #endif /* _LINUX_UTSNAME_H */