Skip to contentSkip to conversation

Add sysfs class support for CAPI

PATCH In review Marcel Holtmann 2 participants 6 messages Apr 9, 2004 – Apr 12, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add sysfs class support for CAPI

Hi Greg,

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

Regards

Marcel

===== drivers/isdn/capi/capi.c 1.51 vs edited =====

drivers/isdn/capi/capi.c +14 -0
@@ -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
@@ -1483,11 +1486,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;
 	}
@@ -1514,6 +1526,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");
 
#1 lore raw
Quoted 4 lines · Marcel Holtmann

Hi Greg,

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

Looks good, but isn't there also a /dev/capi20.00 and so on device nodes needed by this driver? According to devices.txt those are valid nodes...

thanks,

greg k-h

#2 lore raw

Hi Greg,

Quoted 6 lines
Quoted 2 lines

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

Looks good, but isn't there also a /dev/capi20.00 and so on device nodes needed by this driver? According to devices.txt those are valid nodes...

according to devices.txt - yes. But I didn't found any references in the source code nor any application using it. The /dev/capi20 device is a multiplexing interface and the others must be somekind of relict. Maybe Karsten knows the full story ;)

Regards

Marcel

#3 lore raw
In reply to Marcel Holtmann
Quoted 4 lines · Marcel Holtmann

Hi Greg,

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

Looks good, applied, thanks.

greg k-h

#4 lore raw

Hi Greg,

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"

Regards

Marcel

===== drivers/isdn/capi/capi.c 1.52 vs edited =====

drivers/isdn/capi/capi.c +3 -2
@@ -1316,7 +1316,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;
@@ -1492,7 +1493,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");
 
#5 lore raw
Quoted 11 lines · Marcel Holtmann

Hi Greg,

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"

Looks good. I've applied your patch, and modified the udev main rules file to add these rules.

thanks again,

greg k-h