[Asterisk-cvs] zaptel README.udev,NONE,1.1 Makefile,1.48,1.49 zaptel.c,1.84,1.85 zconfig.h,1.10,1.11

markster at lists.digium.com markster at lists.digium.com
Fri Jul 16 18:23:04 CDT 2004


Update of /usr/cvsroot/zaptel
In directory localhost.localdomain:/tmp/cvs-serv13403

Modified Files:
	Makefile zaptel.c zconfig.h 
Added Files:
	README.udev 
Log Message:
Add udev support (courtesy matt / creslin)


--- NEW FILE: README.udev ---
UDEV -- What the heck is udev OR why did I get a message to read this?

This is the new mechanism of doing a dyamic /dev.  What does
that mean?  Basically, before the days of linux-2.3/linux-2.4 your /dev
had to have ~18000 files in it for all the possible device that your
kernel could possibly have, most of which you will NEVER use.  This, for
obvious reasons, is somewhat undesirable.  So then came devfs.  Devfs
solved a lot of these problems by dynamically populating /dev with only
the device nodes of the devices that existed on your system.  Now, in
linux-2.6, udev+sysfs has become the mechanism of choice for populating
your dynamic /dev with device nodes.

You got this message because you are probably running udev on your system.

If your are not, or you feel that you have reached this message error you
can send me an email (look to bottom of file for address).

If you're running udev on your system, you were probably directed
to read this file during compile.  For udevd (the daemon responsible
for creation/deletion of device nodes), you will need to add the following
lines to your udev rules.

# Section for zaptel device
KERNEL="zapctl",     NAME="zap/ctl"
KERNEL="zaptimer",   NAME="zap/timer"
KERNEL="zapchannel", NAME="zap/channel"
KERNEL="zappseudo",  NAME="zap/pseudo"
KERNEL="zap[0-9]*",  NAME="zap/%n"

This will take care of making all the automagic occur that needs to be
done so that udevd will make the right files for zaptel.

Matthew Fredrickson
creslin at NOSPAMdigium.com

Index: Makefile
===================================================================
RCS file: /usr/cvsroot/zaptel/Makefile,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- Makefile	30 Jun 2004 16:09:43 -0000	1.48
+++ Makefile	16 Jul 2004 22:09:07 -0000	1.49
@@ -38,9 +38,14 @@
 
 ifeq (${BUILDVER},linux24)
 #We only support DEVFS in linux 2.4 kernels, since its considered obsolete post 2.4
-DEVFS=$(shell ps ax | grep -v grep | grep devfsd)
+DYNFS=$(shell ps ax | grep -v grep | grep devfsd)
+endif
+ifeq (${BUILDVER},linux26)
+#Tests for newer linux-2.6 udev support
+DYNFS=$(shell ps ax | grep -v grep | grep udevd)
 endif
 
+
 TZOBJS=zonedata.lo tonezone.lo
 LIBTONEZONE=libtonezone.so.1.0
 MODULES=zaptel tor2 torisa wcusb wcfxo wcfxs \
@@ -213,7 +218,7 @@
 	$(CC) -o fxsdump fxsdump.o -lm
 
 devices:
-ifeq ($(DEVFS),)
+ifeq ($(DYNFS),)
 	mkdir -p $(INSTALL_PREFIX)/dev/zap
 	rm -f $(INSTALL_PREFIX)/dev/zap/ctl
 	rm -f $(INSTALL_PREFIX)/dev/zap/channel
@@ -234,7 +239,8 @@
 		N=$$[$$N+1]; \
 	done
 else
-	@echo "**** devfs detected -- not making device nodes"
+	@echo "**** Dynamic filesystem detected -- not creating device nodes"
+	@echo "**** If you are running udev, read README.udev"
 endif
 
 install:  all devices $(LIBTONEZONE)

Index: zaptel.c
===================================================================
RCS file: /usr/cvsroot/zaptel/zaptel.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -u -d -r1.84 -r1.85
--- zaptel.c	2 Jul 2004 13:04:54 -0000	1.84
+++ zaptel.c	16 Jul 2004 22:09:07 -0000	1.85
@@ -143,6 +143,12 @@
 static devfs_handle_t ctl;
 static devfs_handle_t timer;
 #endif
+
+/* udev necessary data structures.  Yeah! */
+#ifdef CONFIG_ZAP_UDEV
+static struct class_simple *zap_class = NULL;
+#endif
+
 /* There is a table like this in the PPP driver, too */
 
 static int deftaps = 64;
@@ -4165,6 +4171,14 @@
 	}
 #endif /* CONFIG_DEVFS_FS */
 
+#ifdef CONFIG_ZAP_UDEV
+	for (x = 0; x < span->channels; x++) {
+		char chan_name[50];
+		sprintf(chan_name, "zap%d", span->chans[x].channo);
+		class_simple_device_add(zap_class, MKDEV(ZT_MAJOR, span->chans[x].channo), NULL, chan_name);
+	}
+#endif /* CONFIG_ZAP_UDEV */
+
 	if (debug)
 		printk("Registered Span %d ('%s') with %d channels\n", span->spanno, span->name, span->channels);
 	if (!master || prefmaster) {
@@ -4208,6 +4222,13 @@
 	}
 	devfs_unregister(span->dhandle);
 #endif /* CONFIG_DEVFS_FS */
+
+#ifdef CONFIG_ZAP_UDEV
+	for (x = 0; x < span->channels; x++) {
+		class_simple_device_remove(MKDEV(ZT_MAJOR, span->chans[x].channo));
+	}
+#endif /* CONFIG_ZAP_UDEV */
+
 	spans[span->spanno] = NULL;
 	span->spanno = 0;
 	span->flags &= ~ZT_FLAG_REGISTERED;
@@ -6078,6 +6099,15 @@
 #ifdef CONFIG_PROC_FS
 	proc_entries[0] = proc_mkdir("zaptel", NULL);
 #endif
+
+#ifdef CONFIG_ZAP_UDEV /* udev support functions */
+	zap_class = class_simple_create(THIS_MODULE, "zaptel");
+	class_simple_device_add(zap_class, MKDEV(ZT_MAJOR, 253), NULL, "zaptimer");
+	class_simple_device_add(zap_class, MKDEV(ZT_MAJOR, 254), NULL, "zapchannel");
+	class_simple_device_add(zap_class, MKDEV(ZT_MAJOR, 255), NULL, "zappseudo");
+	class_simple_device_add(zap_class, MKDEV(ZT_MAJOR, 0), NULL, "zapctl");
+#endif /* CONFIG_ZAP_UDEV */
+
 #ifdef CONFIG_DEVFS_FS
 	{
 	umode_t mode = S_IFCHR|S_IRUGO|S_IWUGO;
@@ -6127,6 +6157,13 @@
 	devfs_unregister(zaptel_devfs_dir);
 	devfs_unregister_chrdev(ZT_MAJOR, "zaptel");
 #else
+#ifdef CONFIG_ZAP_UDEV
+	class_simple_device_remove(MKDEV(ZT_MAJOR, 253)); /* timer */
+	class_simple_device_remove(MKDEV(ZT_MAJOR, 254)); /* channel */
+	class_simple_device_remove(MKDEV(ZT_MAJOR, 255)); /* pseudo */
+	class_simple_device_remove(MKDEV(ZT_MAJOR, 0)); /* ctl */
+	class_simple_destroy(zap_class);
+#endif /* CONFIG_ZAP_UDEV */
 	unregister_chrdev(ZT_MAJOR, "zaptel");
 #endif
 #ifdef CONFIG_ZAPTEL_WATCHDOG

Index: zconfig.h
===================================================================
RCS file: /usr/cvsroot/zaptel/zconfig.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- zconfig.h	2 Jul 2004 13:04:54 -0000	1.10
+++ zconfig.h	16 Jul 2004 22:09:07 -0000	1.11
@@ -62,6 +62,11 @@
  */
 /* #define NO_ECHOCAN_DISABLE */
 
+/* udev support */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#define CONFIG_ZAP_UDEV
+#endif
+
 /* We now use the linux kernel config to detect which options to use */
 /* You can still override them below */
 #if defined(CONFIG_HDLC) || defined(CONFIG_HDLC_MODULE)




More information about the svn-commits mailing list