dahdi: Cleanup formatting in dahdi_ioctl_set_dialparams().
Mainly I wanted to document that the global_dialparams is protected by the BKL so that it can be closely checked when lock_kernel is removed from DAHDI. Signed-off-by: Shaun Ruffell <sruffell@digium.com> Acked-by: Kinsey Moore <kmoore@digium.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9596 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
@@ -4431,50 +4431,63 @@ static int dahdi_ioctl_chanconfig(struct file *file, unsigned long data)
|
||||
return res;
|
||||
}
|
||||
|
||||
static int dahdi_ioctl_set_dialparams(struct file *file, unsigned long data)
|
||||
/**
|
||||
* dahdi_ioctl_set_dialparms - Set the global dial parameters.
|
||||
* @data: Pointer to user space that contains dahdi_dialparams.
|
||||
*
|
||||
* NOTE: The global_dialparms is currently protected from concurrent updates
|
||||
* by the lock_kernel/unlock_kernel calls.
|
||||
*
|
||||
*/
|
||||
static int dahdi_ioctl_set_dialparams(unsigned long data)
|
||||
{
|
||||
unsigned int i;
|
||||
struct dahdi_dialparams tdp;
|
||||
struct dahdi_zone *z;
|
||||
struct dahdi_dialparams *const gdp = &global_dialparams;
|
||||
|
||||
if (copy_from_user(&tdp, (void __user *)data, sizeof(tdp)))
|
||||
return -EFAULT;
|
||||
|
||||
if ((tdp.dtmf_tonelen >= 10) && (tdp.dtmf_tonelen <= 4000)) {
|
||||
global_dialparams.dtmf_tonelen = tdp.dtmf_tonelen;
|
||||
}
|
||||
if ((tdp.mfv1_tonelen >= 10) && (tdp.mfv1_tonelen <= 4000)) {
|
||||
global_dialparams.mfv1_tonelen = tdp.mfv1_tonelen;
|
||||
}
|
||||
if ((tdp.mfr2_tonelen >= 10) && (tdp.mfr2_tonelen <= 4000)) {
|
||||
global_dialparams.mfr2_tonelen = tdp.mfr2_tonelen;
|
||||
}
|
||||
if ((tdp.dtmf_tonelen >= 10) && (tdp.dtmf_tonelen <= 4000))
|
||||
gdp->dtmf_tonelen = tdp.dtmf_tonelen;
|
||||
|
||||
if ((tdp.mfv1_tonelen >= 10) && (tdp.mfv1_tonelen <= 4000))
|
||||
gdp->mfv1_tonelen = tdp.mfv1_tonelen;
|
||||
|
||||
if ((tdp.mfr2_tonelen >= 10) && (tdp.mfr2_tonelen <= 4000))
|
||||
gdp->mfr2_tonelen = tdp.mfr2_tonelen;
|
||||
|
||||
/* update the lengths in all currently loaded zones */
|
||||
spin_lock(&zone_lock);
|
||||
list_for_each_entry(z, &tone_zones, node) {
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(z->dtmf); i++) {
|
||||
z->dtmf[i].tonesamples = global_dialparams.dtmf_tonelen * DAHDI_CHUNKSIZE;
|
||||
z->dtmf[i].tonesamples =
|
||||
gdp->dtmf_tonelen * DAHDI_CHUNKSIZE;
|
||||
}
|
||||
|
||||
/* for MFR1, we only adjust the length of the digits */
|
||||
for (i = DAHDI_TONE_MFR1_0; i <= DAHDI_TONE_MFR1_9; i++) {
|
||||
z->mfr1[i - DAHDI_TONE_MFR1_BASE].tonesamples = global_dialparams.mfv1_tonelen * DAHDI_CHUNKSIZE;
|
||||
z->mfr1[i - DAHDI_TONE_MFR1_BASE].tonesamples =
|
||||
gdp->mfv1_tonelen * DAHDI_CHUNKSIZE;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(z->mfr2_fwd); i++) {
|
||||
z->mfr2_fwd[i].tonesamples = global_dialparams.mfr2_tonelen * DAHDI_CHUNKSIZE;
|
||||
z->mfr2_fwd[i].tonesamples =
|
||||
gdp->mfr2_tonelen * DAHDI_CHUNKSIZE;
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(z->mfr2_rev); i++) {
|
||||
z->mfr2_rev[i].tonesamples = global_dialparams.mfr2_tonelen * DAHDI_CHUNKSIZE;
|
||||
z->mfr2_rev[i].tonesamples =
|
||||
gdp->mfr2_tonelen * DAHDI_CHUNKSIZE;
|
||||
}
|
||||
}
|
||||
spin_unlock(&zone_lock);
|
||||
|
||||
dtmf_silence.tonesamples = global_dialparams.dtmf_tonelen * DAHDI_CHUNKSIZE;
|
||||
mfr1_silence.tonesamples = global_dialparams.mfv1_tonelen * DAHDI_CHUNKSIZE;
|
||||
mfr2_silence.tonesamples = global_dialparams.mfr2_tonelen * DAHDI_CHUNKSIZE;
|
||||
dtmf_silence.tonesamples = gdp->dtmf_tonelen * DAHDI_CHUNKSIZE;
|
||||
mfr1_silence.tonesamples = gdp->mfv1_tonelen * DAHDI_CHUNKSIZE;
|
||||
mfr2_silence.tonesamples = gdp->mfr2_tonelen * DAHDI_CHUNKSIZE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -4683,7 +4696,7 @@ static int dahdi_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long da
|
||||
return dahdi_unregister_tone_zone(j);
|
||||
|
||||
case DAHDI_SET_DIALPARAMS:
|
||||
return dahdi_ioctl_set_dialparams(file, data);
|
||||
return dahdi_ioctl_set_dialparams(data);
|
||||
|
||||
case DAHDI_GET_DIALPARAMS:
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user