summaryrefslogtreecommitdiff
path: root/zaptel-base.c
diff options
context:
space:
mode:
authorkpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-01-04 17:20:27 +0000
committerkpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2008-01-04 17:20:27 +0000
commit59a7a1a944902cf112eedc8d451697e9e79599e7 (patch)
tree121fd295e85a5ab906c928d7a85cb8d90c0e6fef /zaptel-base.c
parentf8e7877031402b282da93a41021c4394ad455747 (diff)
[commit message]
(issue #10393) Reported by: tzafrir Patches: chan_alarm_zaptel.diff uploaded by tzafrir (license 46) (modified by me) git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.4@3613 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'zaptel-base.c')
-rw-r--r--zaptel-base.c51
1 files changed, 39 insertions, 12 deletions
diff --git a/zaptel-base.c b/zaptel-base.c
index 1e9f707..7f48105 100644
--- a/zaptel-base.c
+++ b/zaptel-base.c
@@ -142,6 +142,7 @@ EXPORT_SYMBOL(zt_hdlc_abort);
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 @@ static int zt_release(struct inode *inode, struct file *file)
}
#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 @@ void zt_alarm_notify(struct zt_span *span)
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 @@ static int zt_common_ioctl(struct inode *node, struct file *file, unsigned int c
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 @@ static int zt_common_ioctl(struct inode *node, struct file *file, unsigned int c
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 @@ static int zt_common_ioctl(struct inode *node, struct file *file, unsigned int c
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)))
+ /* 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;