From: Bernardo Innocenti <bernie@develer.com>
Subject: [PATCH] Make sysfs optional for embedded systems

Make sysfs optional for embedded systems.

Applies as-is to 2.6.0-test1.

diff -Nru linux-2.6.0-test1-with_elevator_patch/init/Kconfig linux-2.6.0-test1/init/Kconfig
--- linux-2.6.0-test1-with_elevator_patch/init/Kconfig	2003-07-26 14:25:48.000000000 +0200
+++ linux-2.6.0-test1/init/Kconfig	2003-07-26 16:02:01.000000000 +0200
@@ -141,6 +141,13 @@
 	  Disabling this option will cause the kernel to be built without
 	  support for epoll family of system calls.
 
+config SYS_FS
+	bool "/sys file system support" if EMBEDDED
+	default y
+	help
+	  Disabling this option will cause the kernel to be built without
+	  sysfs, which is mostly needed for power management and hot-plug support.
+
 source "drivers/block/Kconfig.iosched"
 
 endmenu		# General setup
diff -Nru linux-2.6.0-test1-with_elevator_patch/fs/Makefile linux-2.6.0-test1/fs/Makefile
--- linux-2.6.0-test1-with_elevator_patch/fs/Makefile	2003-07-14 05:34:42.000000000 +0200
+++ linux-2.6.0-test1/fs/Makefile	2003-07-26 01:03:59.000000000 +0200
@@ -43,7 +43,7 @@
 
 obj-$(CONFIG_PROC_FS)		+= proc/
 obj-y				+= partitions/
-obj-y				+= sysfs/
+obj-$(CONFIG_SYS_FS)		+= sysfs/
 obj-y				+= devpts/
 
 obj-$(CONFIG_PROFILING)		+= dcookies.o
@@ -74,7 +74,7 @@
 obj-$(CONFIG_NLS)		+= nls/
 obj-$(CONFIG_SYSV_FS)		+= sysv/
 obj-$(CONFIG_SMB_FS)		+= smbfs/
-obj-$(CONFIG_CIFS)             += cifs/
+obj-$(CONFIG_CIFS)              += cifs/
 obj-$(CONFIG_NCP_FS)		+= ncpfs/
 obj-$(CONFIG_HPFS_FS)		+= hpfs/
 obj-$(CONFIG_NTFS_FS)		+= ntfs/
diff -Nru linux-2.6.0-test1-with_elevator_patch/fs/namespace.c linux-2.6.0-test1/fs/namespace.c
--- linux-2.6.0-test1-with_elevator_patch/fs/namespace.c	2003-07-14 05:35:52.000000000 +0200
+++ linux-2.6.0-test1/fs/namespace.c	2003-07-26 15:39:05.000000000 +0200
@@ -1154,7 +1154,11 @@
 		d++;
 		i--;
 	} while (i);
+
+#ifdef CONFIG_SYSFS
 	sysfs_init();
+#endif /* CONFIG_SYSFS */
+
 	init_rootfs();
 	init_mount_tree();
 }
diff -Nru linux-2.6.0-test1-with_elevator_patch/include/linux/sysfs.h linux-2.6.0-test1/include/linux/sysfs.h
--- linux-2.6.0-test1-with_elevator_patch/include/linux/sysfs.h	2003-07-14 05:32:44.000000000 +0200
+++ linux-2.6.0-test1/include/linux/sysfs.h	2003-07-26 15:28:12.000000000 +0200
@@ -25,36 +25,101 @@
 	ssize_t (*write)(struct kobject *, char *, loff_t, size_t);
 };
 
-int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr);
-int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr);
-
 struct sysfs_ops {
 	ssize_t	(*show)(struct kobject *, struct attribute *,char *);
 	ssize_t	(*store)(struct kobject *,struct attribute *,const char *, size_t);
 };
 
+#ifdef CONFIG_SYS_FS
+
 extern int
-sysfs_create_dir(struct kobject *);
+sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr);
+
+extern int
+sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr);
+
+extern int
+sysfs_create_dir(struct kobject * kobj);
 
 extern void
-sysfs_remove_dir(struct kobject *);
+sysfs_remove_dir(struct kobject * kobj);
 
 extern void
-sysfs_rename_dir(struct kobject *, char *new_name);
+sysfs_rename_dir(struct kobject * kobj, char *new_name);
 
 extern int
-sysfs_create_file(struct kobject *, struct attribute *);
+sysfs_create_file(struct kobject * kobj, struct attribute * attr);
 
 extern int
-sysfs_update_file(struct kobject *, struct attribute *);
+sysfs_update_file(struct kobject * kobj, struct attribute * attr);
 
 extern void
-sysfs_remove_file(struct kobject *, struct attribute *);
+sysfs_remove_file(struct kobject * kobj, struct attribute * attr);
 
 extern int 
 sysfs_create_link(struct kobject * kobj, struct kobject * target, char * name);
 
 extern void
-sysfs_remove_link(struct kobject *, char * name);
+sysfs_remove_link(struct kobject * kobj, char * name);
+
+#else /* !CONFIG_SYS_FS */
+
+static inline int
+sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr)
+{
+	return 0;
+}
+
+static inline int
+sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr)
+{
+	return 0;
+}
+
+static inline int
+sysfs_create_dir(struct kobject * kobj)
+{
+	return 0;
+}
+
+static inline void
+sysfs_remove_dir(struct kobject * kobj)
+{
+}
+
+static inline void
+sysfs_rename_dir(struct kobject * kobj, char *new_name)
+{
+}
+
+static inline int
+sysfs_create_file(struct kobject * kobj, struct attribute * attr)
+{
+	return 0;
+}
+
+static inline int
+sysfs_update_file(struct kobject * kobj, struct attribute * attr)
+{
+	return 0;
+}
+
+static inline void
+sysfs_remove_file(struct kobject * kobj, struct attribute * attr)
+{
+}
+
+static inline int 
+sysfs_create_link(struct kobject * kobj, struct kobject * target, char * name)
+{
+	return 0;
+}
+
+static inline void
+sysfs_remove_link(struct kobject * kobj, char * name)
+{
+}
+
+#endif /* !CONFIG_SYS_FS */
 
 #endif /* _SYSFS_H_ */
