[zaptel-commits] kpfleming: branch 1.4 r3613 - in /branches/1.4: zaptel-base.c zaptel.h

SVN commits to the Zaptel project zaptel-commits at lists.digium.com
Fri Jan 4 11:20:27 CST 2008


Author: kpfleming
Date: Fri Jan  4 11:20:27 2008
New Revision: 3613

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3613
Log:
[commit message]

(issue #10393)
Reported by: tzafrir
Patches:
      chan_alarm_zaptel.diff uploaded by tzafrir (license 46) (modified by me)


Modified:
    branches/1.4/zaptel-base.c
    branches/1.4/zaptel.h

Modified: branches/1.4/zaptel-base.c
URL: http://svn.digium.com/view/zaptel/branches/1.4/zaptel-base.c?view=diff&rev=3613&r1=3612&r2=3613
==============================================================================
--- branches/1.4/zaptel-base.c (original)
+++ branches/1.4/zaptel-base.c Fri Jan  4 11:20:27 2008
@@ -142,6 +142,7 @@
 EXPORT_SYMBOL(zt_hdlc_finish);
 EXPORT_SYMBOL(zt_hdlc_getbuf);
 EXPORT_SYMBOL(zt_hdlc_putbuf);
+EXPORT_SYMBOL(zt_alarm_channel);
 
 #ifdef CONFIG_PROC_FS
 static struct proc_dir_entry *proc_entries[ZT_MAX_SPANS]; 
@@ -2872,9 +2873,20 @@
 }
 #endif
 
+
+void zt_alarm_channel(struct zt_chan *chan, int alarms)
+{
+	if (debug)
+		printk(KERN_DEBUG "%s: Channel %s, alarms: %x, current: %x\n", 
+		       __FUNCTION__, chan->name, alarms, chan->chan_alarms);
+	if (chan->chan_alarms != alarms) {
+		chan->chan_alarms = alarms;
+		zt_qevent_lock(chan, alarms ? ZT_EVENT_ALARM : ZT_EVENT_NOALARM);
+	}
+}
+
 void zt_alarm_notify(struct zt_span *span)
 {
-	int j;
 	int x;
 
 	span->alarms &= ~ZT_ALARM_LOOPBACK;
@@ -2886,13 +2898,9 @@
 	   as ((!a) != (!b)) */
 	/* if change in general state */
 	if ((!span->alarms) != (!span->lastalarms)) {
-		if (span->alarms)
-			j = ZT_EVENT_ALARM;
-		else
-			j = ZT_EVENT_NOALARM;
 		span->lastalarms = span->alarms;
-		for (x=0;x < span->channels;x++)
-			zt_qevent_lock(&span->chans[x], j);
+		for (x = 0; x < span->channels; x++)
+			zt_alarm_channel(&span->chans[x], span->alarms);
 		/* Switch to other master if current master in alarm */
 		for (x=1; x<maxspans; x++) {
 			if (spans[x] && !spans[x]->alarms && (spans[x]->flags & ZT_FLAG_RUNNING)) {
@@ -2991,8 +2999,12 @@
 	size_t size_to_copy;
 
 	switch(cmd) {
-	case ZT_GET_PARAMS: /* get channel timing parameters */
-		if (copy_from_user(&stack.param,(struct zt_params *)data,sizeof(stack.param)))
+		/* get channel parameters */
+	case ZT_GET_PARAMS_V1:
+	case ZT_GET_PARAMS:
+		size_to_copy = (cmd == ZT_GET_PARAMS_V1) ? sizeof(struct zt_params_v1) :
+			       sizeof(struct zt_params);
+		if (copy_from_user(&stack.param, (struct zt_params *) data, size_to_copy))
 			return -EFAULT;
 
 		/* check to see if the caller wants to receive our master channel number */
@@ -3050,6 +3062,7 @@
 		stack.param.rxflashtime = chan->rxflashtime;
 		stack.param.debouncetime = chan->debouncetime;
 		stack.param.channo = chan->channo;
+		stack.param.chan_alarms = chan->chan_alarms;
 
 		/* if requested, put the master channel number in the top 16 bits of the result */
 		if (return_master)
@@ -3068,12 +3081,26 @@
 			stack.param.curlaw = ZT_LAW_ALAW;
 		else
 			stack.param.curlaw = ZT_LAW_MULAW;
-		if (copy_to_user((struct zt_params *)data,&stack.param,sizeof(stack.param)))
+
+		if (debug)
+			printk(KERN_DEBUG "%s: ZT_GET_PARAMS_V1, Channel %s.\n", 
+			       __FUNCTION__, chan->name);
+		if (copy_to_user((struct zt_params *) data, &stack.param, size_to_copy))
 			return -EFAULT;
-		break;
-	case ZT_SET_PARAMS: /* set channel timing stack.paramters */
-		if (copy_from_user(&stack.param,(struct zt_params *)data,sizeof(stack.param)))
+
+		break;
+		/* set channel parameters */
+	case ZT_SET_PARAMS_V1:
+	case ZT_SET_PARAMS:
+		/* The difference between zt_params and zt_params_v1 is just the 
+		 * last field, which is read-only anyway. Thus we just read the
+		 * size of the older struct.
+		 */
+		if (copy_from_user(&stack.param, (struct zt_params *) data, sizeof(struct zt_params_v1)))
 			return -EFAULT;
+
+		stack.param.chan_alarms = 0; /* be explicit about the above */
+
 		/* Pick the right channo's */
 		if (!stack.param.channo || unit) {
 			stack.param.channo = unit;

Modified: branches/1.4/zaptel.h
URL: http://svn.digium.com/view/zaptel/branches/1.4/zaptel.h?view=diff&rev=3613&r1=3612&r2=3613
==============================================================================
--- branches/1.4/zaptel.h (original)
+++ branches/1.4/zaptel.h Fri Jan  4 11:20:27 2008
@@ -185,32 +185,61 @@
 #define ZT_SPANINFO_HAS_LINECONFIG
 #define ZT_SPANINFO_HAS_LBONAME
 
+struct zt_params_v1
+{
+	int channo;		/* Channel number */
+	int spanno;		/* Span itself */
+	int chanpos;		/* Channel number in span */
+	int sigtype;		/* read-only */
+	int sigcap;		/* read-only */
+	int rxisoffhook;	/* read-only */
+	int rxbits;		/* read-only */
+	int txbits;		/* read-only */
+	int txhooksig;		/* read-only */
+	int rxhooksig;		/* read-only */
+	int curlaw;		/* read-only  -- one of ZT_LAW_MULAW or ZT_LAW_ALAW */
+	int idlebits;		/* read-only  -- What is considered the idle state */
+	char name[40];		/* Name of channel */
+	int prewinktime;
+	int preflashtime;
+	int winktime;
+	int flashtime;
+	int starttime;
+	int rxwinktime;
+	int rxflashtime;
+	int debouncetime;
+	int pulsebreaktime;
+	int pulsemaketime;
+	int pulseaftertime;
+};
+
 typedef struct zt_params
 {
-int channo;		/* Channel number */
-int spanno;		/* Span itself */
-int chanpos;	/* Channel number in span */
-int	sigtype;  /* read-only */
-int sigcap;	 /* read-only */
-int rxisoffhook; /* read-only */
-int rxbits;	/* read-only */
-int txbits;	/* read-only */
-int txhooksig;	/* read-only */
-int rxhooksig;	/* read-only */
-int curlaw;	/* read-only  -- one of ZT_LAW_MULAW or ZT_LAW_ALAW */
-int idlebits;	/* read-only  -- What is considered the idle state */
-char name[40];	/* Name of channel */
-int	prewinktime;
-int	preflashtime;
-int	winktime;
-int	flashtime;
-int	starttime;
-int	rxwinktime;
-int	rxflashtime;
-int	debouncetime;
-int	pulsebreaktime;
-int	pulsemaketime;
-int	pulseaftertime;
+	int channo;		/* Channel number */
+	int spanno;		/* Span itself */
+	int chanpos;		/* Channel number in span */
+	int sigtype;		/* read-only */
+	int sigcap;		/* read-only */
+	int rxisoffhook;	/* read-only */
+	int rxbits;		/* read-only */
+	int txbits;		/* read-only */
+	int txhooksig;		/* read-only */
+	int rxhooksig;		/* read-only */
+	int curlaw;		/* read-only  -- one of ZT_LAW_MULAW or ZT_LAW_ALAW */
+	int idlebits;		/* read-only  -- What is considered the idle state */
+	char name[40];		/* Name of channel */
+	int prewinktime;
+	int preflashtime;
+	int winktime;
+	int flashtime;
+	int starttime;
+	int rxwinktime;
+	int rxflashtime;
+	int debouncetime;
+	int pulsebreaktime;
+	int pulsemaketime;
+	int pulseaftertime;
+	__u32 chan_alarms;	/* alarms on this channel */
 } ZT_PARAMS;
 
 struct zt_spaninfo_v1 {
@@ -420,11 +449,13 @@
 /*
  * Get channel parameters
  */
+#define ZT_GET_PARAMS_V1	_IOR (ZT_CODE, 5, struct zt_params_v1)
 #define ZT_GET_PARAMS		_IOR (ZT_CODE, 5, struct zt_params)
 
 /*
  * Get channel parameters
  */
+#define ZT_SET_PARAMS_V1	_IOW (ZT_CODE, 6, struct zt_params_v1)
 #define ZT_SET_PARAMS		_IOW (ZT_CODE, 6, struct zt_params)
 
 /*
@@ -1264,10 +1295,10 @@
 	struct file *file;	/* File structure */
 	
 	
-	struct zt_span *span;		/* Span we're a member of */
-	int sig;			/* Signalling */
-	int sigcap;			/* Capability for signalling */
-	
+	struct zt_span	*span;			/* Span we're a member of */
+	int		sig;			/* Signalling */
+	int		sigcap;			/* Capability for signalling */
+	__u32		chan_alarms;		/* alarms status */
 
 	/* Used only by zaptel -- NO DRIVER SERVICEABLE PARTS BELOW */
 	/* Buffer declarations */
@@ -1709,7 +1740,10 @@
 /* Queue an event on a channel, locking it first */
 void zt_qevent_lock(struct zt_chan *chan, int event);
 
-/* Notify a change possible change in alarm status */
+/* Notify a change possible change in alarm status on a channel */
+void zt_alarm_channel(struct zt_chan *chan, int alarms);
+
+/* Notify a change possible change in alarm status on a span */
 void zt_alarm_notify(struct zt_span *span);
 
 /* Initialize a tone state */




More information about the zaptel-commits mailing list