linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Driver Core patches for 2.6.9
Date: Tue, 19 Oct 2004 09:35:55 -0700	[thread overview]
Message-ID: <10982037552948@kroah.com> (raw)
In-Reply-To: <20041019163429.GA2402@kroah.com>

ChangeSet 1.1832.55.4, 2004/09/04 00:11:26+02:00, kay.sievers@vrfy.org

[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


Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>


 include/linux/kobject.h |    3 ++
 kernel/Makefile         |    2 -
 kernel/ksysfs.c         |   52 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/kobject.c           |    4 +--
 4 files changed, 58 insertions(+), 3 deletions(-)


diff -Nru a/include/linux/kobject.h b/include/linux/kobject.h
--- a/include/linux/kobject.h	2004-10-19 09:23:35 -07:00
+++ b/include/linux/kobject.h	2004-10-19 09:23:35 -07:00
@@ -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];
diff -Nru a/kernel/Makefile b/kernel/Makefile
--- a/kernel/Makefile	2004-10-19 09:23:35 -07:00
+++ b/kernel/Makefile	2004-10-19 09:23:35 -07:00
@@ -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
diff -Nru a/kernel/ksysfs.c b/kernel/ksysfs.c
--- /dev/null	Wed Dec 31 16:00:00 196900
+++ b/kernel/ksysfs.c	2004-10-19 09:23:35 -07:00
@@ -0,0 +1,52 @@
+/*
+ * kernel/ksysfs.c - sysfs attributes in /sys/kernel, which
+ * 		     are not related to any other subsystem
+ *
+ * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ * 
+ * This file is release under the GPLv2
+ *
+ */
+
+#include <linux/config.h>
+#include <linux/kobject.h>
+#include <linux/string.h>
+#include <linux/sysfs.h>
+#include <linux/module.h>
+#include <linux/init.h>
+
+#define KERNEL_ATTR_RO(_name) \
+static struct subsys_attribute _name##_attr = __ATTR_RO(_name)
+
+#define KERNEL_ATTR_RW(_name) \
+static struct subsys_attribute _name##_attr = \
+	__ATTR(_name, 0644, _name##_show, _name##_store)
+
+static ssize_t hotplug_seqnum_show(struct subsystem *subsys, char *page)
+{
+	return sprintf(page, "%lu\n", hotplug_seqnum);
+}
+KERNEL_ATTR_RO(hotplug_seqnum);
+
+
+static decl_subsys(kernel, NULL, NULL);
+
+static struct attribute * kernel_attrs[] = {
+	&hotplug_seqnum_attr.attr,
+	NULL
+};
+
+static struct attribute_group kernel_attr_group = {
+	.attrs = kernel_attrs,
+};
+
+static int __init ksysfs_init(void)
+{
+	int error = subsystem_register(&kernel_subsys);
+	if (!error)
+		error = sysfs_create_group(&kernel_subsys.kset.kobj, &kernel_attr_group);
+
+	return error;
+}
+
+core_initcall(ksysfs_init);
diff -Nru a/lib/kobject.c b/lib/kobject.c
--- a/lib/kobject.c	2004-10-19 09:23:35 -07:00
+++ b/lib/kobject.c	2004-10-19 09:23:35 -07:00
@@ -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;


  reply	other threads:[~2004-10-19 16:45 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-19 16:34 [BK PATCH] Driver Core patches for 2.6.9 Greg KH
2004-10-19 16:35 ` Greg KH [this message]
2004-10-19 16:35   ` [PATCH] " Greg KH
2004-10-19 16:36     ` Greg KH
2004-10-19 16:36       ` Greg KH
2004-10-19 16:36         ` Greg KH
2004-10-19 16:36           ` Greg KH
2004-10-19 16:36             ` Greg KH
2004-10-19 16:36               ` Greg KH
2004-10-19 16:36                 ` Greg KH
2004-10-19 16:36                   ` Greg KH
2004-10-19 16:36                     ` Greg KH
2004-10-19 16:36                       ` Greg KH
2004-10-19 16:36                         ` Greg KH
2004-10-19 16:36                           ` Greg KH
2004-10-19 16:36                             ` Greg KH
2004-10-19 16:36                               ` Greg KH
2004-10-19 16:36                                 ` Greg KH
2004-10-19 16:36                                   ` Greg KH
2004-10-19 16:36                                     ` Greg KH
2004-10-19 16:36                                       ` Greg KH
2004-10-19 16:36                                         ` Greg KH
2004-10-19 16:36                                           ` Greg KH
2004-10-19 16:36                                             ` Greg KH
2004-10-19 16:36                                               ` Greg KH
2004-10-19 16:36                                                 ` Greg KH
2004-10-19 16:36                                                   ` Greg KH
2004-10-19 16:36                                                     ` Greg KH
2004-10-19 16:36                                                       ` Greg KH
2004-10-19 16:37                                                         ` Greg KH
2004-10-19 16:37                                                           ` Greg KH
2004-10-19 16:37                                                             ` Greg KH
2004-10-19 16:37                                                               ` Greg KH
2004-10-19 16:37                                                                 ` Greg KH
2004-10-19 16:37                                                                   ` Greg KH
2004-10-23 20:20                     ` Kronos
2004-10-23 20:34                       ` Greg KH
2004-10-23 21:46                         ` Kronos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10982037552948@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).