[svn-commits] tzafrir: branch linux/tzafrir/sysfs r8384 - in /linux/team/tzafrir/sysfs: dri...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Mar 22 09:08:44 CDT 2010


Author: tzafrir
Date: Mon Mar 22 09:08:39 2010
New Revision: 8384

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8384
Log:
better testing of major/minor numbers of special devices

* Make sure that the special devices are also of major number
  DAHDI_MAJOR (196).
* Provide symbolic names for the special minor numbers.
* An extra printk macro, while we're at it.

Modified:
    linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c
    linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c
    linux/team/tzafrir/sysfs/drivers/dahdi/dahdi_transcode.c
    linux/team/tzafrir/sysfs/include/dahdi/kernel.h

Modified: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c?view=diff&rev=8384&r1=8383&r2=8384
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-base.c Mon Mar 22 09:08:39 2010
@@ -100,6 +100,8 @@
 
 /* macro-oni for determining a unit (channel) number */
 #define	UNIT(file) MINOR(file->f_dentry->d_inode->i_rdev)
+#define	IS_UNIT(file, unit) \
+	((file)->f_dentry->d_inode->i_rdev == MKDEV(DAHDI_MAJOR, (unit)))
 
 /* names of tx level settings */
 static char *dahdi_txlevelnames[] = {
@@ -2804,9 +2806,9 @@
 	int unit = UNIT(file);
 	struct dahdi_chan *chan;
 	/* Minor 0: Special "control" descriptor */
-	if (!unit)
+	if (IS_UNIT(file, DAHDI_CTL))
 		return dahdi_ctl_open(file);
-	if (unit == 250) {
+	if (IS_UNIT(file, DAHDI_TRANSCODE)) {
 		if (!dahdi_transcode_fops) {
 			if (request_module("dahdi_transcode")) {
 				return -ENXIO;
@@ -2828,16 +2830,16 @@
 		}
 		return -ENXIO;
 	}
-	if (unit == 253) {
+	if (IS_UNIT(file, DAHDI_TIMER)) {
 		if (can_open_timer()) {
 			return dahdi_timing_open(file);
 		} else {
 			return -ENXIO;
 		}
 	}
-	if (unit == 254)
+	if (IS_UNIT(file, DAHDI_CHANNEL))
 		return dahdi_chan_open(file);
-	if (unit == 255) {
+	if (IS_UNIT(file, DAHDI_PSEUDO)) {
 		chan = dahdi_alloc_pseudo();
 		if (chan) {
 			file->private_data = chan;
@@ -2867,21 +2869,20 @@
 	struct dahdi_chan *chan;
 
 	/* Can't read from control */
-	if (!unit) {
+	if (IS_UNIT(file, DAHDI_CTL))
 		return -EINVAL;
-	}
-
-	if (unit == 253)
+
+	if (IS_UNIT(file, DAHDI_TIMER))
 		return -EINVAL;
 
-	if (unit == 254) {
+	if (IS_UNIT(file, DAHDI_CHANNEL)) {
 		chan = file->private_data;
 		if (!chan)
 			return -EINVAL;
 		return dahdi_chan_read(file, usrbuf, count, chan->channo);
 	}
 
-	if (unit == 255) {
+	if (IS_UNIT(file, DAHDI_PSEUDO)) {
 		chan = file->private_data;
 		if (!chan) {
 			module_printk(KERN_NOTICE, "No pseudo channel structure to read?\n");
@@ -2900,19 +2901,19 @@
 	int unit = UNIT(file);
 	struct dahdi_chan *chan;
 	/* Can't read from control */
-	if (!unit)
+	if (IS_UNIT(file, DAHDI_CTL))
 		return -EINVAL;
 	if (count < 0)
 		return -EINVAL;
-	if (unit == 253)
+	if (IS_UNIT(file, DAHDI_TIMER))
 		return -EINVAL;
-	if (unit == 254) {
+	if (IS_UNIT(file, DAHDI_CHANNEL)) {
 		chan = file->private_data;
 		if (!chan)
 			return -EINVAL;
 		return dahdi_chan_write(file, usrbuf, count, chan->channo);
 	}
-	if (unit == 255) {
+	if (IS_UNIT(file, DAHDI_PSEUDO)) {
 		chan = file->private_data;
 		if (!chan) {
 			module_printk(KERN_NOTICE, "No pseudo channel structure to read?\n");
@@ -3376,26 +3377,25 @@
 	int res;
 	struct dahdi_chan *chan;
 
-	if (!unit)
+	if (IS_UNIT(file, DAHDI_CTL))
 		return dahdi_ctl_release(file);
-	if (unit == 253) {
+	if (IS_UNIT(file, DAHDI_TIMER))
 		return dahdi_timer_release(file);
-	}
-	if (unit == 250) {
+	if (IS_UNIT(file, DAHDI_TRANSCODE)) {
 		/* We should not be here because the dahdi_transcode.ko module
 		 * should have updated the file_operations for this file
 		 * handle when the file was opened. */
 		WARN_ON(1);
 		return -EFAULT;
 	}
-	if (unit == 254) {
+	if (IS_UNIT(file, DAHDI_CHANNEL)) {
 		chan = file->private_data;
 		if (!chan)
 			return dahdi_chan_release(file);
 		else
 			return dahdi_specchan_release(file, chan->channo);
 	}
-	if (unit == 255) {
+	if (IS_UNIT(file, DAHDI_PSEUDO)) {
 		chan = file->private_data;
 		if (chan) {
 			res = dahdi_specchan_release(file, chan->channo);
@@ -5780,12 +5780,12 @@
 	lock_kernel();
 #endif
 
-	if (!unit) {
+	if (IS_UNIT(file, DAHDI_CTL)) {
 		ret = dahdi_ctl_ioctl(file, cmd, data);
 		goto unlock_exit;
 	}
 
-	if (unit == 250) {
+	if (IS_UNIT(file, DAHDI_TRANSCODE)) {
 		/* dahdi_transcode should have updated the file_operations on
 		 * this file object on open, so we shouldn't be here. */
 		WARN_ON(1);
@@ -5793,7 +5793,7 @@
 		goto unlock_exit;
 	}
 
-	if (unit == 253) {
+	if (IS_UNIT(file, DAHDI_TIMER)) {
 		timer = file->private_data;
 		if (timer)
 			ret = dahdi_timer_ioctl(file, cmd, data, timer);
@@ -5801,7 +5801,7 @@
 			ret = -EINVAL;
 		goto unlock_exit;
 	}
-	if (unit == 254) {
+	if (IS_UNIT(file, DAHDI_CHANNEL)) {
 		chan = file->private_data;
 		if (chan)
 			ret = dahdi_chan_ioctl(file, cmd, data, chan->channo);
@@ -5809,7 +5809,7 @@
 			ret = dahdi_prechan_ioctl(file, cmd, data, unit);
 		goto unlock_exit;
 	}
-	if (unit == 255) {
+	if (IS_UNIT(file, DAHDI_PSEUDO)) {
 		chan = file->private_data;
 		if (!chan) {
 			module_printk(KERN_NOTICE, "No pseudo channel structure to read?\n");
@@ -7974,8 +7974,7 @@
 
 static int dahdi_mmap(struct file *file, struct vm_area_struct *vm)
 {
-	int unit = UNIT(file);
-	if (unit == 250)
+	if (IS_UNIT(file, DAHDI_TRANSCODE))
 		return dahdi_transcode_fops->mmap(file, vm);
 	return -ENOSYS;
 }
@@ -7985,22 +7984,22 @@
 	int unit = UNIT(file);
 	struct dahdi_chan *chan;
 
-	if (!unit)
+	if (IS_UNIT(file, DAHDI_CTL))
 		return -EINVAL;
 
-	if (unit == 250)
+	if (IS_UNIT(file, DAHDI_TRANSCODE))
 		return dahdi_transcode_fops->poll(file, wait_table);
 
-	if (unit == 253)
+	if (IS_UNIT(file, DAHDI_TIMER))
 		return dahdi_timer_poll(file, wait_table);
 
-	if (unit == 254) {
+	if (IS_UNIT(file, DAHDI_CHANNEL)) {
 		chan = file->private_data;
 		if (!chan)
 			return -EINVAL;
 		return dahdi_chan_poll(file, wait_table,chan->channo);
 	}
-	if (unit == 255) {
+	if (IS_UNIT(file, DAHDI_PSEUDO)) {
 		chan = file->private_data;
 		if (!chan) {
 			module_printk(KERN_NOTICE, "No pseudo channel structure to read?\n");

Modified: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c?view=diff&rev=8384&r1=8383&r2=8384
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/dahdi-sysfs-chan.c Mon Mar 22 09:08:39 2010
@@ -236,10 +236,14 @@
 	}
 	/* NULL parent, NULL drvdata */
 	/* FIXME: error handling */
-	create_dev_file(chan_class, MKDEV(DAHDI_MAJOR, 253), "dahdi!timer");
-	create_dev_file(chan_class, MKDEV(DAHDI_MAJOR, 254), "dahdi!channel");
-	create_dev_file(chan_class, MKDEV(DAHDI_MAJOR, 255), "dahdi!pseudo");
-	create_dev_file(chan_class, MKDEV(DAHDI_MAJOR, 0),   "dahdi!ctl");
+	create_dev_file(chan_class, MKDEV(DAHDI_MAJOR, DAHDI_TIMER),
+			"dahdi!timer");
+	create_dev_file(chan_class, MKDEV(DAHDI_MAJOR, DAHDI_CHANNEL),
+			"dahdi!channel");
+	create_dev_file(chan_class, MKDEV(DAHDI_MAJOR, DAHDI_PSEUDO),
+			"dahdi!pseudo");
+	create_dev_file(chan_class, MKDEV(DAHDI_MAJOR, DAHDI_CTL),
+			"dahdi!ctl");
 	chan_class->dev_attrs = chan_dev_attrs;
 	return 0;
 }
@@ -248,10 +252,10 @@
 void dahdi_driver_chan_exit(void)
 {
 	dahdi_dbg(DEVICES, "SYSFS\n");
-	destroy_dev_file(chan_class, MKDEV(DAHDI_MAJOR, 0));
-	destroy_dev_file(chan_class, MKDEV(DAHDI_MAJOR, 255));
-	destroy_dev_file(chan_class, MKDEV(DAHDI_MAJOR, 254));
-	destroy_dev_file(chan_class, MKDEV(DAHDI_MAJOR, 253));
+	destroy_dev_file(chan_class, MKDEV(DAHDI_MAJOR, DAHDI_CTL));
+	destroy_dev_file(chan_class, MKDEV(DAHDI_MAJOR, DAHDI_PSEUDO));
+	destroy_dev_file(chan_class, MKDEV(DAHDI_MAJOR, DAHDI_CHANNEL));
+	destroy_dev_file(chan_class, MKDEV(DAHDI_MAJOR, DAHDI_TIMER));
 	class_unregister(chan_class);
 }
 EXPORT_SYMBOL(dahdi_driver_chan_exit);

Modified: linux/team/tzafrir/sysfs/drivers/dahdi/dahdi_transcode.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/dahdi_transcode.c?view=diff&rev=8384&r1=8383&r2=8384
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/dahdi_transcode.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/dahdi_transcode.c Mon Mar 22 09:08:39 2010
@@ -442,7 +442,7 @@
 
 static struct dahdi_chardev transcode_chardev = {
 	.name = "transcode",
-	.minor = 250,
+	.minor = DAHDI_TRANSCODE,
 };
 
 static int dahdi_transcode_init(void)

Modified: linux/team/tzafrir/sysfs/include/dahdi/kernel.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/include/dahdi/kernel.h?view=diff&rev=8384&r1=8383&r2=8384
==============================================================================
--- linux/team/tzafrir/sysfs/include/dahdi/kernel.h (original)
+++ linux/team/tzafrir/sysfs/include/dahdi/kernel.h Mon Mar 22 09:08:39 2010
@@ -1260,6 +1260,8 @@
 						## __VA_ARGS__)
 #define	span_err(span, fmt, ...)	span_printk(ERR, "", span, fmt, \
 						## __VA_ARGS__)
+#define	chan_info(span, fmt, ...)	chan_printk(INFO, "", chan, fmt, \
+						## __VA_ARGS__)
 #define	chan_notice(span, fmt, ...)	chan_printk(NOTICE, "", chan, fmt, \
 						## __VA_ARGS__)
 #define	chan_err(chan, fmt, ...)	chan_printk(ERR, "", chan, fmt, \
@@ -1290,4 +1292,10 @@
 					"%s: " fmt, __func__, ## __VA_ARGS__)))
 #endif /* DAHDI_PRINK_MACROS_USE_debug */
 
+#define	DAHDI_CTL	0
+#define	DAHDI_TRANSCODE	250
+#define	DAHDI_TIMER	253
+#define	DAHDI_CHANNEL	254
+#define	DAHDI_PSEUDO	255
+
 #endif /* _DAHDI_KERNEL_H */




More information about the svn-commits mailing list