Skip to contentSkip to conversation

Driver Core patches for 2.6.9

PATCH New Greg KH 2 participants 38 messages Oct 19, 2004 – Oct 23, 2004

Subsystems (11)
Networking VFS USB PCI +7 more subsystems
lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 Driver Core patches for 2.6.9

Hi,

Here are a bunch of driver core 2.6.9. They have all been in the -mm tree for a number of weeks. They contain:
- add /sys/kernel for kernel stuff (like the hotplug sequence number).
- add the kevent code.
- change the export type of the sysfs and driver core symbols.
- other good stuff (see below for full list)

Please pull from:

	bk://kernel.bkbits.net/gregkh/linux/driver-2.6

thanks,

greg k-h

p.s. I'll send these as patches in response to this email to lkml for those who want to see them.

 drivers/base/bus.c             |   32 +--
 drivers/base/class.c           |   34 +--
 drivers/base/core.c            |   25 +-
 drivers/base/driver.c          |   14 -
 drivers/base/firmware.c        |    4 
 drivers/base/firmware_class.c  |    4 
 drivers/base/platform.c        |   16 -
 drivers/base/power/main.c      |    2 
 drivers/base/power/resume.c    |    4 
 drivers/base/power/suspend.c   |    4 
 drivers/base/sys.c             |   16 -
 drivers/pci/pci-driver.c       |    2 
 drivers/usb/core/usb.c         |   61 ++----
 drivers/usb/serial/bus.c       |    1 
 fs/super.c                     |   51 +++++
 fs/sysfs/bin.c                 |    4 
 fs/sysfs/dir.c                 |    6 
 fs/sysfs/file.c                |    6 
 fs/sysfs/group.c               |    4 
 fs/sysfs/symlink.c             |    4 
 include/linux/device.h         |    2 
 include/linux/kobject.h        |   74 ++++---
 include/linux/kobject_uevent.h |   64 +++++-
 include/linux/module.h         |   21 +-
 include/linux/netlink.h        |    1 
 include/linux/pci.h            |    2 
 init/Kconfig                   |   38 +++
 kernel/Makefile                |   11 -
 kernel/ksysfs.c                |   64 ++++++
 kernel/module.c                |   21 ++
 lib/Makefile                   |    6 
 lib/kobject.c                  |  149 +--------------
 lib/kobject_uevent.c           |  393 ++++++++++++++++++++++++++++++++++++++---
 33 files changed, 804 insertions(+), 336 deletions(-)

-----

<kay.sievers:vrfy.org>:
o export of SEQNUM to userspace (creates /sys/kernel)

Andrew Morton:
o ksysfs warning fix
o kobject_uevent warning fix

Greg Kroah-Hartman:
o kevent: add __bitwise kobject_action to help the compiler check for misusages
o PCI: add "struct module *" to struct pci_driver to show symlink in sysfs for pci drivers
o USB: add support for symlink from usb and usb-serial driver to its module in sysfs
o Put symbolic links between drivers and modules in the sysfs tree
o kevent: add block mount and umount support
o kevent: standardize on the event types
o Kobject Userspace Event Notification
o ksyms: don't implement /sys/kernel/hotplug_seqnum if CONFIG_HOTPLUG is not enabled
o kobject: hotplug_seqnum is not 64 bits on all platforms, so fix it
o kobject: fix build error if CONFIG_HOTPLUG is not enabled
o ksysfs: don't build ksysfs if CONFIG_SYSFS is not enabled
o kobject: adjust hotplug_seqnum increment to keep userspace and kernel agreeing

Hannes Reinecke:
o Driver Core: Handle NULL arg for put_device()

Ingo Molnar:
o module.h build fix

Patrick Mochel:
o [driver core] Change symbol exports to GPL only in power/suspend.c
o [driver core] Change symbol exports to GPL only in power/resume.c
o [driver core] Change symbol exports to GPL only in power/main.c
o [sysfs] Change symbol exports to GPL only in symlink.c
o [sysfs] Change symbol exports to GPL only in group.c
o [sysfs] Change symbol exports to GPL only in file.c
o [sysfs] Change symbol exports to GPL only in dir.c
o [sysfs] Change symbol exports to GPL only in bin.c
o [driver model] Change symbol exports to GPL only in sys.c
o [driver model] Change symbol exports to GPL only in platform.c
o [driver model] Change symbol exports to GPL only in firmware.c
o [driver model] Change symbol exports to GPL only in driver.c
o [driver model] Change symbol exports to GPL only in core.c
o [driver model] Change sybmols exports to GPL only in class.c
o [driver model] Change symbol exports to GPL only in drivers/base/bus.c

Roland Dreier:
o USB: use add_hotplug_env_var() in core/usb.c
o kobject: add add_hotplug_env_var()

author
#1 lore raw

PATCH 1/1 Driver Core patches for 2.6.9

ChangeSet 1.1832.55.4, 2004/09/04 00:11:26+02:00, [email protected]

[PATCH] export of SEQNUM to userspace (creates /sys/kernel)

o /sys/kernel/hotplug_seqnum exports the current number
o lib/kobject.c's sequence_num is renamed to hotplug_seqnum and exported by include/linux/kobject.h
o the source file ksysfs.c in kernel/ creates on init the sybsystem "/sys/kernel/" in sysfs

 include/linux/kobject.h |    3 ++
 kernel/Makefile         |    2 -
 kernel/ksysfs.c         |   52 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/kobject.c           |    4 +--
 4 files changed, 58 insertions(+), 3 deletions(-)
include/linux/kobject.h +3 -0
diff -Nru a/include/linux/kobject.h b/include/linux/kobject.h
@@ -26,6 +26,9 @@
 
 #define KOBJ_NAME_LEN	20
 
+/* counter to tag the hotplug event, read only except for the kobject core */
+extern unsigned long hotplug_seqnum;
+
 struct kobject {
 	char			* k_name;
 	char			name[KOBJ_NAME_LEN];
kernel/Makefile +1 -1
diff -Nru a/kernel/Makefile b/kernel/Makefile
@@ -7,7 +7,7 @@
 	    sysctl.o capability.o ptrace.o timer.o user.o \
 	    signal.o sys.o kmod.o workqueue.o pid.o \
 	    rcupdate.o intermodule.o extable.o params.o posix-timers.o \
-	    kthread.o
+	    kthread.o ksysfs.o
 
 obj-$(CONFIG_FUTEX) += futex.o
 obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
kernel/ksysfs.c new file +52 -0

52 lines not on this page · raw message

lib/kobject.c +2 -2
diff -Nru a/lib/kobject.c b/lib/kobject.c
@@ -122,7 +122,7 @@
 
 #define BUFFER_SIZE	1024	/* should be enough memory for the env */
 #define NUM_ENVP	32	/* number of env pointers */
-static unsigned long sequence_num;
+unsigned long hotplug_seqnum;
 static spinlock_t sequence_lock = SPIN_LOCK_UNLOCKED;
 
 static void kset_hotplug(const char *action, struct kset *kset,
@@ -178,7 +178,7 @@
 	scratch += sprintf(scratch, "ACTION=%s", action) + 1;
 
 	spin_lock(&sequence_lock);
-	seq = sequence_num++;
+	seq = hotplug_seqnum++;
 	spin_unlock(&sequence_lock);
 
 	envp [i++] = scratch;
author
#2 lore raw

ChangeSet 1.1832.55.5, 2004/09/04 01:20:44+02:00, [email protected]

kobject: adjust hotplug_seqnum increment to keep userspace and kernel agreeing.

 lib/kobject.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
lib/kobject.c +1 -1
diff -Nru a/lib/kobject.c b/lib/kobject.c
@@ -178,7 +178,7 @@
 	scratch += sprintf(scratch, "ACTION=%s", action) + 1;
 
 	spin_lock(&sequence_lock);
-	seq = hotplug_seqnum++;
+	seq = ++hotplug_seqnum;
 	spin_unlock(&sequence_lock);
 
 	envp [i++] = scratch;
author
#3 lore raw

ChangeSet 1.1832.55.6, 2004/09/04 18:56:35+02:00, [email protected]

ksysfs: don't build ksysfs if CONFIG_SYSFS is not enabled.

Thanks to Kay Sievers for pointing this out.

 kernel/Makefile |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)
kernel/Makefile +2 -1
diff -Nru a/kernel/Makefile b/kernel/Makefile
@@ -7,7 +7,7 @@
 	    sysctl.o capability.o ptrace.o timer.o user.o \
 	    signal.o sys.o kmod.o workqueue.o pid.o \
 	    rcupdate.o intermodule.o extable.o params.o posix-timers.o \
-	    kthread.o ksysfs.o
+	    kthread.o 
 
 obj-$(CONFIG_FUTEX) += futex.o
 obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o
@@ -24,6 +24,7 @@
 obj-$(CONFIG_AUDIT) += audit.o
 obj-$(CONFIG_AUDITSYSCALL) += auditsc.o
 obj-$(CONFIG_KPROBES) += kprobes.o
+obj-$(CONFIG_SYSFS) += ksysfs.o
 
 ifneq ($(CONFIG_IA64),y)
 # According to Alan Modra <[email protected]>, the -fno-omit-frame-pointer is
author
#4 lore raw

ChangeSet 1.1832.55.7, 2004/09/05 00:59:19+02:00, [email protected]

kobject: fix build error if CONFIG_HOTPLUG is not enabled.

Thanks to Kay Sievers for pointing this out.

 lib/kobject.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
lib/kobject.c +1 -1
diff -Nru a/lib/kobject.c b/lib/kobject.c
@@ -118,11 +118,11 @@
 	return path;
 }
 
+unsigned long hotplug_seqnum;
 #ifdef CONFIG_HOTPLUG
 
 #define BUFFER_SIZE	1024	/* should be enough memory for the env */
 #define NUM_ENVP	32	/* number of env pointers */
-unsigned long hotplug_seqnum;
 static spinlock_t sequence_lock = SPIN_LOCK_UNLOCKED;
 
 static void kset_hotplug(const char *action, struct kset *kset,
author
#5 lore raw

ChangeSet 1.1832.55.8, 2004/09/08 21:23:42-07:00, [email protected]

[PATCH] kobject: hotplug_seqnum is not 64 bits on all platforms, so fix it.

Thanks to Kay Sievers for pointing this out.

 include/linux/kobject.h |    2 +-
 kernel/ksysfs.c         |    2 +-
 lib/kobject.c           |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
include/linux/kobject.h +1 -1
diff -Nru a/include/linux/kobject.h b/include/linux/kobject.h
@@ -27,7 +27,7 @@
 #define KOBJ_NAME_LEN	20
 
 /* counter to tag the hotplug event, read only except for the kobject core */
-extern unsigned long hotplug_seqnum;
+extern u64 hotplug_seqnum;
 
 struct kobject {
 	char			* k_name;
kernel/ksysfs.c +1 -1
diff -Nru a/kernel/ksysfs.c b/kernel/ksysfs.c
@@ -24,7 +24,7 @@
 
 static ssize_t hotplug_seqnum_show(struct subsystem *subsys, char *page)
 {
-	return sprintf(page, "%lu\n", hotplug_seqnum);
+	return sprintf(page, "%llu\n", hotplug_seqnum);
 }
 KERNEL_ATTR_RO(hotplug_seqnum);
 
lib/kobject.c +1 -1
diff -Nru a/lib/kobject.c b/lib/kobject.c
@@ -118,7 +118,7 @@
 	return path;
 }
 
-unsigned long hotplug_seqnum;
+u64 hotplug_seqnum;
 #ifdef CONFIG_HOTPLUG
 
 #define BUFFER_SIZE	1024	/* should be enough memory for the env */
author
#6 lore raw

ChangeSet 1.1832.55.9, 2004/09/08 21:25:19-07:00, [email protected]

[PATCH] ksyms: don't implement /sys/kernel/hotplug_seqnum if CONFIG_HOTPLUG is not enabled.

 kernel/ksysfs.c |    8 ++++++--
 lib/kobject.c   |    2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)
kernel/ksysfs.c +6 -2
diff -Nru a/kernel/ksysfs.c b/kernel/ksysfs.c
@@ -22,17 +22,20 @@
 static struct subsys_attribute _name##_attr = \
 	__ATTR(_name, 0644, _name##_show, _name##_store)
 
+#ifdef CONFIG_HOTPLUG
 static ssize_t hotplug_seqnum_show(struct subsystem *subsys, char *page)
 {
 	return sprintf(page, "%llu\n", hotplug_seqnum);
 }
 KERNEL_ATTR_RO(hotplug_seqnum);
-
+#endif
 
 static decl_subsys(kernel, NULL, NULL);
 
 static struct attribute * kernel_attrs[] = {
+#ifdef CONFIG_HOTPLUG
 	&hotplug_seqnum_attr.attr,
+#endif
 	NULL
 };
 
@@ -44,7 +47,8 @@
 {
 	int error = subsystem_register(&kernel_subsys);
 	if (!error)
-		error = sysfs_create_group(&kernel_subsys.kset.kobj, &kernel_attr_group);
+		error = sysfs_create_group(&kernel_subsys.kset.kobj,
+					   &kernel_attr_group);
 
 	return error;
 }
lib/kobject.c +1 -1
diff -Nru a/lib/kobject.c b/lib/kobject.c
@@ -118,9 +118,9 @@
 	return path;
 }
 
-u64 hotplug_seqnum;
 #ifdef CONFIG_HOTPLUG
 
+u64 hotplug_seqnum;
 #define BUFFER_SIZE	1024	/* should be enough memory for the env */
 #define NUM_ENVP	32	/* number of env pointers */
 static spinlock_t sequence_lock = SPIN_LOCK_UNLOCKED;
author
#7 lore raw

ChangeSet 1.1832.55.10, 2004/09/10 16:45:35-07:00, [email protected]

Kobject Userspace Event Notification

Implemetation of userspace events through a netlink socket. The kernel events layer provides the functionality to raise an event from a given kobject represented by its sysfs-path and a signal string to describe the type of event.

Currently, kobject additions and removals are signalized to userspace by forking the /sbin/hotplug helper. This patch moves this special case of userspace-event out of the kobject core to the new kobject_uevent implementation. This makes it possible to send all hotplug messages also through the new netlink transport.

Possible new users of the kernel userspace functionality are filesystem mount events (block device claim/release) or simple device state transitions (cpu overheating).

To send an event, the user needs to pass the kobject, a optional sysfs-attribute and the signal string to the following function:

kobject_uevent(const char *signal,
struct kobject *kobj,
struct attribute *attr)

  Example:
  kobject_uevent("overheating", &cpu->kobj, NULL);

The message itself is sent over multicast netlink socket, which makes it possible for userspace to listen with multiple applications for the same messages.

 include/linux/kobject.h |   32 +++++
 include/linux/netlink.h |    1 
 init/Kconfig            |   19 +++
 lib/Makefile            |    2 
 lib/kobject.c           |  133 ------------------------
 lib/kobject_uevent.c    |  264 ++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 319 insertions(+), 132 deletions(-)
include/linux/kobject.h +29 -3
diff -Nru a/include/linux/kobject.h b/include/linux/kobject.h
@@ -62,9 +62,7 @@
 extern struct kobject * kobject_get(struct kobject *);
 extern void kobject_put(struct kobject *);
 
-extern void kobject_hotplug(const char *action, struct kobject *);
-
-extern char * kobject_get_path(struct kset *, struct kobject *, int);
+extern char * kobject_get_path(struct kobject *, int);
 
 struct kobj_type {
 	void (*release)(struct kobject *);
@@ -236,6 +234,34 @@
 
 extern int subsys_create_file(struct subsystem * , struct subsys_attribute *);
 extern void subsys_remove_file(struct subsystem * , struct subsys_attribute *);
+
+
+#ifdef CONFIG_HOTPLUG
+extern void kobject_hotplug(const char *action, struct kobject *kobj);
+#else
+static inline void kobject_hotplug(const char *action, struct kobject *kobj) { }
+#endif
+
+
+#ifdef CONFIG_KOBJECT_UEVENT
+extern int kobject_uevent(const char *signal, struct kobject *kobj,
+			  struct attribute *attr);
+
+extern int kobject_uevent_atomic(const char *signal, struct kobject *kobj,
+				 struct attribute *attr);
+#else
+static inline int kobject_uevent(const char *signal, struct kobject *kobj,
+				 struct attribute *attr)
+{
+	return 0;
+}
+
+static inline int kobject_uevent_atomic(const char *signal, struct kobject *kobj,
+					struct attribute *attr)
+{
+	return 0;
+}
+#endif
 
 #endif /* __KERNEL__ */
 #endif /* _KOBJECT_H_ */
include/linux/netlink.h +1 -0
diff -Nru a/include/linux/netlink.h b/include/linux/netlink.h
@@ -17,6 +17,7 @@
 #define NETLINK_ROUTE6		11	/* af_inet6 route comm channel */
 #define NETLINK_IP6_FW		13
 #define NETLINK_DNRTMSG		14	/* DECnet routing messages */
+#define NETLINK_KOBJECT_UEVENT	15	/* Kernel messages to userspace */
 #define NETLINK_TAPBASE		16	/* 16 to 31 are ethertap */
 
 #define MAX_LINKS 32		
init/Kconfig +19 -0
diff -Nru a/init/Kconfig b/init/Kconfig
@@ -195,6 +195,25 @@
 	  agent" (/sbin/hotplug) to load modules and set up software needed
 	  to use devices as you hotplug them.
 
+config KOBJECT_UEVENT
+	bool "Kernel Userspace Events"
+	depends on NET
+	default y
+	help
+	  This option enables the kernel userspace event layer, which is a
+	  simple mechanism for kernel-to-user communication over a netlink
+	  socket.
+	  The goal of the kernel userspace events layer is to provide a simple
+	  and efficient events system, that notifies userspace about kobject
+	  state changes. This will enable applications to just listen for
+	  events instead of polling system devices and files.
+	  Hotplug events (kobject addition and removal) are also available on
+	  the netlink socket in addition to the execution of /sbin/hotplug if
+	  CONFIG_HOTPLUG is enabled.
+
+	  Say Y, unless you are building a system requiring minimal memory
+	  consumption.
+
 config IKCONFIG
 	bool "Kernel .config support"
 	---help---
lib/Makefile +1 -1
diff -Nru a/lib/Makefile b/lib/Makefile
@@ -6,7 +6,7 @@
 lib-y := errno.o ctype.o string.o vsprintf.o cmdline.o \
 	 bust_spinlocks.o rbtree.o radix-tree.o dump_stack.o \
 	 kobject.o kref.o idr.o div64.o parser.o int_sqrt.o \
-	 bitmap.o extable.o
+	 bitmap.o extable.o kobject_uevent.o
 
 lib-$(CONFIG_RWSEM_GENERIC_SPINLOCK) += rwsem-spinlock.o
 lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o
lib/kobject.c +5 -128

172 lines not on this page · raw message

lib/kobject_uevent.c new file +264 -0

264 lines not on this page · raw message

author
#8 lore raw

ChangeSet 1.1867.3.2, 2004/09/14 11:12:09-07:00, [email protected]

[PATCH] kobject_uevent warning fix

lib/kobject_uevent.c: In function `kobject_hotplug':
lib/kobject_uevent.c:225: warning: long long int format, u64 arg (arg 3)

 lib/kobject_uevent.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
lib/kobject_uevent.c +1 -1
diff -Nru a/lib/kobject_uevent.c b/lib/kobject_uevent.c
@@ -222,7 +222,7 @@
 	spin_unlock(&sequence_lock);
 
 	envp [i++] = scratch;
-	scratch += sprintf(scratch, "SEQNUM=%lld", seq) + 1;
+	scratch += sprintf(scratch, "SEQNUM=%lld", (long long)seq) + 1;
 
 	envp [i++] = scratch;
 	scratch += sprintf(scratch, "SUBSYSTEM=%s", name) + 1;
author
#9 lore raw

ChangeSet 1.1867.3.3, 2004/09/14 11:12:38-07:00, [email protected]

[PATCH] ksysfs warning fix

kernel/ksysfs.c: In function `hotplug_seqnum_show':
kernel/ksysfs.c:28: warning: long long unsigned int format, u64 arg (arg 3)

 kernel/ksysfs.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
kernel/ksysfs.c +1 -1
diff -Nru a/kernel/ksysfs.c b/kernel/ksysfs.c
@@ -25,7 +25,7 @@
 #ifdef CONFIG_HOTPLUG
 static ssize_t hotplug_seqnum_show(struct subsystem *subsys, char *page)
 {
-	return sprintf(page, "%llu\n", hotplug_seqnum);
+	return sprintf(page, "%llu\n", (unsigned long long)hotplug_seqnum);
 }
 KERNEL_ATTR_RO(hotplug_seqnum);
 #endif
author
#10 lore raw

ChangeSet 1.1867.3.4, 2004/09/15 11:36:09-07:00, [email protected]

kevent: standardize on the event types

This prevents any potential typos from happening.

 drivers/base/firmware_class.c  |    2 -
 include/linux/kobject.h        |   27 ++--------------------
 include/linux/kobject_uevent.h |   50 +++++++++++++++++++++++++++++++++++++++++
 lib/kobject.c                  |    4 +--
 lib/kobject_uevent.c           |   46 +++++++++++++++++++++++++++++++------
 5 files changed, 94 insertions(+), 35 deletions(-)
drivers/base/firmware_class.c +1 -1
diff -Nru a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
@@ -420,7 +420,7 @@
 		add_timer(&fw_priv->timeout);
 	}
 
-	kobject_hotplug("add", &class_dev->kobj);
+	kobject_hotplug(&class_dev->kobj, KOBJ_ADD);
 	wait_for_completion(&fw_priv->completion);
 	set_bit(FW_STATUS_DONE, &fw_priv->status);
 
include/linux/kobject.h +3 -24
diff -Nru a/include/linux/kobject.h b/include/linux/kobject.h
@@ -22,6 +22,7 @@
 #include <linux/sysfs.h>
 #include <linux/rwsem.h>
 #include <linux/kref.h>
+#include <linux/kobject_uevent.h>
 #include <asm/atomic.h>
 
 #define KOBJ_NAME_LEN	20
@@ -235,32 +236,10 @@
 extern int subsys_create_file(struct subsystem * , struct subsys_attribute *);
 extern void subsys_remove_file(struct subsystem * , struct subsys_attribute *);
 
-
 #ifdef CONFIG_HOTPLUG
-extern void kobject_hotplug(const char *action, struct kobject *kobj);
-#else
-static inline void kobject_hotplug(const char *action, struct kobject *kobj) { }
-#endif
-
-
-#ifdef CONFIG_KOBJECT_UEVENT
-extern int kobject_uevent(const char *signal, struct kobject *kobj,
-			  struct attribute *attr);
-
-extern int kobject_uevent_atomic(const char *signal, struct kobject *kobj,
-				 struct attribute *attr);
+extern void kobject_hotplug(struct kobject *kobj, enum kobject_action action);
 #else
-static inline int kobject_uevent(const char *signal, struct kobject *kobj,
-				 struct attribute *attr)
-{
-	return 0;
-}
-
-static inline int kobject_uevent_atomic(const char *signal, struct kobject *kobj,
-					struct attribute *attr)
-{
-	return 0;
-}
+static inline void kobject_hotplug(struct kobject *kobj, enum kobject_action action) { }
 #endif
 
 #endif /* __KERNEL__ */
include/linux/kobject_uevent.h new file +50 -0

50 lines not on this page · raw message

lib/kobject.c +2 -2
diff -Nru a/lib/kobject.c b/lib/kobject.c
@@ -186,7 +186,7 @@
 		if (parent)
 			kobject_put(parent);
 	} else {
-		kobject_hotplug("add", kobj);
+		kobject_hotplug(kobj, KOBJ_ADD);
 	}
 
 	return error;
@@ -300,7 +300,7 @@
 
 void kobject_del(struct kobject * kobj)
 {
-	kobject_hotplug("remove", kobj);
+	kobject_hotplug(kobj, KOBJ_REMOVE);
 	sysfs_remove_dir(kobj);
 	unlink(kobj);
 }
lib/kobject_uevent.c +38 -8

114 lines not on this page · raw message

author
#11 lore raw

ChangeSet 1.1867.3.5, 2004/09/15 14:16:46-07:00, [email protected]

kevent: add block mount and umount support

Send notification over the new netlink socket to let userspace know that the filesystem code claims/releases the superblock on an blockdevice. This way, userspace can get rid of constantly polling /proc/mounts to watch for filesystem changes.

 fs/super.c                     |   17 ++++++++++++++++-
 include/linux/kobject_uevent.h |    1 +
 lib/kobject_uevent.c           |    1 +
 3 files changed, 18 insertions(+), 1 deletion(-)
fs/super.c +16 -1
diff -Nru a/fs/super.c b/fs/super.c
@@ -35,6 +35,7 @@
 #include <linux/vfs.h>
 #include <linux/writeback.h>		/* for the emergency remount stuff */
 #include <linux/idr.h>
+#include <linux/kobject.h>
 #include <asm/uaccess.h>
 
 
@@ -633,6 +634,16 @@
 	return (void *)s->s_bdev == data;
 }
 
+static void bdev_uevent(struct block_device *bdev, enum kobject_action action)
+{
+	if (bdev->bd_disk) {
+		if (bdev->bd_part)
+			kobject_uevent(&bdev->bd_part->kobj, action, NULL);
+		else
+			kobject_uevent(&bdev->bd_disk->kobj, action, NULL);
+	}
+}
+
 struct super_block *get_sb_bdev(struct file_system_type *fs_type,
 	int flags, const char *dev_name, void *data,
 	int (*fill_super)(struct super_block *, void *, int))
@@ -675,8 +686,10 @@
 			up_write(&s->s_umount);
 			deactivate_super(s);
 			s = ERR_PTR(error);
-		} else
+		} else {
 			s->s_flags |= MS_ACTIVE;
+			bdev_uevent(bdev, KOBJ_MOUNT);
+		}
 	}
 
 	return s;
@@ -691,6 +704,8 @@
 void kill_block_super(struct super_block *sb)
 {
 	struct block_device *bdev = sb->s_bdev;
+
+	bdev_uevent(bdev, KOBJ_UMOUNT);
 	generic_shutdown_super(sb);
 	set_blocksize(bdev, sb->s_old_blocksize);
 	close_bdev_excl(bdev);
include/linux/kobject_uevent.h +1 -0
diff -Nru a/include/linux/kobject_uevent.h b/include/linux/kobject_uevent.h
@@ -21,6 +21,7 @@
 	KOBJ_REMOVE	= 0x01,	/* remove event, for hotplug */
 	KOBJ_CHANGE	= 0x02,	/* a sysfs attribute file has changed */
 	KOBJ_MOUNT	= 0x03,	/* mount event for block devices */
+	KOBJ_UMOUNT	= 0x04,	/* umount event for block devices */
 	KOBJ_MAX_ACTION,	/* must be last action listed */
 };
 
lib/kobject_uevent.c +1 -0
diff -Nru a/lib/kobject_uevent.c b/lib/kobject_uevent.c
@@ -32,6 +32,7 @@
 	"remove",	/* 0x01 */
 	"change",	/* 0x02 */
 	"mount",	/* 0x03 */
+	"umount",	/* 0x04 */
 };
 
 static char *action_to_string(enum kobject_action action)
author
#12 lore raw

ChangeSet 1.1939.1.47, 2004/09/22 16:09:41-07:00, [email protected]

[PATCH] Put symbolic links between drivers and modules in the sysfs tree

This functionality is essential for us to work out which drivers are supplied by which modules. We use this in turn to work out which modules are necessary to find the root device (and hence what initrd/initramfs needs to insert).

If you look at debian at the moment, it uses a huge mapping table on /proc/scsi/* to do this. If we implement the sysfs feature, we can simply go from /sys/block/<device> to the actual device to the driver and then to the module with no need of any fixed tables.

 drivers/base/bus.c     |    2 ++
 include/linux/device.h |    2 ++
 include/linux/module.h |   14 ++++++++++++++
 kernel/module.c        |   21 +++++++++++++++++++++
 4 files changed, 39 insertions(+)
drivers/base/bus.c +2 -0
diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
@@ -529,6 +529,7 @@
 		down_write(&bus->subsys.rwsem);
 		driver_attach(drv);
 		up_write(&bus->subsys.rwsem);
+		module_add_driver(drv->owner, drv);
 
 		driver_add_attrs(bus, drv);
 	}
@@ -553,6 +554,7 @@
 		pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);
 		driver_detach(drv);
 		up_write(&drv->bus->subsys.rwsem);
+		module_remove_driver(drv);
 		kobject_unregister(&drv->kobj);
 		put_bus(drv->bus);
 	}
include/linux/device.h +2 -0
diff -Nru a/include/linux/device.h b/include/linux/device.h
@@ -106,6 +106,8 @@
 	struct kobject		kobj;
 	struct list_head	devices;
 
+	struct module 		* owner;
+
 	int	(*probe)	(struct device * dev);
 	int 	(*remove)	(struct device * dev);
 	void	(*shutdown)	(struct device * dev);
include/linux/module.h +14 -0
diff -Nru a/include/linux/module.h b/include/linux/module.h
@@ -445,6 +445,11 @@
 int unregister_module_notifier(struct notifier_block * nb);
 
 extern void print_modules(void);
+
+struct device_driver;
+void module_add_driver(struct module *, struct device_driver *);
+void module_remove_driver(struct device_driver *);
+
 #else /* !CONFIG_MODULES... */
 #define EXPORT_SYMBOL(sym)
 #define EXPORT_SYMBOL_GPL(sym)
@@ -534,6 +539,15 @@
 static inline void print_modules(void)
 {
 }
+
+static inline void module_add_driver(struct module *, struct device_driver *)
+{
+}
+
+static inline void module_remove_driver(struct device_driver *)
+{
+}
+
 #endif /* CONFIG_MODULES */
 
 #define symbol_request(x) try_then_request_module(symbol_get(x), "symbol:" #x)
kernel/module.c +21 -0
diff -Nru a/kernel/module.c b/kernel/module.c
@@ -34,6 +34,7 @@
 #include <linux/vermagic.h>
 #include <linux/notifier.h>
 #include <linux/stop_machine.h>
+#include <linux/device.h>
 #include <asm/uaccess.h>
 #include <asm/semaphore.h>
 #include <asm/cacheflush.h>
@@ -2139,6 +2140,26 @@
 		printk(" %s", mod->name);
 	printk("\n");
 }
+
+void module_add_driver(struct module *mod, struct device_driver *drv)
+{
+	if (!mod || !drv)
+		return;
+	if (!mod->mkobj)
+		return;
+
+	/* Don't check return code; this call is idempotent */
+	sysfs_create_link(&drv->kobj, &mod->mkobj->kobj, "module");
+}
+EXPORT_SYMBOL(module_add_driver);
+
+void module_remove_driver(struct device_driver *drv)
+{
+	if (!drv)
+		return;
+	sysfs_remove_link(&drv->kobj, "module");
+}
+EXPORT_SYMBOL(module_remove_driver);
 
 #ifdef CONFIG_MODVERSIONS
 /* Generate the signature for struct module here, too, for modversions. */
author
#13 lore raw

ChangeSet 1.1939.1.48, 2004/09/22 16:12:59-07:00, [email protected]

[PATCH] USB: add support for symlink from usb and usb-serial driver to its module in sysfs

 drivers/usb/core/usb.c   |    2 ++
 drivers/usb/serial/bus.c |    1 +
 2 files changed, 3 insertions(+)
drivers/usb/core/usb.c +2 -0
diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
@@ -73,6 +73,7 @@
 }
 
 static struct device_driver usb_generic_driver = {
+	.owner = THIS_MODULE,
 	.name =	"usb",
 	.bus = &usb_bus_type,
 	.probe = generic_probe,
@@ -150,6 +151,7 @@
 	new_driver->driver.bus = &usb_bus_type;
 	new_driver->driver.probe = usb_probe_interface;
 	new_driver->driver.remove = usb_unbind_interface;
+	new_driver->driver.owner = new_driver->owner;
 
 	retval = driver_register(&new_driver->driver);
 
drivers/usb/serial/bus.c +1 -0
diff -Nru a/drivers/usb/serial/bus.c b/drivers/usb/serial/bus.c
@@ -120,6 +120,7 @@
 	device->driver.bus = &usb_serial_bus_type;
 	device->driver.probe = usb_serial_device_probe;
 	device->driver.remove = usb_serial_device_remove;
+	device->driver.owner = device->owner;
 
 	retval = driver_register(&device->driver);
 
author
#14 lore raw

ChangeSet 1.1939.1.49, 2004/09/22 16:25:38-07:00, [email protected]

[PATCH] PCI: add "struct module *" to struct pci_driver to show symlink in sysfs for pci drivers.

 drivers/pci/pci-driver.c |    1 +
 include/linux/pci.h      |    2 ++
 2 files changed, 3 insertions(+)
drivers/pci/pci-driver.c +1 -0
diff -Nru a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
@@ -404,6 +404,7 @@
 	drv->driver.bus = &pci_bus_type;
 	drv->driver.probe = pci_device_probe;
 	drv->driver.remove = pci_device_remove;
+	drv->driver.owner = drv->owner;
 	drv->driver.kobj.ktype = &pci_driver_kobj_type;
 	pci_init_dynids(&drv->dynids);
 
include/linux/pci.h +2 -0
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
@@ -631,9 +631,11 @@
 	unsigned int use_driver_data:1; /* pci_driver->driver_data is used */
 };
 
+struct module;
 struct pci_driver {
 	struct list_head node;
 	char *name;
+	struct module *owner;
 	const struct pci_device_id *id_table;	/* must be non-NULL for probe to be called */
 	int  (*probe)  (struct pci_dev *dev, const struct pci_device_id *id);	/* New device inserted */
 	void (*remove) (struct pci_dev *dev);	/* Device removed (NULL if not a hot-plug capable driver) */
author
#15 lore raw

ChangeSet 1.1946.10.1, 2004/09/24 11:43:03-07:00, [email protected]

[driver model] Change symbol exports to GPL only in drivers/base/bus.c.

 drivers/base/bus.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)
drivers/base/bus.c +14 -14
diff -Nru a/drivers/base/bus.c b/drivers/base/bus.c
@@ -721,20 +721,20 @@
 }
 
 
-EXPORT_SYMBOL(bus_for_each_dev);
-EXPORT_SYMBOL(bus_for_each_drv);
+EXPORT_SYMBOL_GPL(bus_for_each_dev);
+EXPORT_SYMBOL_GPL(bus_for_each_drv);
 
-EXPORT_SYMBOL(device_bind_driver);
-EXPORT_SYMBOL(device_release_driver);
+EXPORT_SYMBOL_GPL(device_bind_driver);
+EXPORT_SYMBOL_GPL(device_release_driver);
 
-EXPORT_SYMBOL(bus_add_device);
-EXPORT_SYMBOL(bus_remove_device);
-EXPORT_SYMBOL(bus_register);
-EXPORT_SYMBOL(bus_unregister);
-EXPORT_SYMBOL(bus_rescan_devices);
-EXPORT_SYMBOL(get_bus);
-EXPORT_SYMBOL(put_bus);
-EXPORT_SYMBOL(find_bus);
+EXPORT_SYMBOL_GPL(bus_add_device);
+EXPORT_SYMBOL_GPL(bus_remove_device);
+EXPORT_SYMBOL_GPL(bus_register);
+EXPORT_SYMBOL_GPL(bus_unregister);
+EXPORT_SYMBOL_GPL(bus_rescan_devices);
+EXPORT_SYMBOL_GPL(get_bus);
+EXPORT_SYMBOL_GPL(put_bus);
+EXPORT_SYMBOL_GPL(find_bus);
 
-EXPORT_SYMBOL(bus_create_file);
-EXPORT_SYMBOL(bus_remove_file);
+EXPORT_SYMBOL_GPL(bus_create_file);
+EXPORT_SYMBOL_GPL(bus_remove_file);
author
#16 lore raw

ChangeSet 1.1946.10.2, 2004/09/24 11:43:50-07:00, [email protected]

[driver model] Change sybmols exports to GPL only in class.c

 drivers/base/class.c |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)
drivers/base/class.c +17 -17
diff -Nru a/drivers/base/class.c b/drivers/base/class.c
@@ -528,22 +528,22 @@
 	return 0;
 }
 
-EXPORT_SYMBOL(class_create_file);
-EXPORT_SYMBOL(class_remove_file);
-EXPORT_SYMBOL(class_register);
-EXPORT_SYMBOL(class_unregister);
-EXPORT_SYMBOL(class_get);
-EXPORT_SYMBOL(class_put);
+EXPORT_SYMBOL_GPL(class_create_file);
+EXPORT_SYMBOL_GPL(class_remove_file);
+EXPORT_SYMBOL_GPL(class_register);
+EXPORT_SYMBOL_GPL(class_unregister);
+EXPORT_SYMBOL_GPL(class_get);
+EXPORT_SYMBOL_GPL(class_put);
 
-EXPORT_SYMBOL(class_device_register);
-EXPORT_SYMBOL(class_device_unregister);
-EXPORT_SYMBOL(class_device_initialize);
-EXPORT_SYMBOL(class_device_add);
-EXPORT_SYMBOL(class_device_del);
-EXPORT_SYMBOL(class_device_get);
-EXPORT_SYMBOL(class_device_put);
-EXPORT_SYMBOL(class_device_create_file);
-EXPORT_SYMBOL(class_device_remove_file);
+EXPORT_SYMBOL_GPL(class_device_register);
+EXPORT_SYMBOL_GPL(class_device_unregister);
+EXPORT_SYMBOL_GPL(class_device_initialize);
+EXPORT_SYMBOL_GPL(class_device_add);
+EXPORT_SYMBOL_GPL(class_device_del);
+EXPORT_SYMBOL_GPL(class_device_get);
+EXPORT_SYMBOL_GPL(class_device_put);
+EXPORT_SYMBOL_GPL(class_device_create_file);
+EXPORT_SYMBOL_GPL(class_device_remove_file);
 
-EXPORT_SYMBOL(class_interface_register);
-EXPORT_SYMBOL(class_interface_unregister);
+EXPORT_SYMBOL_GPL(class_interface_register);
+EXPORT_SYMBOL_GPL(class_interface_unregister);
author
#17 lore raw

ChangeSet 1.1946.10.3, 2004/09/24 11:44:27-07:00, [email protected]

[driver model] Change symbol exports to GPL only in core.c

 drivers/base/core.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)
drivers/base/core.c +11 -11
diff -Nru a/drivers/base/core.c b/drivers/base/core.c
@@ -401,17 +401,17 @@
 	return subsystem_register(&devices_subsys);
 }
 
-EXPORT_SYMBOL(device_for_each_child);
+EXPORT_SYMBOL_GPL(device_for_each_child);
 
-EXPORT_SYMBOL(device_initialize);
-EXPORT_SYMBOL(device_add);
-EXPORT_SYMBOL(device_register);
+EXPORT_SYMBOL_GPL(device_initialize);
+EXPORT_SYMBOL_GPL(device_add);
+EXPORT_SYMBOL_GPL(device_register);
 
-EXPORT_SYMBOL(device_del);
-EXPORT_SYMBOL(device_unregister);
-EXPORT_SYMBOL(get_device);
-EXPORT_SYMBOL(put_device);
-EXPORT_SYMBOL(device_find);
+EXPORT_SYMBOL_GPL(device_del);
+EXPORT_SYMBOL_GPL(device_unregister);
+EXPORT_SYMBOL_GPL(get_device);
+EXPORT_SYMBOL_GPL(put_device);
+EXPORT_SYMBOL_GPL(device_find);
 
-EXPORT_SYMBOL(device_create_file);
-EXPORT_SYMBOL(device_remove_file);
+EXPORT_SYMBOL_GPL(device_create_file);
+EXPORT_SYMBOL_GPL(device_remove_file);
author
#18 lore raw

ChangeSet 1.1946.10.4, 2004/09/24 11:45:06-07:00, [email protected]

[driver model] Change symbol exports to GPL only in driver.c

 drivers/base/driver.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
drivers/base/driver.c +7 -7
diff -Nru a/drivers/base/driver.c b/drivers/base/driver.c
@@ -129,11 +129,11 @@
 	return NULL;
 }
 
-EXPORT_SYMBOL(driver_register);
-EXPORT_SYMBOL(driver_unregister);
-EXPORT_SYMBOL(get_driver);
-EXPORT_SYMBOL(put_driver);
-EXPORT_SYMBOL(driver_find);
+EXPORT_SYMBOL_GPL(driver_register);
+EXPORT_SYMBOL_GPL(driver_unregister);
+EXPORT_SYMBOL_GPL(get_driver);
+EXPORT_SYMBOL_GPL(put_driver);
+EXPORT_SYMBOL_GPL(driver_find);
 
-EXPORT_SYMBOL(driver_create_file);
-EXPORT_SYMBOL(driver_remove_file);
+EXPORT_SYMBOL_GPL(driver_create_file);
+EXPORT_SYMBOL_GPL(driver_remove_file);
author
#19 lore raw

ChangeSet 1.1946.10.5, 2004/09/24 11:45:49-07:00, [email protected]

[driver model] Change symbol exports to GPL only in firmware.c

 drivers/base/firmware.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/base/firmware.c +2 -2
diff -Nru a/drivers/base/firmware.c b/drivers/base/firmware.c
@@ -30,5 +30,5 @@
 	return subsystem_register(&firmware_subsys);
 }
 
-EXPORT_SYMBOL(firmware_register);
-EXPORT_SYMBOL(firmware_unregister);
+EXPORT_SYMBOL_GPL(firmware_register);
+EXPORT_SYMBOL_GPL(firmware_unregister);
author
#20 lore raw

ChangeSet 1.1946.10.6, 2004/09/24 11:46:32-07:00, [email protected]

[driver model] Change symbol exports to GPL only in platform.c.

 drivers/base/platform.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
drivers/base/platform.c +8 -8
diff -Nru a/drivers/base/platform.c b/drivers/base/platform.c
@@ -298,13 +298,13 @@
 	}
 	return mask & *dev->dma_mask;
 }
-EXPORT_SYMBOL(dma_get_required_mask);
+EXPORT_SYMBOL_GPL(dma_get_required_mask);
 #endif
 
-EXPORT_SYMBOL(platform_bus);
-EXPORT_SYMBOL(platform_bus_type);
-EXPORT_SYMBOL(platform_device_register);
-EXPORT_SYMBOL(platform_device_register_simple);
-EXPORT_SYMBOL(platform_device_unregister);
-EXPORT_SYMBOL(platform_get_irq);
-EXPORT_SYMBOL(platform_get_resource);
+EXPORT_SYMBOL_GPL(platform_bus);
+EXPORT_SYMBOL_GPL(platform_bus_type);
+EXPORT_SYMBOL_GPL(platform_device_register);
+EXPORT_SYMBOL_GPL(platform_device_register_simple);
+EXPORT_SYMBOL_GPL(platform_device_unregister);
+EXPORT_SYMBOL_GPL(platform_get_irq);
+EXPORT_SYMBOL_GPL(platform_get_resource);
author
#21 lore raw

ChangeSet 1.1946.10.7, 2004/09/24 11:47:15-07:00, [email protected]

[driver model] Change symbol exports to GPL only in sys.c

 drivers/base/sys.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
drivers/base/sys.c +8 -8
diff -Nru a/drivers/base/sys.c b/drivers/base/sys.c
@@ -73,8 +73,8 @@
 	sysfs_remove_file(&s->kobj, &a->attr);
 }
 
-EXPORT_SYMBOL(sysdev_create_file);
-EXPORT_SYMBOL(sysdev_remove_file);
+EXPORT_SYMBOL_GPL(sysdev_create_file);
+EXPORT_SYMBOL_GPL(sysdev_remove_file);
 
 /*
  * declare system_subsys
@@ -98,8 +98,8 @@
 	kset_unregister(&cls->kset);
 }
 
-EXPORT_SYMBOL(sysdev_class_register);
-EXPORT_SYMBOL(sysdev_class_unregister);
+EXPORT_SYMBOL_GPL(sysdev_class_register);
+EXPORT_SYMBOL_GPL(sysdev_class_unregister);
 
 
 static LIST_HEAD(global_drivers);
@@ -157,8 +157,8 @@
 	up_write(&system_subsys.rwsem);
 }
 
-EXPORT_SYMBOL(sysdev_driver_register);
-EXPORT_SYMBOL(sysdev_driver_unregister);
+EXPORT_SYMBOL_GPL(sysdev_driver_register);
+EXPORT_SYMBOL_GPL(sysdev_driver_unregister);
 
 
 
@@ -392,5 +392,5 @@
 	return subsystem_register(&system_subsys);
 }
 
-EXPORT_SYMBOL(sysdev_register);
-EXPORT_SYMBOL(sysdev_unregister);
+EXPORT_SYMBOL_GPL(sysdev_register);
+EXPORT_SYMBOL_GPL(sysdev_unregister);
author
#22 lore raw

ChangeSet 1.1946.10.8, 2004/09/24 11:48:47-07:00, [email protected]

[sysfs] Change symbol exports to GPL only in bin.c

 fs/sysfs/bin.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/sysfs/bin.c +2 -2
diff -Nru a/fs/sysfs/bin.c b/fs/sysfs/bin.c
@@ -199,5 +199,5 @@
 	return 0;
 }
 
-EXPORT_SYMBOL(sysfs_create_bin_file);
-EXPORT_SYMBOL(sysfs_remove_bin_file);
+EXPORT_SYMBOL_GPL(sysfs_create_bin_file);
+EXPORT_SYMBOL_GPL(sysfs_remove_bin_file);
author
#23 lore raw

ChangeSet 1.1946.10.9, 2004/09/24 11:49:41-07:00, [email protected]

[sysfs] Change symbol exports to GPL only in dir.c

 fs/sysfs/dir.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
fs/sysfs/dir.c +3 -3
diff -Nru a/fs/sysfs/dir.c b/fs/sysfs/dir.c
@@ -193,7 +193,7 @@
 	return error;
 }
 
-EXPORT_SYMBOL(sysfs_create_dir);
-EXPORT_SYMBOL(sysfs_remove_dir);
-EXPORT_SYMBOL(sysfs_rename_dir);
+EXPORT_SYMBOL_GPL(sysfs_create_dir);
+EXPORT_SYMBOL_GPL(sysfs_remove_dir);
+EXPORT_SYMBOL_GPL(sysfs_rename_dir);
 
author
#24 lore raw

ChangeSet 1.1946.10.10, 2004/09/24 11:50:39-07:00, [email protected]

[sysfs] Change symbol exports to GPL only in file.c.

 fs/sysfs/file.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
fs/sysfs/file.c +3 -3
diff -Nru a/fs/sysfs/file.c b/fs/sysfs/file.c
@@ -436,7 +436,7 @@
 }
 
 
-EXPORT_SYMBOL(sysfs_create_file);
-EXPORT_SYMBOL(sysfs_remove_file);
-EXPORT_SYMBOL(sysfs_update_file);
+EXPORT_SYMBOL_GPL(sysfs_create_file);
+EXPORT_SYMBOL_GPL(sysfs_remove_file);
+EXPORT_SYMBOL_GPL(sysfs_update_file);
 
author
#25 lore raw

ChangeSet 1.1946.10.11, 2004/09/24 11:51:37-07:00, [email protected]

[sysfs] Change symbol exports to GPL only in group.c.

 fs/sysfs/group.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/sysfs/group.c +2 -2
diff -Nru a/fs/sysfs/group.c b/fs/sysfs/group.c
@@ -78,5 +78,5 @@
 }
 
 
-EXPORT_SYMBOL(sysfs_create_group);
-EXPORT_SYMBOL(sysfs_remove_group);
+EXPORT_SYMBOL_GPL(sysfs_create_group);
+EXPORT_SYMBOL_GPL(sysfs_remove_group);
author
#26 lore raw

ChangeSet 1.1946.10.12, 2004/09/24 11:52:50-07:00, [email protected]

[sysfs] Change symbol exports to GPL only in symlink.c.

 fs/sysfs/symlink.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/sysfs/symlink.c +2 -2
diff -Nru a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
@@ -159,6 +159,6 @@
 		free_page((unsigned long)page);
 }
 
-EXPORT_SYMBOL(sysfs_create_link);
-EXPORT_SYMBOL(sysfs_remove_link);
+EXPORT_SYMBOL_GPL(sysfs_create_link);
+EXPORT_SYMBOL_GPL(sysfs_remove_link);
 
author
#27 lore raw

ChangeSet 1.1946.10.13, 2004/09/24 19:23:11-07:00, [email protected]

[driver core] Change symbol exports to GPL only in power/main.c

 drivers/base/power/main.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/base/power/main.c +1 -1
diff -Nru a/drivers/base/power/main.c b/drivers/base/power/main.c
@@ -66,7 +66,7 @@
 	dev->power.pm_parent = parent;
 	device_pm_hold(parent);
 }
-EXPORT_SYMBOL(device_pm_set_parent);
+EXPORT_SYMBOL_GPL(device_pm_set_parent);
 
 int device_pm_add(struct device * dev)
 {
author
#28 lore raw

ChangeSet 1.1946.10.14, 2004/09/24 19:24:17-07:00, [email protected]

[driver core] Change symbol exports to GPL only in power/resume.c

 drivers/base/power/resume.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/base/power/resume.c +2 -2
diff -Nru a/drivers/base/power/resume.c b/drivers/base/power/resume.c
@@ -58,7 +58,7 @@
 	up(&dpm_sem);
 }
 
-EXPORT_SYMBOL(device_resume);
+EXPORT_SYMBOL_GPL(device_resume);
 
 
 /**
@@ -97,6 +97,6 @@
 	dpm_power_up();
 }
 
-EXPORT_SYMBOL(device_power_up);
+EXPORT_SYMBOL_GPL(device_power_up);
 
 
author
#29 lore raw

ChangeSet 1.1946.10.15, 2004/09/24 19:25:13-07:00, [email protected]

[driver core] Change symbol exports to GPL only in power/suspend.c.

 drivers/base/power/suspend.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/base/power/suspend.c +2 -2
diff -Nru a/drivers/base/power/suspend.c b/drivers/base/power/suspend.c
@@ -100,7 +100,7 @@
 	goto Done;
 }
 
-EXPORT_SYMBOL(device_suspend);
+EXPORT_SYMBOL_GPL(device_suspend);
 
 
 /**
@@ -132,5 +132,5 @@
 	goto Done;
 }
 
-EXPORT_SYMBOL(device_power_down);
+EXPORT_SYMBOL_GPL(device_power_down);
 
author
#30 lore raw

ChangeSet 1.1991, 2004/09/29 13:12:09-07:00, [email protected]

[PATCH] module.h build fix

From: Ingo Molnar <[email protected]>

Forward-declare the structures before using them, rather than relying on previous inclusions.

akpm: The breakage was introduced by bk-driver-core.patch

 include/linux/module.h |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
include/linux/module.h +5 -2
diff -Nru a/include/linux/module.h b/include/linux/module.h
@@ -540,11 +540,14 @@
 {
 }
 
-static inline void module_add_driver(struct module *, struct device_driver *)
+struct device_driver;
+struct module;
+
+static inline void module_add_driver(struct module *module, struct device_driver *driver)
 {
 }
 
-static inline void module_remove_driver(struct device_driver *)
+static inline void module_remove_driver(struct device_driver *driver)
 {
 }
 
author
#31 lore raw

ChangeSet 1.1992, 2004/09/29 16:28:06-07:00, [email protected]

[PATCH] Driver Core: Handle NULL arg for put_device()

Since get_device() accepts a NULL argument, put_device() should do so, too.

 drivers/base/core.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)
drivers/base/core.c +2 -1
diff -Nru a/drivers/base/core.c b/drivers/base/core.c
@@ -293,7 +293,8 @@
  */
 void put_device(struct device * dev)
 {
-	kobject_put(&dev->kobj);
+	if (dev)
+		kobject_put(&dev->kobj);
 }
 
 
author
#32 lore raw

ChangeSet 1.1993, 2004/09/29 17:24:36-07:00, [email protected]

[PATCH] kobject: add add_hotplug_env_var()

Add a (non-inlined) add_hotplug_env_var() function to <linux/kobject.h> and lib/kobject.c. There's a lot of boilerplate code involved in setting environment variables in a hotplug method, so we should have a convenience function to consolidate it (and avoid subtle bugs).

 include/linux/kobject.h |   10 ++++++++-
 lib/kobject_uevent.c    |   52 +++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 60 insertions(+), 2 deletions(-)
include/linux/kobject.h +9 -1
diff -Nru a/include/linux/kobject.h b/include/linux/kobject.h
@@ -237,9 +237,17 @@
 extern void subsys_remove_file(struct subsystem * , struct subsys_attribute *);
 
 #ifdef CONFIG_HOTPLUG
-extern void kobject_hotplug(struct kobject *kobj, enum kobject_action action);
+void kobject_hotplug(struct kobject *kobj, enum kobject_action action);
+int add_hotplug_env_var(char **envp, int num_envp, int *cur_index,
+			char *buffer, int buffer_size, int *cur_len,
+			const char *format, ...)
+	__attribute__((format (printf, 7, 8)));
 #else
 static inline void kobject_hotplug(struct kobject *kobj, enum kobject_action action) { }
+static inline int add_hotplug_env_var(char **envp, int num_envp, int *cur_index, 
+				      char *buffer, int buffer_size, int *cur_len, 
+				      const char *format, ...)
+{ return 0; }
 #endif
 
 #endif /* __KERNEL__ */
lib/kobject_uevent.c +51 -1

57 lines not on this page · raw message

author
#33 lore raw

ChangeSet 1.1994, 2004/09/29 17:26:15-07:00, [email protected]

[PATCH] USB: use add_hotplug_env_var() in core/usb.c

Use the new add_hotplug_env_var() function in drivers/usb/core/usb.c. In addition to cleaning up the code, this fixes a (probably harmless) bug here: for each value added to the environment, the code did

	length += sprintf(...);

and then

	scratch += length;

which means that we skip the sum of the lengths of all the values we've put so far, rather than just the length of the value we just put. This is probably harmless since we're unlikely to run out of space but if nothing else it's setting a bad example....

I've tested this on a system with USB floppy and CD-ROM; hotplug gets the same environment with the patch as without.

 drivers/usb/core/usb.c |   59 +++++++++++++++++++------------------------------
 1 files changed, 23 insertions(+), 36 deletions(-)
drivers/usb/core/usb.c +23 -36
diff -Nru a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
@@ -566,7 +566,6 @@
 {
 	struct usb_interface *intf;
 	struct usb_device *usb_dev;
-	char *scratch;
 	int i = 0;
 	int length = 0;
 
@@ -593,8 +592,6 @@
 		return -ENODEV;
 	}
 
-	scratch = buffer;
-
 #ifdef	CONFIG_USB_DEVICEFS
 	/* If this is available, userspace programs can directly read
 	 * all the device descriptors we don't tell them about.  Or
@@ -602,37 +599,30 @@
 	 *
 	 * FIXME reduce hardwired intelligence here
 	 */
-	envp [i++] = scratch;
-	length += snprintf (scratch, buffer_size - length,
-			    "DEVICE=/proc/bus/usb/%03d/%03d",
-			    usb_dev->bus->busnum, usb_dev->devnum);
-	if ((buffer_size - length <= 0) || (i >= num_envp))
+	if (add_hotplug_env_var(envp, num_envp, &i,
+				buffer, buffer_size, &length,
+				"DEVICE=/proc/bus/usb/%03d/%03d",
+				usb_dev->bus->busnum, usb_dev->devnum))
 		return -ENOMEM;
-	++length;
-	scratch += length;
 #endif
 
 	/* per-device configurations are common */
-	envp [i++] = scratch;
-	length += snprintf (scratch, buffer_size - length, "PRODUCT=%x/%x/%x",
-			    usb_dev->descriptor.idVendor,
-			    usb_dev->descriptor.idProduct,
-			    usb_dev->descriptor.bcdDevice);
-	if ((buffer_size - length <= 0) || (i >= num_envp))
+	if (add_hotplug_env_var(envp, num_envp, &i,
+				buffer, buffer_size, &length,
+				"PRODUCT=%x/%x/%x",
+				usb_dev->descriptor.idVendor,
+				usb_dev->descriptor.idProduct,
+				usb_dev->descriptor.bcdDevice))
 		return -ENOMEM;
-	++length;
-	scratch += length;
 
 	/* class-based driver binding models */
-	envp [i++] = scratch;
-	length += snprintf (scratch, buffer_size - length, "TYPE=%d/%d/%d",
-			    usb_dev->descriptor.bDeviceClass,
-			    usb_dev->descriptor.bDeviceSubClass,
-			    usb_dev->descriptor.bDeviceProtocol);
-	if ((buffer_size - length <= 0) || (i >= num_envp))
+	if (add_hotplug_env_var(envp, num_envp, &i,
+				buffer, buffer_size, &length,
+				"TYPE=%d/%d/%d",
+				usb_dev->descriptor.bDeviceClass,
+				usb_dev->descriptor.bDeviceSubClass,
+				usb_dev->descriptor.bDeviceProtocol))
 		return -ENOMEM;
-	++length;
-	scratch += length;
 
 	if (usb_dev->descriptor.bDeviceClass == 0) {
 		struct usb_host_interface *alt = intf->cur_altsetting;
@@ -641,18 +631,15 @@
 		 * agents are called for all interfaces, and can use
 		 * $DEVPATH/bInterfaceNumber if necessary.
 		 */
-		envp [i++] = scratch;
-		length += snprintf (scratch, buffer_size - length,
-			    "INTERFACE=%d/%d/%d",
-			    alt->desc.bInterfaceClass,
-			    alt->desc.bInterfaceSubClass,
-			    alt->desc.bInterfaceProtocol);
-		if ((buffer_size - length <= 0) || (i >= num_envp))
+		if (add_hotplug_env_var(envp, num_envp, &i,
+					buffer, buffer_size, &length,
+					"INTERFACE=%d/%d/%d",
+					alt->desc.bInterfaceClass,
+					alt->desc.bInterfaceSubClass,
+					alt->desc.bInterfaceProtocol))
 			return -ENOMEM;
-		++length;
-		scratch += length;
-
 	}
+
 	envp[i++] = NULL;
 
 	return 0;
author
#34 lore raw

ChangeSet 1.1996, 2004/10/15 16:07:38-07:00, [email protected]

kevent: add __bitwise kobject_action to help the compiler check for misusages

 include/linux/kobject_uevent.h |   13 ++++++-------
 lib/kobject_uevent.c           |   28 +++++++++++++---------------
 2 files changed, 19 insertions(+), 22 deletions(-)
include/linux/kobject_uevent.h +6 -7
diff -Nru a/include/linux/kobject_uevent.h b/include/linux/kobject_uevent.h
@@ -15,14 +15,13 @@
  * If you add an action here, you must also add the proper string to the
  * lib/kobject_uevent.c file.
  */
-
+typedef int __bitwise kobject_action_t;
 enum kobject_action {
-	KOBJ_ADD	= 0x00,	/* add event, for hotplug */
-	KOBJ_REMOVE	= 0x01,	/* remove event, for hotplug */
-	KOBJ_CHANGE	= 0x02,	/* a sysfs attribute file has changed */
-	KOBJ_MOUNT	= 0x03,	/* mount event for block devices */
-	KOBJ_UMOUNT	= 0x04,	/* umount event for block devices */
-	KOBJ_MAX_ACTION,	/* must be last action listed */
+	KOBJ_ADD	= (__force kobject_action_t) 0x01,	/* add event, for hotplug */
+	KOBJ_REMOVE	= (__force kobject_action_t) 0x02,	/* remove event, for hotplug */
+	KOBJ_CHANGE	= (__force kobject_action_t) 0x03,	/* a sysfs attribute file has changed */
+	KOBJ_MOUNT	= (__force kobject_action_t) 0x04,	/* mount event for block devices */
+	KOBJ_UMOUNT	= (__force kobject_action_t) 0x05,	/* umount event for block devices */
 };
 
 
lib/kobject_uevent.c +13 -15
diff -Nru a/lib/kobject_uevent.c b/lib/kobject_uevent.c
@@ -23,24 +23,22 @@
 #include <linux/kobject.h>
 #include <net/sock.h>
 
-/* 
- * These must match up with the values for enum kobject_action
- * as found in include/linux/kobject_uevent.h
- */
-static char *actions[] = {
-	"add",		/* 0x00 */
-	"remove",	/* 0x01 */
-	"change",	/* 0x02 */
-	"mount",	/* 0x03 */
-	"umount",	/* 0x04 */
-};
-
 static char *action_to_string(enum kobject_action action)
 {
-	if (action >= KOBJ_MAX_ACTION)
+	switch (action) {
+	case KOBJ_ADD:
+		return "add";
+	case KOBJ_REMOVE:
+		return "remove";
+	case KOBJ_CHANGE:
+		return "change";
+	case KOBJ_MOUNT:
+		return "mount";
+	case KOBJ_UMOUNT:
+		return "umount";
+	default:
 		return NULL;
-	else
-		return actions[action];
+	}
 }
 
 #ifdef CONFIG_KOBJECT_UEVENT
#35 lore raw
In reply to Greg KH

Greg KH <[email protected]> ha scritto:

Quoted 5 lines

ChangeSet 1.1867.3.4, 2004/09/15 11:36:09-07:00, [email protected]

kevent: standardize on the event types

This prevents any potential typos from happening.

[cut]

Quoted 11 lines

diff -Nru a/lib/kobject_uevent.c b/lib/kobject_uevent.c

lib/kobject_uevent.c 2004-10-19 09:22:44 -07:00 +1 -0
@@ -19,9 +19,29 @@
 #include <linux/skbuff.h>
 #include <linux/netlink.h>
 #include <linux/string.h>
+#include <linux/kobject_uevent.h>
 #include <linux/kobject.h>
 #include <net/sock.h>
 

lib/kobject_uevent.c 2004-10-19 09:22:44 -07:00 line 35

Quoted 10 lines
lib/kobject_uevent.c 2004-10-19 09:22:44 -07:00 +10 -0
+/* 
+ * These must match up with the values for enum kobject_action
+ * as found in include/linux/kobject_uevent.h
+ */
+static char *actions[] = {
+       "add",          /* 0x00 */
+       "remove",       /* 0x01 */
+       "change",       /* 0x02 */
+       "mount",        /* 0x03 */
+};

Hi Greg,
maybe it's just a matter of taste but I think that is better to do something like this:

static char *actions[] = {
        [KOBJ_ADD]      = "add",
        [KOBJ_REMOVE]   = "remove",
        [KOBJ_CHANGE]   = "change",
        [KOBJ_MOUNT]    = "mount",
};

This would prevent the insertion of a new action in the wrong place.

Luca

Signature · 4 lines
Home: http://kronoz.cjb.net
#include <stdio.h> 
int main(void) {printf("\t\t\b\b\b\b\b\b");
printf("\t\t\b\b\b\b\b\b");return 0;}
author
#36 lore raw
Quoted 35 lines · Kronos

Greg KH <[email protected]> ha scritto:

Quoted 5 lines

ChangeSet 1.1867.3.4, 2004/09/15 11:36:09-07:00, [email protected]

kevent: standardize on the event types

This prevents any potential typos from happening.

[cut]

Quoted 11 lines

diff -Nru a/lib/kobject_uevent.c b/lib/kobject_uevent.c

lib/kobject_uevent.c 2004-10-19 09:22:44 -07:00 +1 -0
@@ -19,9 +19,29 @@
 #include <linux/skbuff.h>
 #include <linux/netlink.h>
 #include <linux/string.h>
+#include <linux/kobject_uevent.h>
 #include <linux/kobject.h>
 #include <net/sock.h>
 

lib/kobject_uevent.c 2004-10-19 09:22:44 -07:00 line 35

Quoted 10 lines
lib/kobject_uevent.c 2004-10-19 09:22:44 -07:00 +10 -0
+/* 
+ * These must match up with the values for enum kobject_action
+ * as found in include/linux/kobject_uevent.h
+ */
+static char *actions[] = {
+       "add",          /* 0x00 */
+       "remove",       /* 0x01 */
+       "change",       /* 0x02 */
+       "mount",        /* 0x03 */
+};

Hi Greg,
maybe it's just a matter of taste but I think that is better to do something like this:

Quoted 8 lines
static char *actions[] = {
        [KOBJ_ADD]      = "add",
        [KOBJ_REMOVE]   = "remove",
        [KOBJ_CHANGE]   = "change",
        [KOBJ_MOUNT]    = "mount",
};

This would prevent the insertion of a new action in the wrong place.

See the following patches in the series, which fixes this up :)

thanks,

greg k-h

#37 lore raw

Il Sat, Oct 23, 2004 at 01:34:04PM -0700, Greg KH ha scritto:

Quoted 43 lines · Kronos
Quoted 42 lines

Greg KH <[email protected]> ha scritto:

Quoted 5 lines

ChangeSet 1.1867.3.4, 2004/09/15 11:36:09-07:00, [email protected]

kevent: standardize on the event types

This prevents any potential typos from happening.

[cut]

Quoted 11 lines

diff -Nru a/lib/kobject_uevent.c b/lib/kobject_uevent.c

lib/kobject_uevent.c 2004-10-19 09:22:44 -07:00 +1 -0
@@ -19,9 +19,29 @@
 #include <linux/skbuff.h>
 #include <linux/netlink.h>
 #include <linux/string.h>
+#include <linux/kobject_uevent.h>
 #include <linux/kobject.h>
 #include <net/sock.h>
 

lib/kobject_uevent.c 2004-10-19 09:22:44 -07:00 line 35

Quoted 10 lines
lib/kobject_uevent.c 2004-10-19 09:22:44 -07:00 +10 -0
+/* 
+ * These must match up with the values for enum kobject_action
+ * as found in include/linux/kobject_uevent.h
+ */
+static char *actions[] = {
+       "add",          /* 0x00 */
+       "remove",       /* 0x01 */
+       "change",       /* 0x02 */
+       "mount",        /* 0x03 */
+};

Hi Greg,
maybe it's just a matter of taste but I think that is better to do something like this:

static char *actions[] = {
        [KOBJ_ADD]      = "add",
        [KOBJ_REMOVE]   = "remove",
        [KOBJ_CHANGE]   = "change",
        [KOBJ_MOUNT]    = "mount",
};
Quoted 3 lines
Quoted 1 line

This would prevent the insertion of a new action in the wrong place.

See the following patches in the series, which fixes this up :)

Ah, right. I missed that patch. Sorry for the noise.

Luca

Signature · 5 lines
Home: http://kronoz.cjb.net
Sono un mirabile incrocio tra Tarzan e Giacomo Leopardi.
In me convivono tutte le doti intelluttuali di Tarzan e
tutta la prestanza fisica di Giacomo Leopardi.
A. Borsani