[dahdi-commits] sruffell: branch linux/sruffell/chan_list_refactoring r9279 - /linux/team/sru...
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Thu Sep 2 12:41:24 CDT 2010
Author: sruffell
Date: Thu Sep 2 12:41:13 2010
New Revision: 9279
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9279
Log:
dahdi: Remove unit parameter from dahdi_ioctl_[get|set]gains.
Modified:
linux/team/sruffell/chan_list_refactoring/drivers/dahdi/dahdi-base.c
Modified: linux/team/sruffell/chan_list_refactoring/drivers/dahdi/dahdi-base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/chan_list_refactoring/drivers/dahdi/dahdi-base.c?view=diff&rev=9279&r1=9278&r2=9279
==============================================================================
--- linux/team/sruffell/chan_list_refactoring/drivers/dahdi/dahdi-base.c (original)
+++ linux/team/sruffell/chan_list_refactoring/drivers/dahdi/dahdi-base.c Thu Sep 2 12:41:13 2010
@@ -3676,12 +3676,13 @@
return 0;
}
-static int dahdi_ioctl_getgains(struct file *file, unsigned long data, int unit)
+static int dahdi_ioctl_getgains(struct file *file, unsigned long data)
{
int res = 0;
struct dahdi_gains *gain;
- int i, j;
+ int j;
void __user * const user_data = (void __user *)data;
+ struct dahdi_chan *chan;
gain = kzalloc(sizeof(*gain), GFP_KERNEL);
if (!gain)
@@ -3691,25 +3692,27 @@
res = -EFAULT;
goto cleanup;
}
- i = gain->chan; /* get channel no */
- /* if zero, use current channel no */
- if (!i)
- i = unit;
-
- /* make sure channel number makes sense */
- if ((i < 0) || (i > DAHDI_MAX_CHANNELS) || !chans[i]) {
+ if (!gain->chan) {
+ chan = chan_from_file(file);
+ } else {
+ if (valid_channo(gain->chan))
+ chan = chans[gain->chan];
+ else
+ chan = NULL;
+ }
+ if (chan) {
res = -EINVAL;
goto cleanup;
}
- if (!(chans[i]->flags & DAHDI_FLAG_AUDIO)) {
+ if (!(chan->flags & DAHDI_FLAG_AUDIO)) {
res = -EINVAL;
goto cleanup;
}
- gain->chan = i; /* put the span # in here */
+ gain->chan = chan->channo;
for (j = 0; j < 256; ++j) {
- gain->txgain[j] = chans[i]->txgain[j];
- gain->rxgain[j] = chans[i]->rxgain[j];
+ gain->txgain[j] = chan->txgain[j];
+ gain->rxgain[j] = chan->rxgain[j];
}
if (copy_to_user(user_data, gain, sizeof(*gain))) {
res = -EFAULT;
@@ -3721,15 +3724,16 @@
return res;
}
-static int dahdi_ioctl_setgains(struct file *file, unsigned long data, int unit)
+static int dahdi_ioctl_setgains(struct file *file, unsigned long data)
{
int res = 0;
struct dahdi_gains *gain;
unsigned char *txgain, *rxgain;
- int i, j;
+ int j;
unsigned long flags;
const int GAIN_TABLE_SIZE = sizeof(defgain);
void __user * const user_data = (void __user *)data;
+ struct dahdi_chan *chan;
gain = kzalloc(sizeof(*gain), GFP_KERNEL);
if (!gain)
@@ -3739,16 +3743,21 @@
res = -EFAULT;
goto cleanup;
}
- i = gain->chan; /* get channel no */
- /* if zero, use current channel no */
- if (!i)
- i = unit;
- /* make sure channel number makes sense */
- if ((i < 0) || (i > DAHDI_MAX_CHANNELS) || !chans[i]) {
+
+ if (!gain->chan) {
+ chan = chan_from_file(file);
+ } else {
+ if (valid_channo(gain->chan))
+ chan = chans[gain->chan];
+ else
+ chan = NULL;
+ }
+
+ if (!chan) {
res = -EINVAL;
goto cleanup;
}
- if (!(chans[i]->flags & DAHDI_FLAG_AUDIO)) {
+ if (!(chan->flags & DAHDI_FLAG_AUDIO)) {
res = -EINVAL;
goto cleanup;
}
@@ -3759,7 +3768,7 @@
goto cleanup;
}
- gain->chan = i; /* put the span # in here */
+ gain->chan = chan->channo;
txgain = rxgain + GAIN_TABLE_SIZE;
for (j = 0; j < GAIN_TABLE_SIZE; ++j) {
@@ -3770,22 +3779,22 @@
if (!memcmp(rxgain, defgain, GAIN_TABLE_SIZE) &&
!memcmp(txgain, defgain, GAIN_TABLE_SIZE)) {
kfree(rxgain);
- spin_lock_irqsave(&chans[i]->lock, flags);
- if (chans[i]->gainalloc)
- kfree(chans[i]->rxgain);
- chans[i]->gainalloc = 0;
- chans[i]->rxgain = defgain;
- chans[i]->txgain = defgain;
- spin_unlock_irqrestore(&chans[i]->lock, flags);
+ spin_lock_irqsave(&chan->lock, flags);
+ if (chan->gainalloc)
+ kfree(chan->rxgain);
+ chan->gainalloc = 0;
+ chan->rxgain = defgain;
+ chan->txgain = defgain;
+ spin_unlock_irqrestore(&chan->lock, flags);
} else {
/* This is a custom gain setting */
- spin_lock_irqsave(&chans[i]->lock, flags);
- if (chans[i]->gainalloc)
- kfree(chans[i]->rxgain);
- chans[i]->gainalloc = 1;
- chans[i]->rxgain = rxgain;
- chans[i]->txgain = txgain;
- spin_unlock_irqrestore(&chans[i]->lock, flags);
+ spin_lock_irqsave(&chan->lock, flags);
+ if (chan->gainalloc)
+ kfree(chan->rxgain);
+ chan->gainalloc = 1;
+ chan->rxgain = rxgain;
+ chan->txgain = txgain;
+ spin_unlock_irqrestore(&chan->lock, flags);
}
if (copy_to_user(user_data, gain, sizeof(*gain))) {
@@ -4043,9 +4052,11 @@
case DAHDI_GETGAINS_V1: /* Intentional drop through. */
case DAHDI_GETGAINS: /* get gain stuff */
- return dahdi_ioctl_getgains(file, data, unit);
+ return dahdi_ioctl_getgains(file, data);
+
case DAHDI_SETGAINS: /* set gain stuff */
- return dahdi_ioctl_setgains(file, data, unit);
+ return dahdi_ioctl_setgains(file, data);
+
case DAHDI_SPANSTAT:
size_to_copy = sizeof(struct dahdi_spaninfo);
if (copy_from_user(&stack.spaninfo, user_data, size_to_copy))
More information about the dahdi-commits
mailing list