Index: include/dahdi/user.h =================================================================== --- include/dahdi/user.h (revision 5766) +++ include/dahdi/user.h (working copy) @@ -967,19 +967,24 @@ #define DAHDI_TC_GETINFO _IOWR(DAHDI_TC_CODE, 2, struct dahdi_transcoder_info) /* + * VMWI Specification + */ +struct dahdi_vmwi_info { + unsigned int messages; /* Number of messages pending */ + unsigned char fsk; /* default FSK, */ + unsigned char rpas; /* Ring Pulse Alert Signal precedes the FSK spill */ + unsigned char linereverse; /* Line reversal message indicator */ + unsigned char hvdc; /* Line reversal message indicator */ + unsigned char hvac; /* Line reversal message indicator */ +}; + +/* * VoiceMail Waiting Indication (VMWI) -- implemented by low-level driver. * Value: number of waiting messages (hence 0: switch messages off). */ -#define DAHDI_VMWI _IOWR(DAHDI_CODE, 94, int) +#define DAHDI_VMWI _IOWR(DAHDI_CODE, 94, struct dahdi_vmwi_info) -#define DAHDI_VMWI_NUMBER_MASK (0xffff) /* Number of messages pending for VMWI */ -#define DAHDI_VMWI_FSK (1 << 16) /* default FSK, no Ring Pulse Alert Signal*/ -#define DAHDI_VMWI_RPAS (1 << 17) /* Ring Pulse Alert Signal then FSK */ -#define DAHDI_VMWI_LREV (1 << 18) /* Line Reversal */ -#define DAHDI_VMWI_HVDC (1 << 19) /* HV 90VDC */ -#define DAHDI_VMWI_HVAC (1 << 20) /* HV 90VAC Neon lamp */ - -/* +/* * Startup or Shutdown a span */ #define DAHDI_STARTUP _IOW(DAHDI_CODE, 99, int) Index: drivers/dahdi/wctdm.c =================================================================== --- drivers/dahdi/wctdm.c (revision 5766) +++ drivers/dahdi/wctdm.c (working copy) @@ -239,7 +239,7 @@ 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 @@ 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 @@ 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 @@ } 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 Index: drivers/dahdi/wctdm24xxp/wctdm24xxp.h =================================================================== --- drivers/dahdi/wctdm24xxp/wctdm24xxp.h (revision 5766) +++ drivers/dahdi/wctdm24xxp/wctdm24xxp.h (working copy) @@ -248,9 +248,8 @@ int idletxhookstate; /* IDLE changing hook state */ int lasttxhook; /* Bits 0-3 are written to proslic reg 64, Bit 4 indicates if the last write is pending */ int palarms; - int mwisendtype; - int vmwimessages; /* 0=none 1-255=number of messages */ - int vmwilinereverse; /* MWI Line Reversal*/ + struct dahdi_vmwi_info vmwisetting; + int linereverse_mwi; int reversepolarity; /* polarity reversal */ struct calregs calregs; } fxs; Index: drivers/dahdi/wctdm24xxp/base.c =================================================================== --- drivers/dahdi/wctdm24xxp/base.c (revision 5766) +++ drivers/dahdi/wctdm24xxp/base.c (working copy) @@ -87,7 +87,7 @@ * polarity reversal for the port, * and the state of the line reversal MWI indicator */ -#define POLARITY_XOR(card) ( (reversepolarity != 0) ^ (wc->mods[(card)].fxs.reversepolarity != 0) ^ (wc->mods[(card)].fxs.vmwilinereverse != 0) ) +#define POLARITY_XOR(card) ( (reversepolarity != 0) ^ (wc->mods[(card)].fxs.reversepolarity != 0) ^ (wc->mods[(card)].fxs.linereverse_mwi != 0) ) static int reversepolarity = 0; static alpha indirect_regs[] = @@ -2052,9 +2052,8 @@ return -2; /* Initialize VMWI settings */ - wc->mods[card].fxs.mwisendtype = 0; - wc->mods[card].fxs.vmwimessages = 0; - wc->mods[card].fxs.vmwilinereverse = 0; + memset(&(wc->mods[card].fxs.vmwisetting), 0, sizeof(wc->mods[card].fxs.vmwisetting)); + wc->mods[card].fxs.linereverse_mwi = 0; /* By default, don't send on hook */ if (!reversepolarity != !wc->mods[card].fxs.reversepolarity) { @@ -2446,20 +2445,15 @@ } 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; - - wc->mods[chan->chanpos - 1].fxs.vmwimessages = (x & DAHDI_VMWI_NUMBER_MASK); - wc->mods[chan->chanpos - 1].fxs.mwisendtype = (x & ~DAHDI_VMWI_NUMBER_MASK); - if (wc->mods[chan->chanpos - 1].fxs.vmwimessages){ - x = wc->mods[chan->chanpos - 1].fxs.mwisendtype; - wc->mods[chan->chanpos - 1].fxs.vmwilinereverse= (x & DAHDI_VMWI_LREV)?1:0; + if (copy_from_user(&(wc->mods[chan->chanpos - 1].fxs.vmwisetting), (__user void *) data, sizeof(wc->mods[chan->chanpos - 1].fxs.vmwisetting))) + return -EFAULT; + + if (wc->mods[chan->chanpos - 1].fxs.vmwisetting.messages && wc->mods[chan->chanpos - 1].fxs.vmwisetting.linereverse){ + wc->mods[chan->chanpos - 1].fxs.linereverse_mwi = 1; } else { - wc->mods[chan->chanpos - 1].fxs.vmwilinereverse= 0; + wc->mods[chan->chanpos - 1].fxs.linereverse_mwi = 0; } /* Set line polarity for new VMWI state */ if (POLARITY_XOR(chan->chanpos -1)) { @@ -2484,11 +2478,10 @@ } if (debug) { - printk(KERN_DEBUG "Setting VMWI on channel %d, type=0x%X, messages=%d, lrev=%d\n", + printk(KERN_DEBUG "Setting VMWI on channel %d, messages=%d, lrev=%d\n", chan->chanpos-1, - wc->mods[chan->chanpos - 1].fxs.mwisendtype, - wc->mods[chan->chanpos - 1].fxs.vmwimessages, - wc->mods[chan->chanpos - 1].fxs.vmwilinereverse + wc->mods[chan->chanpos - 1].fxs.vmwisetting.messages, + wc->mods[chan->chanpos - 1].fxs.linereverse_mwi ); } break;