diff options
author | Doug Bailey <dbailey@digium.com> | 2009-01-21 15:39:46 +0000 |
---|---|---|
committer | Doug Bailey <dbailey@digium.com> | 2009-01-21 15:39:46 +0000 |
commit | 613ed956297773445ac225da4d8129eb9df73b10 (patch) | |
tree | 7e43011c546fbee75f25fd7669d16aefd579bb76 /drivers/dahdi/wctdm.c | |
parent | 9b8c4f9965b097601a256452e5fe6dc6f9bdc8ad (diff) |
Change the DAHDI_VMWI ioctl call to pass data via structure.
Changed wctdm and wctdm24xxp to handle these calls.
(issue #14104)
Reported by: alecdavis
Patches:
mwiioctl_structure_dahdi.diff2.txt uploaded by dbailey (license )
Tested by: alecdavis, dbailey
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@5785 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/wctdm.c')
-rw-r--r-- | drivers/dahdi/wctdm.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/drivers/dahdi/wctdm.c b/drivers/dahdi/wctdm.c index d4c94e9..cc32a9f 100644 --- a/drivers/dahdi/wctdm.c +++ b/drivers/dahdi/wctdm.c @@ -239,7 +239,7 @@ struct wctdm { int palarms; int reversepolarity; /* Reverse Line */ int mwisendtype; - int vmwimessages; /* 0=none 1-255=number of messages */ + struct dahdi_vmwi_info vmwisetting; int vmwi_lrev:1; /* MWI Line Reversal*/ int vmwi_hvdc:1; /* MWI High Voltage DC Idle line */ int vmwi_hvac:1; /* MWI Neon High Voltage AC Idle line */ @@ -1568,12 +1568,12 @@ static int wctdm_init_proslic(struct wctdm *wc, int card, int fast, int manual, return -2; /* default messages to none and method to FSK */ - wc->mod[card].fxs.mwisendtype=DAHDI_VMWI_FSK; - wc->mod[card].fxs.vmwimessages=0; - wc->mod[card].fxs.vmwi_lrev=0; - wc->mod[card].fxs.vmwi_hvdc=0; - wc->mod[card].fxs.vmwi_hvac=0; - + memset(&wc->mod[card].fxs.vmwisetting, 0, sizeof(wc->mod[card].fxs.vmwisetting)); + wc->mod[card].fxs.vmwi_lrev = 0; + wc->mod[card].fxs.vmwi_hvdc = 0; + wc->mod[card].fxs.vmwi_hvac = 0; + + /* By default, don't send on hook */ if (!reversepolarity != !wc->mod[card].fxs.reversepolarity) wc->mod[card].fxs.idletxhookstate = 5; @@ -1841,20 +1841,15 @@ static int wctdm_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long wctdm_setreg(wc, chan->chanpos - 1, 64, wc->mod[chan->chanpos - 1].fxs.lasttxhook); break; case DAHDI_VMWI: - /* value: bits 15-8 VMWI TYPE */ - /* bits 7-0 VMWI number of messages */ - if (get_user(x, (__user int *) data)) - return -EFAULT; if (wc->modtype[chan->chanpos - 1] != MOD_TYPE_FXS) return -EINVAL; + if (copy_from_user(&(wc->mod[chan->chanpos - 1].fxs.vmwisetting), (__user void *) data, sizeof(wc->mod[chan->chanpos - 1].fxs.vmwisetting))) + return -EFAULT; - wc->mod[chan->chanpos - 1].fxs.vmwimessages = (x & DAHDI_VMWI_NUMBER_MASK); - wc->mod[chan->chanpos - 1].fxs.mwisendtype = (x & ~ DAHDI_VMWI_NUMBER_MASK); - if (wc->mod[chan->chanpos - 1].fxs.vmwimessages){ - x = wc->mod[chan->chanpos - 1].fxs.mwisendtype; - wc->mod[chan->chanpos - 1].fxs.vmwi_lrev = (x & DAHDI_VMWI_LREV)?1:0; - wc->mod[chan->chanpos - 1].fxs.vmwi_hvdc = (x & DAHDI_VMWI_HVDC)?1:0; - wc->mod[chan->chanpos - 1].fxs.vmwi_hvac = (x & DAHDI_VMWI_HVAC)?1:0; + if (wc->mod[chan->chanpos - 1].fxs.vmwisetting.messages){ + wc->mod[chan->chanpos - 1].fxs.vmwi_lrev = (wc->mod[chan->chanpos - 1].fxs.vmwisetting.linereverse)?1:0; + wc->mod[chan->chanpos - 1].fxs.vmwi_hvdc = (wc->mod[chan->chanpos - 1].fxs.vmwisetting.hvdc)?1:0; + wc->mod[chan->chanpos - 1].fxs.vmwi_hvac = (wc->mod[chan->chanpos - 1].fxs.vmwisetting.hvac)?1:0; } else { wc->mod[chan->chanpos - 1].fxs.vmwi_lrev = 0; wc->mod[chan->chanpos - 1].fxs.vmwi_hvdc = 0; @@ -1862,10 +1857,9 @@ static int wctdm_ioctl(struct dahdi_chan *chan, unsigned int cmd, unsigned long } if (debug) { - printk(KERN_DEBUG "Setting VMWI on channel %d, type=0x%X, messages=%d, lrev=%d, hvdc=%d, hvac=%d\n", + printk(KERN_DEBUG "Setting VMWI on channel %d, messages=%d, lrev=%d, hvdc=%d, hvac=%d\n", chan->chanpos-1, - wc->mod[chan->chanpos - 1].fxs.mwisendtype, - wc->mod[chan->chanpos - 1].fxs.vmwimessages, + wc->mod[chan->chanpos - 1].fxs.vmwisetting.messages, wc->mod[chan->chanpos - 1].fxs.vmwi_lrev, wc->mod[chan->chanpos - 1].fxs.vmwi_hvdc, wc->mod[chan->chanpos - 1].fxs.vmwi_hvac |