[svn-commits] sruffell: branch linux/sruffell/chan_list_refactoring r9274 - /linux/team/sru...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Sep 2 12:41:18 CDT 2010
Author: sruffell
Date: Thu Sep 2 12:41:07 2010
New Revision: 9274
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9274
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.
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=9274&r1=9273&r2=9274
==============================================================================
--- 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:07 2010
@@ -310,7 +310,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)
@@ -410,11 +410,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)
{
@@ -3634,19 +3653,6 @@
}
}
}
-
-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)
static int dahdi_timer_ioctl(struct file *file, unsigned int cmd, unsigned long data, struct dahdi_timer *timer)
{
@@ -5647,18 +5653,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:
@@ -6034,7 +6041,7 @@
break;
#endif
default:
- return dahdi_chanandpseudo_ioctl(file, cmd, data, unit);
+ return dahdi_chanandpseudo_ioctl(file, cmd, data, chan->channo);
}
return 0;
}
@@ -6110,7 +6117,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;
@@ -6131,7 +6138,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