ast_mutex_unlock(&p->lock);
}
+/* linear_mode = 0 - turn linear mode off, >0 - turn linear mode on
+* returns the last value of the linear setting
+*/
static int my_set_linear_mode(void *pvt, int idx, int linear_mode)
{
struct dahdi_pvt *p = pvt;
- if (!linear_mode)
- linear_mode = p->subs[idx].linear;
- return dahdi_setlinear(p->subs[idx].dfd, linear_mode);
+ int oldval;
+
+ if (0 > linear_mode || !dahdi_setlinear(p->subs[idx].dfd, linear_mode)) {
+ return -1;
+ }
+ oldval = p->subs[idx].linear;
+ p->subs[idx].linear = linear_mode;
+ return oldval;
}
static int get_alarms(struct dahdi_pvt *p);
static int dahdi_setlinear(int dfd, int linear)
{
- int res;
- res = ioctl(dfd, DAHDI_SETLINEAR, &linear);
- if (res)
- return res;
- return 0;
+ return ioctl(dfd, DAHDI_SETLINEAR, &linear);
}
static int analog_set_linear_mode(struct analog_pvt *p, int index, int linear_mode)
{
if (p->calls->set_linear_mode) {
+ /* Return provides old linear_mode setting or error indication */
return p->calls->set_linear_mode(p->chan_pvt, index, linear_mode);
}
return -1;
/* If set to use DTMF CID signalling, listen for DTMF */
if (p->cid_signalling == CID_SIG_DTMF) {
int i = 0;
+ int oldlinearity;
cs = NULL;
ast_debug(1, "Receiving DTMF cid on "
"channel %s\n", chan->name);
- analog_set_linear_mode(p, index, 0);
+ oldlinearity = analog_set_linear_mode(p, index, 0);
res = 2000;
for (;;) {
}
dtmfbuf[i] = '\0';
- analog_set_linear_mode(p, index, 1);
+ analog_set_linear_mode(p, index, oldlinearity);
/* Got cid and ring. */
ast_debug(1, "CID got string '%s'\n", dtmfbuf);