All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] add sysfs mem device support  [2/4]
@ 2003-12-23  0:26 Greg KH
  2003-12-23 13:15 ` Christoph Hellwig
                   ` (15 more replies)
  0 siblings, 16 replies; 42+ messages in thread
From: Greg KH @ 2003-12-23  0:26 UTC (permalink / raw)
  To: linux-hotplug

This adds /sys/class/mem which enables all mem char devices to show up
properly in udev.

Has been posted to linux-kernel every so often since last July, and
acked by a number of other kernel developers.


diff -Nru a/drivers/char/mem.c b/drivers/char/mem.c
--- a/drivers/char/mem.c	Mon Dec 22 16:02:08 2003
+++ b/drivers/char/mem.c	Mon Dec 22 16:02:08 2003
@@ -24,6 +24,7 @@
 #include <linux/smp_lock.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/ptrace.h>
+#include <linux/device.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -657,7 +658,7 @@
 	.open		= memory_open,	/* just a selector for the real open */
 };
 
-static const struct {
+static const struct mem_dev {
 	unsigned int		minor;
 	char			*name;
 	umode_t			mode;
@@ -676,6 +677,23 @@
 	{11,"kmsg",    S_IRUGO | S_IWUSR,           &kmsg_fops},
 };
 
+static void release_mem_dev(struct class_device *class_dev)
+{
+	kfree(class_dev);
+}
+
+static struct class mem_class = {
+	.name		= "mem",
+	.release	= &release_mem_dev,
+};
+
+static ssize_t show_dev(struct class_device *class_dev, char *buf)
+{
+	struct mem_dev *mem_dev = class_get_devdata(class_dev);
+	return print_dev_t(buf, MKDEV(MEM_MAJOR, mem_dev->minor));
+}
+static CLASS_DEVICE_ATTR(dev, S_IRUGO, show_dev, NULL);
+
 static int __init chr_dev_init(void)
 {
 	int i;
@@ -683,7 +701,20 @@
 	if (register_chrdev(MEM_MAJOR,"mem",&memory_fops))
 		printk("unable to get major %d for memory devs\n", MEM_MAJOR);
 
+	class_register(&mem_class);
 	for (i = 0; i < ARRAY_SIZE(devlist); i++) {
+		struct class_device *class_dev;
+
+		class_dev = kmalloc(sizeof(*class_dev), GFP_KERNEL);
+		if (class_dev) {
+			memset(class_dev, 0x00, sizeof(*class_dev));
+			class_dev->class = &mem_class;
+			strncpy(class_dev->class_id, devlist[i].name, BUS_ID_SIZE);
+			class_set_devdata(class_dev, (void *)&devlist[i]);
+			if (!class_device_register(class_dev));
+				class_device_create_file(class_dev, &class_device_attr_dev);
+		}
+
 		devfs_mk_cdev(MKDEV(MEM_MAJOR, devlist[i].minor),
 				S_IFCHR | devlist[i].mode, devlist[i].name);
 	}


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 42+ messages in thread
* [PATCH] some sysfs patches for 2.6.0 [0/4]
@ 2003-12-23  0:21 Greg KH
  2003-12-23  0:24 ` [PATCH] fix sysfs oops [1/4] Greg KH
  0 siblings, 1 reply; 42+ messages in thread
From: Greg KH @ 2003-12-23  0:21 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-kernel, linux-hotplug-devel

Here are 4 sysfs related patches for 2.6.0.  They do the following:

  - fix an oops in sysfs when a kobject has been unregistered before
    it's child has.  An example of this is the oops that happens in
    2.6.0 whenever a usb-serial device is removed that has a port open
    by a user (almost all Pilot devices do this by virtue of the
    protocol...)


  - add sysfs support to the following char drivers:
  	- mem devices (/dev/null and friends)
	- misc devices (/dev/psaux and other odd devices)
	- vc devices

Please apply these to 2.6.0 or your -mm tree depending on how
comfortable you are with them.

thanks,

greg k-h
	

^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2003-12-26 20:15 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-23  0:26 [PATCH] add sysfs mem device support [2/4] Greg KH
2003-12-23 13:15 ` Christoph Hellwig
2003-12-23 15:31 ` Rob Love
2003-12-23 16:07 ` Rob Love
2003-12-23 16:39 ` Christoph Hellwig
2003-12-23 17:56 ` Rob Love
2003-12-23 18:01 ` Greg KH
2003-12-23 19:16 ` Christoph Hellwig
2003-12-23 19:19 ` Rob Love
2003-12-23 19:22 ` Christoph Hellwig
2003-12-23 19:24 ` viro
2003-12-23 19:25 ` Rob Love
2003-12-23 19:28 ` Rob Love
2003-12-23 19:42 ` Jeff Garzik
2003-12-23 19:45 ` Rob Love
2003-12-23 20:00 ` Stephan Maciej
2003-12-23 20:33 ` viro
  -- strict thread matches above, loose matches on Subject: below --
2003-12-23  0:21 [PATCH] some sysfs patches for 2.6.0 [0/4] Greg KH
2003-12-23  0:24 ` [PATCH] fix sysfs oops [1/4] Greg KH
2003-12-23  0:26   ` [PATCH] add sysfs mem device support [2/4] Greg KH
2003-12-23 13:15     ` Christoph Hellwig
2003-12-23 15:31       ` Rob Love
2003-12-23 16:07         ` Rob Love
2003-12-23 16:39         ` Christoph Hellwig
2003-12-23 17:56           ` Rob Love
2003-12-23 20:00           ` Stephan Maciej
2003-12-23 20:33             ` viro
2003-12-25 17:48           ` Andreas Jellinghaus
2003-12-25 18:45             ` Christoph Hellwig
2003-12-25 19:41               ` Martin Schlemmer
2003-12-25 20:57                 ` Martin J. Bligh
2003-12-25 22:02                   ` Martin Schlemmer
2003-12-26 16:19                 ` Christoph Hellwig
2003-12-26 16:54                   ` Tomasz Torcz
2003-12-26 20:18                     ` Martin Schlemmer
2003-12-23 18:01       ` Greg KH
2003-12-23 19:16         ` Christoph Hellwig
2003-12-23 19:19           ` Rob Love
2003-12-23 19:22             ` Christoph Hellwig
2003-12-23 19:25               ` Rob Love
2003-12-23 19:42                 ` Jeff Garzik
2003-12-23 19:45                   ` Rob Love
2003-12-23 19:24             ` viro
2003-12-23 19:28               ` Rob Love

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.