Skip to contentSkip to conversation

Driver Core update for 2.6.6-rc1

PATCH New Greg KH 1 participant 19 messages Apr 15, 2004

Subsystems (5)
lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 Driver Core update for 2.6.6-rc1

Hi,

Here are a few driver core changes for 2.6.6-rc1. These have all been in the -mm tree for a number of weeks now. They fix a few minor bugs, and add sysfs class support to a few miscellaneous drivers.

I'd like to thank Andrew for fixing the vc bug so that the sysfs class patch that I've been sitting on for months can be added to the main tree, that was pretty nasty...

Please pull from:

	bk://linuxusb.bkbits.net/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/Kconfig                    |   16 ++++-----
 drivers/base/class.c                    |    6 +--
 drivers/char/dsp56k.c                   |   27 +++++++++++++++-
 drivers/char/ftape/zftape/zftape-init.c |   17 ++++++++++
 drivers/char/istallion.c                |   24 ++++++++++++--
 drivers/char/stallion.c                 |   12 ++++++-
 drivers/char/tipar.c                    |   16 ++++++---
 drivers/char/tpqic02.c                  |   44 ++++++++++++++++++++++++++
 drivers/char/vc_screen.c                |   10 ++++++
 drivers/char/vt.c                       |    6 ++-
 drivers/isdn/capi/capi.c                |   53 +++++++++++++++++++++-----------
 drivers/video/fbmem.c                   |   38 ++++++++++++++++++++++
 fs/coda/psdev.c                         |   38 +++++++++++++++++++---
 lib/kobject.c                           |    6 +--
 14 files changed, 261 insertions(+), 52 deletions(-)

-----

<lxiep:ltcfwd.linux.ibm.com>:
o kobject_set_name() doesn't allocate enough space

<romain:lievin.net>:
o tipar char driver (divide by zero)

Greg Kroah-Hartman:
o Driver class: remove possible oops
o VC: fix bug in vty_init() where vcs_init() was not called early enough
o add sysfs support for vc devices
o Driver Core: fix spaces instead of tabs problem in the Kconfig file

Hanna V. Linder:
o Fix class support to istallion.c
o Fix for patch to add class support to stallion.c
o fix sysfs class support to fs/coda/psdev.c
o Add sysfs class support to fs/coda/psdev.c
o add class support to dsp56k.c
o added class support to istallion.c
o added class support to stallion.c
o add class support to floppy tape driver zftape-init.c
o QIC-02 tape drive hookup to classes in sysfs

Luca Tettamanti:
o Sysfs for framebuffer

Marcel Holtmann:
o Fix sysfs class support for CAPI
o Add sysfs class support for CAPI

author
#1 lore raw

PATCH 1/1 Driver Core update for 2.6.6-rc1

ChangeSet 1.1643.36.1, 2004/03/19 13:05:08-08:00, [email protected]

Driver Core: fix spaces instead of tabs problem in the Kconfig file.

 drivers/base/Kconfig |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
drivers/base/Kconfig +8 -8
diff -Nru a/drivers/base/Kconfig b/drivers/base/Kconfig
@@ -9,14 +9,14 @@
 	  the kernel tree does.
 
 config DEBUG_DRIVER
-        bool "Driver Core verbose debug messages"
-        depends on DEBUG_KERNEL
-        help
-          Say Y here if you want the Driver core to produce a bunch of
-          debug messages to the system log. Select this if you are having a
-          problem with the driver core and want to see more of what is
-          going on.
+	 bool "Driver Core verbose debug messages"
+	depends on DEBUG_KERNEL
+	help
+	  Say Y here if you want the Driver core to produce a bunch of
+	  debug messages to the system log. Select this if you are having a
+	  problem with the driver core and want to see more of what is
+	  going on.
 
-          If you are unsure about this, say N here.
+	  If you are unsure about this, say N here.
 
 endmenu
author
#2 lore raw

ChangeSet 1.1643.36.2, 2004/03/19 13:10:22-08:00, [email protected]

add sysfs support for vc devices.

 drivers/char/vc_screen.c |   10 ++++++++++
 1 files changed, 10 insertions(+)
drivers/char/vc_screen.c +10 -0
diff -Nru a/drivers/char/vc_screen.c b/drivers/char/vc_screen.c
@@ -36,6 +36,7 @@
 #include <linux/kbd_kern.h>
 #include <linux/console.h>
 #include <linux/smp_lock.h>
+#include <linux/device.h>
 #include <asm/uaccess.h>
 #include <asm/byteorder.h>
 #include <asm/unaligned.h>
@@ -469,6 +470,8 @@
 	.open		= vcs_open,
 };
 
+static struct class_simple *vc_class;
+
 void vcs_make_devfs(struct tty_struct *tty)
 {
 	devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 1),
@@ -477,19 +480,26 @@
 	devfs_mk_cdev(MKDEV(VCS_MAJOR, tty->index + 129),
 			S_IFCHR|S_IRUSR|S_IWUSR,
 			"vcc/a%u", tty->index + 1);
+	class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, tty->index + 1), NULL, "vcs%u", tty->index + 1);
+	class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, tty->index + 129), NULL, "vcsa%u", tty->index + 1);
 }
 void vcs_remove_devfs(struct tty_struct *tty)
 {
 	devfs_remove("vcc/%u", tty->index + 1);
 	devfs_remove("vcc/a%u", tty->index + 1);
+	class_simple_device_remove(MKDEV(VCS_MAJOR, tty->index + 1));
+	class_simple_device_remove(MKDEV(VCS_MAJOR, tty->index + 129));
 }
 
 int __init vcs_init(void)
 {
 	if (register_chrdev(VCS_MAJOR, "vcs", &vcs_fops))
 		panic("unable to get major %d for vcs device", VCS_MAJOR);
+	vc_class = class_simple_create(THIS_MODULE, "vc");
 
 	devfs_mk_cdev(MKDEV(VCS_MAJOR, 0), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/0");
 	devfs_mk_cdev(MKDEV(VCS_MAJOR, 128), S_IFCHR|S_IRUSR|S_IWUSR, "vcc/a0");
+	class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, 0), NULL, "vcs");
+	class_simple_device_add(vc_class, MKDEV(VCS_MAJOR, 128), NULL, "vcsa");
 	return 0;
 }
author
#3 lore raw

ChangeSet 1.1643.36.3, 2004/03/19 13:12:46-08:00, [email protected]

VC: fix bug in vty_init() where vcs_init() was not called early enough.

It was being used before initialized, not nice :(

 drivers/char/vt.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletion(-)
drivers/char/vt.c +2 -1
diff -Nru a/drivers/char/vt.c b/drivers/char/vt.c
@@ -2602,6 +2602,8 @@
 
 int __init vty_init(void)
 {
+	vcs_init();
+
 	console_driver = alloc_tty_driver(MAX_NR_CONSOLES);
 	if (!console_driver)
 		panic("Couldn't allocate console driver\n");
@@ -2629,7 +2631,6 @@
 #ifdef CONFIG_FRAMEBUFFER_CONSOLE
 	fb_console_init();
 #endif	
-	vcs_init();
 	return 0;
 }
 
author
#4 lore raw

ChangeSet 1.1643.36.4, 2004/03/19 14:15:17-08:00, [email protected]

Driver class: remove possible oops

This happens when the device associated with a class device goes away before the class does.

 drivers/base/class.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)
drivers/base/class.c +2 -4
diff -Nru a/drivers/base/class.c b/drivers/base/class.c
@@ -155,8 +155,7 @@
 
 static void class_device_dev_unlink(struct class_device * class_dev)
 {
-	if (class_dev->dev)
-		sysfs_remove_link(&class_dev->kobj, "device");
+	sysfs_remove_link(&class_dev->kobj, "device");
 }
 
 static int class_device_driver_link(struct class_device * class_dev)
@@ -169,8 +168,7 @@
 
 static void class_device_driver_unlink(struct class_device * class_dev)
 {
-	if ((class_dev->dev) && (class_dev->dev->driver))
-		sysfs_remove_link(&class_dev->kobj, "driver");
+	sysfs_remove_link(&class_dev->kobj, "driver");
 }
 
 
author
#5 lore raw

ChangeSet 1.1643.36.5, 2004/03/19 16:39:16-08:00, [email protected]

[PATCH] QIC-02 tape drive hookup to classes in sysfs

Here is a patch to hook up the qic02 tape device to have class support in sysfs. I have verified it compiles. I do not have access to the hardware to test. Could someone who does please verify?

From the file:
* This is a driver for the Wangtek 5150 tape drive with
* a QIC-02 controller for ISA-PC type computers.
* Hopefully it will work with other QIC-02 tape drives as well.

 drivers/char/tpqic02.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+)
drivers/char/tpqic02.c +22 -0
diff -Nru a/drivers/char/tpqic02.c b/drivers/char/tpqic02.c
@@ -94,6 +94,7 @@
 #include <linux/init.h>
 #include <linux/smp_lock.h>
 #include <linux/devfs_fs_kernel.h>
+#include <linux/device.h>
 
 #include <asm/dma.h>
 #include <asm/system.h>
@@ -229,6 +230,8 @@
 	"600"			/* untested. */
 };
 
+static struct class_simple *tpqic02_class;
+
 
 /* `exception_list' is needed for exception status reporting.
  * Exceptions 1..14 are defined by QIC-02 rev F.
@@ -2696,23 +2699,32 @@
 		return -ENODEV;
 	}
 
+	tpqic02_class = class_simple_create(THIS_MODULE, TPQIC02_NAME);
+	class_simple_device_add(tpqic02_class, MKDEV(QIC02_TAPE_MAJOR, 2), NULL, "ntpqic11");
 	devfs_mk_cdev(MKDEV(QIC02_TAPE_MAJOR, 2),
 		       S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP, "ntpqic11");
+	class_simple_device_add(tpqic02_class, MKDEV(QIC02_TAPE_MAJOR, 3), NULL, "tpqic11");
 	devfs_mk_cdev(MKDEV(QIC02_TAPE_MAJOR, 3),
 		       S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP, "tpqic11");
 
+	class_simple_device_add(tpqic02_class, MKDEV(QIC02_TAPE_MAJOR, 4), NULL, "ntpqic24");
 	devfs_mk_cdev(MKDEV(QIC02_TAPE_MAJOR, 4),
 		       S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP, "ntpqic24");
+	class_simple_device_add(tpqic02_class, MKDEV(QIC02_TAPE_MAJOR, 5), NULL, "tpqic24");
 	devfs_mk_cdev(MKDEV(QIC02_TAPE_MAJOR, 5),
 		       S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP, "tpqic24");
 
+	class_simple_device_add(tpqic02_class, MKDEV(QIC02_TAPE_MAJOR, 6), NULL, "ntpqic20");
 	devfs_mk_cdev(MKDEV(QIC02_TAPE_MAJOR, 6),
 		       S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP, "ntpqic120");
+	class_simple_device_add(tpqic02_class, MKDEV(QIC02_TAPE_MAJOR, 7), NULL, "tpqic20");
 	devfs_mk_cdev(MKDEV(QIC02_TAPE_MAJOR, 7),
 		       S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP, "tpqic120");
 
+	class_simple_device_add(tpqic02_class, MKDEV(QIC02_TAPE_MAJOR, 8), NULL, "ntpqic50");
 	devfs_mk_cdev(MKDEV(QIC02_TAPE_MAJOR, 8),
 		       S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP, "ntpqic150");
+	class_simple_device_add(tpqic02_class, MKDEV(QIC02_TAPE_MAJOR, 9), NULL, "tpqic50");
 	devfs_mk_cdev(MKDEV(QIC02_TAPE_MAJOR, 9),
 		       S_IFCHR|S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP, "tpqic150");
 
@@ -2757,13 +2769,23 @@
 		qic02_release_resources();
 		
 	devfs_remove("ntpqic11");
+	class_simple_device_remove(MKDEV(QIC02_TAPE_MAJOR, 2));
 	devfs_remove("tpqic11");
+	class_simple_device_remove(MKDEV(QIC02_TAPE_MAJOR, 3));
 	devfs_remove("ntpqic24");
+	class_simple_device_remove(MKDEV(QIC02_TAPE_MAJOR, 4));
 	devfs_remove("tpqic24");
+	class_simple_device_remove(MKDEV(QIC02_TAPE_MAJOR, 5));
 	devfs_remove("ntpqic120");
+	class_simple_device_remove(MKDEV(QIC02_TAPE_MAJOR, 6));
 	devfs_remove("tpqic120");
+	class_simple_device_remove(MKDEV(QIC02_TAPE_MAJOR, 7));
 	devfs_remove("ntpqic150");
+	class_simple_device_remove(MKDEV(QIC02_TAPE_MAJOR, 8));
 	devfs_remove("tpqic150");
+	class_simple_device_remove(MKDEV(QIC02_TAPE_MAJOR, 9));
+
+	class_simple_destroy(tpqic02_class);
 }
 
 static int qic02_module_init(void)
author
#6 lore raw

ChangeSet 1.1643.36.6, 2004/03/19 16:39:37-08:00, [email protected]

[PATCH] add class support to floppy tape driver zftape-init.c

Here is a patch to add class support to zftape-init.c:

MODULE_DESCRIPTION(ZFTAPE_VERSION " - "
"VFS interface for the Linux floppy tape driver. " "Support for QIC-113 compatible volume table " "and builtin compression (lzrw3 algorithm)");

I have verified it compiles but do not have the hardware to test it.

 drivers/char/ftape/zftape/zftape-init.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+)
drivers/char/ftape/zftape/zftape-init.c +17 -0
diff -Nru a/drivers/char/ftape/zftape/zftape-init.c b/drivers/char/ftape/zftape/zftape-init.c
@@ -38,6 +38,7 @@
 
 #include <linux/zftape.h>
 #include <linux/init.h>
+#include <linux/device.h>
 
 #include "../zftape/zftape-init.h"
 #include "../zftape/zftape-read.h"
@@ -103,6 +104,8 @@
 	.release	= zft_close,
 };
 
+static struct class_simple *zft_class;
+
 /*      Open floppy tape device
  */
 static int zft_open(struct inode *ino, struct file *filep)
@@ -341,22 +344,29 @@
 	      "installing zftape VFS interface for ftape driver ...");
 	TRACE_CATCH(register_chrdev(QIC117_TAPE_MAJOR, "zft", &zft_cdev),);
 
+	zft_class = class_simple_create(THIS_MODULE, "zft");
 	for (i = 0; i < 4; i++) {
+		class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i), NULL, "qft%i", i);
 		devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i),
 				S_IFCHR | S_IRUSR | S_IWUSR,
 				"qft%i", i);
+		class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 4), NULL, "nqft%i", i);
 		devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 4),
 				S_IFCHR | S_IRUSR | S_IWUSR,
 				"nqft%i", i);
+		class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 16), NULL, "zqft%i", i);
 		devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 16),
 				S_IFCHR | S_IRUSR | S_IWUSR,
 				"zqft%i", i);
+		class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 20), NULL, "nzqft%i", i);
 		devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 20),
 				S_IFCHR | S_IRUSR | S_IWUSR,
 				"nzqft%i", i);
+		class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 32), NULL, "rawqft%i", i);
 		devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 32),
 				S_IFCHR | S_IRUSR | S_IWUSR,
 				"rawqft%i", i);
+		class_simple_device_add(zft_class, MKDEV(QIC117_TAPE_MAJOR, i + 36), NULL, "nrawrawqft%i", i);
 		devfs_mk_cdev(MKDEV(QIC117_TAPE_MAJOR, i + 36),
 				S_IFCHR | S_IRUSR | S_IWUSR,
 				"nrawqft%i", i);
@@ -386,12 +396,19 @@
 	}
         for (i = 0; i < 4; i++) {
 		devfs_remove("qft%i", i);
+		class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i));
 		devfs_remove("nqft%i", i);
+		class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 4));
 		devfs_remove("zqft%i", i);
+		class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 16));
 		devfs_remove("nzqft%i", i);
+		class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 20));
 		devfs_remove("rawqft%i", i);
+		class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 32));
 		devfs_remove("nrawqft%i", i);
+		class_simple_device_remove(MKDEV(QIC117_TAPE_MAJOR, i + 36));
 	}
+	class_simple_destroy(zft_class);
 	zft_uninit_mem(); /* release remaining memory, if any */
         printk(KERN_INFO "zftape successfully unloaded.\n");
 	TRACE_EXIT;
author
#7 lore raw

ChangeSet 1.1643.36.7, 2004/03/22 11:47:06-08:00, [email protected]

[PATCH] Sysfs for framebuffer

the following patch (against 2.6.5-rc2) teaches fb to use class_simple. With this patch udev will automagically create device nodes for each framebuffer registered. Once all drivers are converted to framebuffer_{alloc,release} we can switch to our own class.

This is what sysfs dir looks like:

notebook:~# tree /sys/class/graphics/
/sys/class/graphics/
`-- fb0
    `-- dev
 drivers/video/fbmem.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+)
drivers/video/fbmem.c +19 -0
diff -Nru a/drivers/video/fbmem.c b/drivers/video/fbmem.c
@@ -32,6 +32,9 @@
 #include <linux/kmod.h>
 #endif
 #include <linux/devfs_fs_kernel.h>
+#include <linux/err.h>
+#include <linux/kernel.h>
+#include <linux/device.h>
 
 #if defined(__mc68000__) || defined(CONFIG_APUS)
 #include <asm/setup.h>
@@ -1251,6 +1254,8 @@
 #endif
 };
 
+static struct class_simple *fb_class;
+
 /**
  *	register_framebuffer - registers a frame buffer device
  *	@fb_info: frame buffer info structure
@@ -1265,6 +1270,7 @@
 register_framebuffer(struct fb_info *fb_info)
 {
 	int i;
+	struct class_device *c;
 
 	if (num_registered_fb == FB_MAX)
 		return -ENXIO;
@@ -1273,6 +1279,12 @@
 		if (!registered_fb[i])
 			break;
 	fb_info->node = i;
+
+	c = class_simple_device_add(fb_class, MKDEV(FB_MAJOR, i), NULL, "fb%d", i);
+	if (IS_ERR(c)) {
+		/* Not fatal */
+		printk(KERN_WARNING "Unable to create class_device for framebuffer %d; errno = %ld\n", i, PTR_ERR(c));
+	}
 	
 	if (fb_info->pixmap.addr == NULL) {
 		fb_info->pixmap.addr = kmalloc(FBPIXMAPSIZE, GFP_KERNEL);
@@ -1338,6 +1350,7 @@
 		kfree(fb_info->sprite.addr);
 	registered_fb[i]=NULL;
 	num_registered_fb--;
+	class_simple_device_remove(MKDEV(FB_MAJOR, i));
 	return 0;
 }
 
@@ -1398,6 +1411,12 @@
 	devfs_mk_dir("fb");
 	if (register_chrdev(FB_MAJOR,"fb",&fb_fops))
 		printk("unable to get major %d for fb devs\n", FB_MAJOR);
+
+	fb_class = class_simple_create(THIS_MODULE, "graphics");
+	if (IS_ERR(fb_class)) {
+		printk(KERN_WARNING "Unable to create fb class; errno = %ld\n", PTR_ERR(fb_class));
+		fb_class = NULL;
+	}
 
 #ifdef CONFIG_FB_OF
 	if (ofonly) {
author
#8 lore raw

ChangeSet 1.1643.36.8, 2004/03/25 10:43:11-08:00, [email protected]

[PATCH] added class support to stallion.c

Here is a patch to add class support to the Stallion multiport serial driver.

 drivers/char/stallion.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletion(-)
drivers/char/stallion.c +9 -1
diff -Nru a/drivers/char/stallion.c b/drivers/char/stallion.c
@@ -41,6 +41,7 @@
 #include <linux/init.h>
 #include <linux/smp_lock.h>
 #include <linux/devfs_fs_kernel.h>
+#include <linux/device.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -732,6 +733,8 @@
 
 /*****************************************************************************/
 
+static struct class_simple *stallion_class;
+
 #ifdef MODULE
 
 /*
@@ -788,12 +791,15 @@
 		restore_flags(flags);
 		return;
 	}
-	for (i = 0; i < 4; i++)
+	for (i = 0; i < 4; i++) {
 		devfs_remove("staliomem/%d", i);
+		class_simple_device_remove(MKDEV(STL_SIOMEMMAJOR, i));
+	}
 	devfs_remove("staliomem");
 	if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
 		printk("STALLION: failed to un-register serial memory device, "
 			"errno=%d\n", -i);
+	class_simple_destroy(stallion_class);
 
 	if (stl_tmpwritebuf != (char *) NULL)
 		kfree(stl_tmpwritebuf);
@@ -3181,10 +3187,12 @@
 		printk("STALLION: failed to register serial board device\n");
 	devfs_mk_dir("staliomem");
 
+	stallion_class = class_simple_create(THIS_MODULE, "staliomem");
 	for (i = 0; i < 4; i++) {
 		devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i),
 				S_IFCHR|S_IRUSR|S_IWUSR,
 				"staliomem/%d", i);
+		class_simple_device_add(stallion_class, MKDEV(STL_SIOMEMMAJOR, i), NULL, "staliomem/%d", i);
 	}
 
 	stl_serial->owner = THIS_MODULE;
author
#9 lore raw

ChangeSet 1.1643.36.9, 2004/03/25 10:44:05-08:00, [email protected]

[PATCH] added class support to istallion.c

Here is a patch to add class support to the Stallion Intelligent multiport serial driver.

 drivers/char/istallion.c |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletion(-)
drivers/char/istallion.c +10 -1
diff -Nru a/drivers/char/istallion.c b/drivers/char/istallion.c
@@ -40,6 +40,7 @@
 #include <linux/delay.h>
 #include <linux/init.h>
 #include <linux/devfs_fs_kernel.h>
+#include <linux/device.h>
 
 #include <asm/io.h>
 #include <asm/uaccess.h>
@@ -795,6 +796,8 @@
 
 /*****************************************************************************/
 
+static struct class_simple *istallion_class;
+
 #ifdef MODULE
 
 /*
@@ -853,9 +856,12 @@
 		return;
 	}
 	put_tty_driver(stli_serial);
-	for (i = 0; i < 4; i++)
+	for (i = 0; i < 4; i++) {
 		devfs_remove("staliomem/%d", i);
+		class_simple_device_remove(MKDEV(STL_SIOMEMMAJOR, i));
+	}
 	devfs_remove("staliomem");
+	class_simple_destroy(istallion_class);
 	if ((i = unregister_chrdev(STL_SIOMEMMAJOR, "staliomem")))
 		printk("STALLION: failed to un-register serial memory device, "
 			"errno=%d\n", -i);
@@ -5311,10 +5317,13 @@
 				"device\n");
 
 	devfs_mk_dir("staliomem");
+	istallion_class = class_simple_create(THIS_MODULE, "staliomem");
 	for (i = 0; i < 4; i++) {
 		devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i),
 			       S_IFCHR | S_IRUSR | S_IWUSR,
 			       "staliomem/%d", i);
+		class_simple_device_add(istallion_class, MKDEV(STL_SIOMEMMAJOR, i), 
+				NULL, "staliomem/%d", i);
 	}
 
 /*
author
#10 lore raw

ChangeSet 1.1643.36.10, 2004/03/26 14:24:35-08:00, [email protected]

[PATCH] tipar char driver (divide by zero)

A patch about the tipar.c char driver has been sent on lkml by Sebastien Bourdeau. It fixes a divide-by-zero error when we try to read/write data after setting the timeout to 0.

 drivers/char/tipar.c |   16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)
drivers/char/tipar.c +11 -5
diff -Nru a/drivers/char/tipar.c b/drivers/char/tipar.c
@@ -67,7 +67,7 @@
 /*
  * Version Information
  */
-#define DRIVER_VERSION "1.17"
+#define DRIVER_VERSION "1.19"
 #define DRIVER_AUTHOR  "Romain Lievin <[email protected]>"
 #define DRIVER_DESC    "Device driver for TI/PC parallel link cables"
 #define DRIVER_LICENSE "GPL"
@@ -361,10 +361,13 @@
 
 	switch (cmd) {
 	case IOCTL_TIPAR_DELAY:
-	  delay = (int)arg;    //get_user(delay, &arg);
-	  break;
+		delay = (int)arg;    //get_user(delay, &arg);
+		break;
 	case IOCTL_TIPAR_TIMEOUT:
-	  timeout = (int)arg;  //get_user(timeout, &arg);
+		if (arg != 0)
+                        timeout = (int)arg;
+                else
+                        retval = -EINVAL;
 	  break;
 	default:
 		retval = -ENOTTY;
@@ -399,7 +402,10 @@
 	str = get_options(str, ARRAY_SIZE(ints), ints);
 
 	if (ints[0] > 0) {
-		timeout = ints[1];
+		if (ints[1] != 0)
+                        timeout = ints[1];
+                else
+                        printk("tipar: wrong timeout value (0), using default value instead.");
 		if (ints[0] > 1) {
 			delay = ints[2];
 		}
author
#11 lore raw

ChangeSet 1.1643.36.11, 2004/03/31 15:20:20-08:00, [email protected]

[PATCH] kobject_set_name() doesn't allocate enough space

 lib/kobject.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
lib/kobject.c +3 -3
diff -Nru a/lib/kobject.c b/lib/kobject.c
@@ -349,16 +349,16 @@
 		/* 
 		 * Need more space? Allocate it and try again 
 		 */
-		name = kmalloc(need,GFP_KERNEL);
+		limit = need + 1;
+		name = kmalloc(limit,GFP_KERNEL);
 		if (!name) {
 			error = -ENOMEM;
 			goto Done;
 		}
-		limit = need;
 		need = vsnprintf(name,limit,fmt,args);
 
 		/* Still? Give up. */
-		if (need > limit) {
+		if (need >= limit) {
 			kfree(name);
 			error = -EFAULT;
 			goto Done;
author
#12 lore raw

ChangeSet 1.1643.36.12, 2004/04/08 14:45:41-07:00, [email protected]

[PATCH] add class support to dsp56k.c

Here is a patch that adds sysfs class support to /drivers/char/dsp56k.c

 drivers/char/dsp56k.c |   27 +++++++++++++++++++++++++--
 1 files changed, 25 insertions(+), 2 deletions(-)
drivers/char/dsp56k.c +25 -2
diff -Nru a/drivers/char/dsp56k.c b/drivers/char/dsp56k.c
@@ -35,6 +35,7 @@
 #include <linux/init.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/smp_lock.h>
+#include <linux/device.h>
 
 #include <asm/atarihw.h>
 #include <asm/traps.h>
@@ -149,6 +150,8 @@
 	int tx_wsize, rx_wsize;
 } dsp56k;
 
+static struct class_simple *dsp56k_class;
+
 static int dsp56k_reset(void)
 {
 	u_char status;
@@ -502,6 +505,8 @@
 
 static int __init dsp56k_init_driver(void)
 {
+	int err = 0;
+
 	if(!MACH_IS_ATARI || !ATARIHW_PRESENT(DSP56K)) {
 		printk("DSP56k driver: Hardware not present\n");
 		return -ENODEV;
@@ -511,17 +516,35 @@
 		printk("DSP56k driver: Unable to register driver\n");
 		return -ENODEV;
 	}
+	dsp56k_class = class_simple_create(THIS_MODULE, "dsp56k");
+	if (IS_ERR(dsp56k_class)) {
+		err = PTR_ERR(dsp56k_class);
+		goto out_chrdev;
+	}
+	class_simple_device_add(dsp56k_class, MKDEV(DSP56K_MAJOR, 0), NULL, "dsp56k");
 
-	devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0),
+	err = devfs_mk_cdev(MKDEV(DSP56K_MAJOR, 0),
 		      S_IFCHR | S_IRUSR | S_IWUSR, "dsp56k");
+	if(err)
+		goto out_class;
 
 	printk(banner);
-	return 0;
+	goto out;
+
+out_class:
+	class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0));
+	class_simple_destroy(dsp56k_class);
+out_chrdev:
+	unregister_chrdev(DSP56K_MAJOR, "dsp56k");
+out:
+	return err;
 }
 module_init(dsp56k_init_driver);
 
 static void __exit dsp56k_cleanup_driver(void)
 {
+	class_simple_device_remove(MKDEV(DSP56K_MAJOR, 0));
+	class_simple_destroy(dsp56k_class);
 	unregister_chrdev(DSP56K_MAJOR, "dsp56k");
 	devfs_remove("dsp56k");
 }
author
#13 lore raw

ChangeSet 1.1643.36.13, 2004/04/08 14:53:05-07:00, [email protected]

[PATCH] Add sysfs class support to fs/coda/psdev.c

Here is a patch to add class support to psdev.c.

I have verified it compiles and works.

 fs/coda/psdev.c |   36 +++++++++++++++++++++++++++++++-----
 1 files changed, 31 insertions(+), 5 deletions(-)
fs/coda/psdev.c +31 -5
diff -Nru a/fs/coda/psdev.c b/fs/coda/psdev.c
@@ -37,6 +37,7 @@
 #include <linux/init.h>
 #include <linux/list.h>
 #include <linux/smp_lock.h>
+#include <linux/device.h>
 #include <asm/io.h>
 #include <asm/system.h>
 #include <asm/poll.h>
@@ -61,6 +62,7 @@
 
 
 struct venus_comm coda_comms[MAX_CODADEVS];
+static struct class_simple coda_psdev_class;
 
 /*
  * Device operations
@@ -358,20 +360,38 @@
 
 static int init_coda_psdev(void)
 {
-	int i;
+	int i, err = 0;
 	if (register_chrdev(CODA_PSDEV_MAJOR,"coda_psdev",
 				 &coda_psdev_fops)) {
               printk(KERN_ERR "coda_psdev: unable to get major %d\n", 
 		     CODA_PSDEV_MAJOR);
               return -EIO;
 	}
+	coda_psdev_class = class_simple_create(THIS_MODULE, "coda_psdev");
+	if (IS_ERR(coda_psdev_class)) {
+		err = PTR_ERR(coda_psdev_class);
+		goto out_chrdev;
+	}		
 	devfs_mk_dir ("coda");
 	for (i = 0; i < MAX_CODADEVS; i++) {
-		devfs_mk_cdev(MKDEV(CODA_PSDEV_MAJOR, i),
+		class_simple_device_add(coda_psdev_class, MKDEV(CODA_PSDEV_MAJOR,i), 
+				NULL, "cfs%d", i);
+		err = devfs_mk_cdev(MKDEV(CODA_PSDEV_MAJOR, i),
 				S_IFCHR|S_IRUSR|S_IWUSR, "coda/%d", i);
+		if (err)
+			goto out_class;
 	}
 	coda_sysctl_init();
-	return 0;
+	goto out;
+
+out_class:
+	for (i = 0; i < MAX_CODADEVS; i++) 
+		class_simple_device_remove(MKDEV(CODA_PSDEV_MAJOR, i));
+	class_simple_destroy(coda_psdev_class);
+out_chrdev:
+	unregister_chrdev(CODA_PSDEV_MAJOR, "coda_psdev");
+out:
+	return err;
 }
 
 
@@ -408,8 +428,11 @@
 	}
 	return 0;
 out:
-	for (i = 0; i < MAX_CODADEVS; i++)
+	for (i = 0; i < MAX_CODADEVS; i++) {
+		class_simple_device_remove(MKDEV(CODA_PSDEV_MAJOR, i));
 		devfs_remove("coda/%d", i);
+	}
+	class_simple_destroy(coda_psdev_class);
 	devfs_remove("coda");
 	unregister_chrdev(CODA_PSDEV_MAJOR,"coda_psdev");
 	coda_sysctl_clean();
@@ -427,8 +450,11 @@
         if ( err != 0 ) {
                 printk("coda: failed to unregister filesystem\n");
         }
-	for (i = 0; i < MAX_CODADEVS; i++)
+	for (i = 0; i < MAX_CODADEVS; i++) {
+		class_simple_device_remove(MKDEV(CODA_PSDEV_MAJOR, i));
 		devfs_remove("coda/%d", i);
+	}
+	class_simple_destroy(coda_psdev_class);
 	devfs_remove("coda");
 	unregister_chrdev(CODA_PSDEV_MAJOR, "coda_psdev");
 	coda_sysctl_clean();
author
#14 lore raw

ChangeSet 1.1643.36.14, 2004/04/09 11:32:55-07:00, [email protected]

[PATCH] Add sysfs class support for CAPI

here is a patch that adds class support to the ISDN CAPI module. Without it udev won't create the /dev/capi20 device node.

 drivers/isdn/capi/capi.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+)
drivers/isdn/capi/capi.c +14 -0
diff -Nru a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
@@ -37,6 +37,7 @@
 #include <linux/capi.h>
 #include <linux/kernelcapi.h>
 #include <linux/init.h>
+#include <linux/device.h>
 #include <linux/devfs_fs_kernel.h>
 #include <linux/isdn/capiutil.h>
 #include <linux/isdn/capicmd.h>
@@ -56,6 +57,8 @@
 
 /* -------- driver information -------------------------------------- */
 
+static struct class_simple *capi_class;
+
 int capi_major = 68;		/* allocated */
 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
 #define CAPINC_NR_PORTS	32
@@ -1479,11 +1482,20 @@
 		return -EIO;
 	}
 
+	capi_class = class_simple_create(THIS_MODULE, "capi");
+	if (IS_ERR(capi_class)) {
+		unregister_chrdev(capi_major, "capi20");
+		return PTR_ERR(capi_class);
+	}
+
+	class_simple_device_add(capi_class, MKDEV(capi_major, 0), NULL, "capi20");
 	devfs_mk_cdev(MKDEV(capi_major, 0), S_IFCHR | S_IRUSR | S_IWUSR,
 			"isdn/capi20");
 
 #ifdef CONFIG_ISDN_CAPI_MIDDLEWARE
 	if (capinc_tty_init() < 0) {
+		class_simple_device_remove(MKDEV(capi_major, 0));
+		class_simple_destroy(capi_class);
 		unregister_chrdev(capi_major, "capi20");
 		return -ENOMEM;
 	}
@@ -1510,6 +1522,8 @@
 {
 	proc_exit();
 
+	class_simple_device_remove(MKDEV(capi_major, 0));
+	class_simple_destroy(capi_class);
 	unregister_chrdev(capi_major, "capi20");
 	devfs_remove("isdn/capi20");
 
author
#15 lore raw

ChangeSet 1.1643.36.15, 2004/04/09 11:50:34-07:00, [email protected]

[PATCH] fix sysfs class support to fs/coda/psdev.c

Quoted 7 lines · --On Friday, April 09, 2004 12:02:19 AM +0200 Marcel Holtmann…
Quoted 1 line

+static struct class_simple coda_psdev_class;

I think coda_psdev_class must be a pointer.

Regards

Marcel

Doh! I tested on one system and fixed this there. Then accidentally mailed out the original. Sorry about that. Here is a patch to fix it:

 fs/coda/psdev.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
fs/coda/psdev.c +1 -1
diff -Nru a/fs/coda/psdev.c b/fs/coda/psdev.c
@@ -62,7 +62,7 @@
 
 
 struct venus_comm coda_comms[MAX_CODADEVS];
-static struct class_simple coda_psdev_class;
+static struct class_simple *coda_psdev_class;
 
 /*
  * Device operations
author
#16 lore raw

ChangeSet 1.1643.36.16, 2004/04/09 11:50:55-07:00, [email protected]

[PATCH] Fix for patch to add class support to stallion.c

Oops. Realized I had a / in the file name in this patch too.

Please apply to correct it:

 drivers/char/stallion.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/char/stallion.c +1 -1
diff -Nru a/drivers/char/stallion.c b/drivers/char/stallion.c
@@ -3192,7 +3192,7 @@
 		devfs_mk_cdev(MKDEV(STL_SIOMEMMAJOR, i),
 				S_IFCHR|S_IRUSR|S_IWUSR,
 				"staliomem/%d", i);
-		class_simple_device_add(stallion_class, MKDEV(STL_SIOMEMMAJOR, i), NULL, "staliomem/%d", i);
+		class_simple_device_add(stallion_class, MKDEV(STL_SIOMEMMAJOR, i), NULL, "staliomem%d", i);
 	}
 
 	stl_serial->owner = THIS_MODULE;
author
#17 lore raw

ChangeSet 1.1643.36.17, 2004/04/09 11:51:13-07:00, [email protected]

[PATCH] Fix class support to istallion.c

Realized I put a / in the filename of this device too.

Here is the fix:

 drivers/char/istallion.c |    2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)
drivers/char/istallion.c +1 -1
diff -Nru a/drivers/char/istallion.c b/drivers/char/istallion.c
@@ -5323,7 +5323,7 @@
 			       S_IFCHR | S_IRUSR | S_IWUSR,
 			       "staliomem/%d", i);
 		class_simple_device_add(istallion_class, MKDEV(STL_SIOMEMMAJOR, i), 
-				NULL, "staliomem/%d", i);
+				NULL, "staliomem%d", i);
 	}
 
 /*
author
#18 lore raw

ChangeSet 1.1643.36.18, 2004/04/12 16:46:07-07:00, [email protected]

[PATCH] Fix sysfs class support for CAPI

this patch fixes a bug in the CAPI TTY support, because the ->name value of the TTY driver shouldn't contain a "/". After changing this there are now a "capi20" TTY device and a "capi20" control device and so I renamed the control device to "capi". The userspace visible part must be done by udev and I added these two rules to restore the old namespace:

	# CAPI devices
	KERNEL="capi",          NAME="capi20", SYMLINK="isdn/capi20"
	KERNEL="capi*",         NAME="capi/%n"
 drivers/isdn/capi/capi.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
drivers/isdn/capi/capi.c +3 -2
diff -Nru a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
@@ -1312,7 +1312,8 @@
 
 	drv->owner = THIS_MODULE;
 	drv->driver_name = "capi_nc";
-	drv->name = "capi/";
+	drv->devfs_name = "capi/";
+	drv->name = "capi";
 	drv->major = capi_ttymajor;
 	drv->minor_start = 0;
 	drv->type = TTY_DRIVER_TYPE_SERIAL;
@@ -1488,7 +1489,7 @@
 		return PTR_ERR(capi_class);
 	}
 
-	class_simple_device_add(capi_class, MKDEV(capi_major, 0), NULL, "capi20");
+	class_simple_device_add(capi_class, MKDEV(capi_major, 0), NULL, "capi");
 	devfs_mk_cdev(MKDEV(capi_major, 0), S_IFCHR | S_IRUSR | S_IWUSR,
 			"isdn/capi20");