[dahdi-commits] sruffell: linux/trunk r9596 - /linux/trunk/drivers/dahdi/dahdi-base.c
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Mon Jan 3 18:27:22 UTC 2011
Author: sruffell
Date: Mon Jan 3 12:27:18 2011
New Revision: 9596
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9596
Log:
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 at digium.com>
Acked-by: Kinsey Moore <kmoore at digium.com>
Modified:
linux/trunk/drivers/dahdi/dahdi-base.c
Modified: linux/trunk/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/dahdi-base.c?view=diff&rev=9596&r1=9595&r2=9596
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Mon Jan 3 12:27:18 2011
@@ -4431,50 +4431,63 @@
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 @@
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:
{
More information about the dahdi-commits
mailing list