[svn-commits] sruffell: linux/trunk r9369 - /linux/trunk/drivers/dahdi/dahdi-base.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Sep 20 15:33:39 CDT 2010
Author: sruffell
Date: Mon Sep 20 15:33:35 2010
New Revision: 9369
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9369
Log:
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 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=9369&r1=9368&r2=9369
==============================================================================
--- linux/trunk/drivers/dahdi/dahdi-base.c (original)
+++ linux/trunk/drivers/dahdi/dahdi-base.c Mon Sep 20 15:33:35 2010
@@ -309,7 +309,7 @@
.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,11 +409,30 @@
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)
{
@@ -3606,13 +3625,6 @@
}
}
-#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 @@
* 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,18 +5661,19 @@
}
}
-static int dahdi_chan_ioctl(struct file *file, unsigned int cmd, unsigned long data, int unit)
-{
- struct dahdi_chan *chan = chans[unit];
+static int dahdi_chan_ioctl(struct file *file, unsigned int cmd, unsigned long data)
+{
+ 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:
@@ -6036,7 +6049,7 @@
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 @@
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 @@
goto unlock_exit;
}
- ret = dahdi_chan_ioctl(file, cmd, data, unit);
+ ret = dahdi_chan_ioctl(file, cmd, data);
unlock_exit:
#ifdef HAVE_UNLOCKED_IOCTL
More information about the svn-commits
mailing list