summaryrefslogtreecommitdiff
path: root/drivers/dahdi/dahdi-base.c
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2010-09-20 20:33:35 +0000
committerShaun Ruffell <sruffell@digium.com>2010-09-20 20:33:35 +0000
commit164760002ac3e75a15ac10a5cd4ef935a8103071 (patch)
treee23d1ca86cd9582409dcd2a8d0dd8daf90e25b84 /drivers/dahdi/dahdi-base.c
parent0da3171cfd3d2cef1eb03a3aec77e3f4624656ef (diff)
dahdi: Remove the unit parameter from dahdi_chan_ioctl.
This ioctl is called either via the "/dev/dahdi/channel" file or via a /dev/dahdi/channo file. In either case, either the minor number of the device file will match up with a channel, or the "private_data" member on the channel will be set, so the unit is redundant. Review: https://reviewboard.asterisk.org/r/905/ Signed-off-by: Shaun Ruffell <sruffell@digium.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9369 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/dahdi-base.c')
-rw-r--r--drivers/dahdi/dahdi-base.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index c44a9da..19bef19 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -309,7 +309,7 @@ static struct dahdi_dialparams global_dialparams = {
.mfr2_tonelen = DEFAULT_MFR2_LENGTH,
};
-static int dahdi_chan_ioctl(struct file *file, unsigned int cmd, unsigned long data, int unit);
+static int dahdi_chan_ioctl(struct file *file, unsigned int cmd, unsigned long data);
#if defined(CONFIG_DAHDI_MMX) || defined(ECHO_CAN_FP)
#if (defined(CONFIG_X86) && !defined(CONFIG_X86_64)) || defined(CONFIG_I386)
@@ -409,12 +409,31 @@ static rwlock_t zone_lock = RW_LOCK_UNLOCKED;
static rwlock_t chan_lock = RW_LOCK_UNLOCKED;
#endif
+static bool valid_channo(const int channo)
+{
+ return ((channo >= DAHDI_MAX_CHANNELS) || (channo < 1)) ?
+ false : true;
+}
+
+#define VALID_CHANNEL(j) do { \
+ if (!valid_channo(j)) \
+ return -EINVAL; \
+ if (!chans[j]) \
+ return -ENXIO; \
+} while (0)
+
/* Protected by chan_lock. */
static struct dahdi_span *spans[DAHDI_MAX_SPANS];
static struct dahdi_chan *chans[DAHDI_MAX_CHANNELS];
static int maxspans = 0;
+static struct dahdi_chan *chan_from_file(struct file *file)
+{
+ return (file->private_data) ? file->private_data :
+ ((valid_channo(UNIT(file))) ? chans[UNIT(file)] : NULL);
+}
+
static struct dahdi_span *find_span(int spanno)
{
return (spanno > 0 && spanno < DAHDI_MAX_SPANS) ? spans[spanno] : NULL;
@@ -3606,13 +3625,6 @@ void dahdi_alarm_notify(struct dahdi_span *span)
}
}
-#define VALID_CHANNEL(j) do { \
- if ((j >= DAHDI_MAX_CHANNELS) || (j < 1)) \
- return -EINVAL; \
- if (!chans[j]) \
- return -ENXIO; \
-} while(0)
-
static int dahdi_timer_ioctl(struct file *file, unsigned int cmd, unsigned long data, struct dahdi_timer *timer)
{
int j;
@@ -4460,7 +4472,7 @@ static int dahdi_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long da
* call. */
old = file->private_data;
file->private_data = chan;
- res = dahdi_chan_ioctl(file, ind.op, (unsigned long) ind.data, ind.chan);
+ res = dahdi_chan_ioctl(file, ind.op, (unsigned long) ind.data);
file->private_data = old;
return res;
}
@@ -5649,19 +5661,20 @@ static void set_echocan_fax_mode(struct dahdi_chan *chan, unsigned int channo, c
}
}
-static int dahdi_chan_ioctl(struct file *file, unsigned int cmd, unsigned long data, int unit)
+static int dahdi_chan_ioctl(struct file *file, unsigned int cmd, unsigned long data)
{
- struct dahdi_chan *chan = chans[unit];
+ struct dahdi_chan *const chan = chan_from_file(file);
unsigned long flags;
int j, rv;
int ret;
int oldconf;
void *rxgain=NULL;
- WARN_ON(!chan->master);
if (!chan)
return -ENOSYS;
+ WARN_ON(!chan->master);
+
switch(cmd) {
case DAHDI_SETSIGFREEZE:
get_user(j, (int __user *)data);
@@ -6036,7 +6049,7 @@ static int dahdi_chan_ioctl(struct file *file, unsigned int cmd, unsigned long d
break;
#endif
default:
- return dahdi_chanandpseudo_ioctl(file, cmd, data, unit);
+ return dahdi_chanandpseudo_ioctl(file, cmd, data, chan->channo);
}
return 0;
}
@@ -6112,7 +6125,7 @@ static int dahdi_ioctl(struct inode *inode, struct file *file,
if (unit == 254) {
chan = file->private_data;
if (chan)
- ret = dahdi_chan_ioctl(file, cmd, data, chan->channo);
+ ret = dahdi_chan_ioctl(file, cmd, data);
else
ret = dahdi_prechan_ioctl(file, cmd, data, unit);
goto unlock_exit;
@@ -6133,7 +6146,7 @@ static int dahdi_ioctl(struct inode *inode, struct file *file,
goto unlock_exit;
}
- ret = dahdi_chan_ioctl(file, cmd, data, unit);
+ ret = dahdi_chan_ioctl(file, cmd, data);
unlock_exit:
#ifdef HAVE_UNLOCKED_IOCTL