[svn-commits] fjoe: freebsd/trunk r9189 - in /freebsd/trunk: drivers/dahdi/ include/dahdi/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Aug 25 04:57:55 CDT 2010


Author: fjoe
Date: Wed Aug 25 04:57:51 2010
New Revision: 9189

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9189
Log:
- Fix non-blocking mode detection in __rbs_otimer_expire()
This fixes outgoing calls on FXO.
- dahdi_schluffen() should return negative value on error.

Modified:
    freebsd/trunk/drivers/dahdi/dahdi-base.c
    freebsd/trunk/include/dahdi/kernel.h

Modified: freebsd/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=9189&r1=9188&r2=9189
==============================================================================
--- freebsd/trunk/drivers/dahdi/dahdi-base.c (original)
+++ freebsd/trunk/drivers/dahdi/dahdi-base.c Wed Aug 25 04:57:51 2010
@@ -214,21 +214,21 @@
 	return 0;
 }
 
-static int
-dahdi_get_flags(struct cdev *dev)
+void *
+dahdi_get_private_data(struct file *file)
 {
 	int error;
 	struct dahdi_fp *fp;
 
 	error = devfs_get_cdevpriv((void **) &fp);
 	if (error || fp == NULL)
-		return 0;
-
-	return fp->fflags;
-}
-
-static void
-dahdi_set_flags(struct file *file, int fflags)
+		return NULL;
+
+	return fp->private_data;
+}
+
+void
+dahdi_set_private_data(struct file *file, void *private_data)
 {
 	int error;
 	struct dahdi_fp *fp;
@@ -237,33 +237,13 @@
 	if (error)
 		return;
 
-	fp->fflags = fflags;
-}
-
-void *
-dahdi_get_private_data(struct file *file)
-{
-	int error;
-	struct dahdi_fp *fp;
-
-	error = devfs_get_cdevpriv((void **) &fp);
-	if (error || fp == NULL)
-		return NULL;
-
-	return fp->private_data;
-}
-
-void
-dahdi_set_private_data(struct file *file, void *private_data)
-{
-	int error;
-	struct dahdi_fp *fp;
-
-	error = dahdi_get_fp(file->dev, &fp);
-	if (error)
-		return;
-
 	fp->private_data = private_data;
+}
+
+static int
+dahdi_chan_is_nonblocking(struct dahdi_chan *chan)
+{
+	return chan->file && (chan->file_flags & O_NONBLOCK);
 }
 
 static void
@@ -305,7 +285,7 @@
 	switch (rc) {
 	case EINTR:
 	case ERESTART:
-		return rc;
+		return -rc;
 	}
 	return 0;
 }
@@ -386,15 +366,6 @@
 /* macro-oni for determining a unit (channel) number */
 #define	UNIT(file) MINOR(file->f_dentry->d_inode->i_rdev)
 
-static int
-dahdi_get_flags(struct file *file)
-{
-	if (!file)
-		return 0;
-
-	return file->f_flags;
-}
-
 void *
 dahdi_get_private_data(struct file *file)
 {
@@ -405,6 +376,12 @@
 dahdi_set_private_data(struct file *file, void *private_data)
 {
 	file->private_data = private_data;
+}
+
+static int
+dahdi_chan_is_nonblocking(struct dahdi_chan *chan)
+{
+	return chan->file && (chan->file->f_flags & O_NONBLOCK);
 }
 
 static void
@@ -3139,7 +3116,12 @@
 					res = chan->span->ops->open(chan);
 			}
 			if (!res) {
+#if defined(__FreeBSD__)
 				chan->file = file->dev;
+				chan->file_flags = file->f_flags;
+#else
+				chan->file = file;
+#endif
 				spin_unlock_irqrestore(&chan->lock, flags);
 			} else {
 				spin_unlock_irqrestore(&chan->lock, flags);
@@ -5824,19 +5806,16 @@
 	switch(cmd) {
 #if defined(__FreeBSD__)
 	case F_SETFL: {
-		int fflags = dahdi_get_flags(file->dev);
-
 		get_user(j, data);
 
 		/*
 		 * XXX: On the moment we're interested only in O_NONBLOCK
 		 * Need any other flags?
 		 */
-		if ((j & O_NONBLOCK) != 0) {
-			dahdi_set_flags(file, fflags | O_NONBLOCK);
-		} else {
-			dahdi_set_flags(file, fflags & ~O_NONBLOCK);
-		}
+		if ((j & O_NONBLOCK) != 0)
+			chan->file_flags |= O_NONBLOCK;
+		else
+			chan->file_flags &= ~O_NONBLOCK;
 		break;
 	}
 #endif /* __FreeBSD__ */
@@ -6104,6 +6083,7 @@
 			return -EINVAL;
 		/* if no span, just do nothing */
 		if (!chan->span) return(0);
+		printf("DAHDI_HOOK: %d\n", j);
 		spin_lock_irqsave(&chan->lock, flags);
 		/* if dialing, stop it */
 		chan->curtone = NULL;
@@ -7182,7 +7162,7 @@
 	case DAHDI_TXSTATE_WINK:
 		/* Wink complete, go on hook and stabalize */
 		dahdi_rbs_sethook(chan, DAHDI_TXSIG_ONHOOK, DAHDI_TXSTATE_ONHOOK, 0);
-		if (dahdi_get_flags(chan->file) & O_NONBLOCK)
+		if (dahdi_chan_is_nonblocking(chan))
 			__qevent(chan, DAHDI_EVENT_HOOKCOMPLETE);
 		wake_up_interruptible(&chan->txstateq);
 		break;
@@ -7194,7 +7174,7 @@
 
 	case DAHDI_TXSTATE_FLASH:
 		dahdi_rbs_sethook(chan, DAHDI_TXSIG_OFFHOOK, DAHDI_TXSTATE_OFFHOOK, 0);
-		if (dahdi_get_flags(chan->file) & O_NONBLOCK)
+		if (dahdi_chan_is_nonblocking(chan))
 			__qevent(chan, DAHDI_EVENT_HOOKCOMPLETE);
 		wake_up_interruptible(&chan->txstateq);
 		break;
@@ -7209,14 +7189,14 @@
 
 	case DAHDI_TXSTATE_AFTERSTART:
 		dahdi_rbs_sethook(chan, DAHDI_TXSIG_OFFHOOK, DAHDI_TXSTATE_OFFHOOK, 0);
-		if (dahdi_get_flags(chan->file) & O_NONBLOCK)
+		if (dahdi_chan_is_nonblocking(chan))
 			__qevent(chan, DAHDI_EVENT_HOOKCOMPLETE);
 		wake_up_interruptible(&chan->txstateq);
 		break;
 
 	case DAHDI_TXSTATE_KEWL:
 		dahdi_rbs_sethook(chan, DAHDI_TXSIG_ONHOOK, DAHDI_TXSTATE_AFTERKEWL, DAHDI_AFTERKEWLTIME);
-		if (dahdi_get_flags(chan->file) & O_NONBLOCK)
+		if (dahdi_chan_is_nonblocking(chan))
 			__qevent(chan, DAHDI_EVENT_HOOKCOMPLETE);
 		wake_up_interruptible(&chan->txstateq);
 		break;
@@ -9050,12 +9030,11 @@
 	int res;
 	struct file file;
 
-	init_file(&file, dev, 0);
+	init_file(&file, dev, oflags);
 	res = dahdi_open(NULL, &file);
 	if (res < 0)
 		return -res;
 
-	dahdi_set_flags(&file, oflags);
 	return res;
 }
 
@@ -9065,7 +9044,7 @@
 	int res;
 	struct file file;
 
-	init_file(&file, dev, 0);
+	init_file(&file, dev, fflag);
 	res = dahdi_release(NULL, &file);
 	if (res < 0)
 		return -res;

Modified: freebsd/trunk/include/dahdi/kernel.h
URL: http://svnview.digium.com/svn/dahdi/freebsd/trunk/include/dahdi/kernel.h?view=diff&rev=9189&r1=9188&r2=9189
==============================================================================
--- freebsd/trunk/include/dahdi/kernel.h (original)
+++ freebsd/trunk/include/dahdi/kernel.h Wed Aug 25 04:57:51 2010
@@ -467,6 +467,7 @@
 #if defined(__FreeBSD__)
 	struct cdev *dev;	/*!< Device structure */
 	struct cdev *file;	/*!< File structure */
+	int file_flags;
 #else
 	struct file *file;	/*!< File structure */
 #endif




More information about the svn-commits mailing list