[svn-commits] sruffell: branch linux/sruffell/chan_list_refactoring r9260 - /linux/team/sru...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Thu Sep 2 12:41:02 CDT 2010
Author: sruffell
Date: Thu Sep 2 12:40:51 2010
New Revision: 9260
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9260
Log:
dahdi: Use 'chan' convenience pointer in dahdi_ioctl_chanconfig.
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=9260&r1=9259&r2=9260
==============================================================================
--- 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:40:51 2010
@@ -4194,6 +4194,7 @@
int y;
struct dahdi_chanconfig ch;
struct dahdi_chan *newmaster;
+ struct dahdi_chan *chan;
unsigned long flags;
int sigcap;
@@ -4217,30 +4218,31 @@
} else {
newmaster = chans[ch.chan];
}
- spin_lock_irqsave(&chans[ch.chan]->lock, flags);
+ chan = chans[ch.chan];
+ spin_lock_irqsave(&chan->lock, flags);
#ifdef CONFIG_DAHDI_NET
- if (chans[ch.chan]->flags & DAHDI_FLAG_NETDEV) {
- if (ztchan_to_dev(chans[ch.chan])->flags & IFF_UP) {
- spin_unlock_irqrestore(&chans[ch.chan]->lock, flags);
- module_printk(KERN_WARNING, "Can't switch HDLC net mode on channel %s, since current interface is up\n", chans[ch.chan]->name);
+ if (chan->flags & DAHDI_FLAG_NETDEV) {
+ if (ztchan_to_dev(chan)->flags & IFF_UP) {
+ spin_unlock_irqrestore(&chan->lock, flags);
+ module_printk(KERN_WARNING, "Can't switch HDLC net mode on channel %s, since current interface is up\n", chan->name);
return -EBUSY;
}
- spin_unlock_irqrestore(&chans[ch.chan]->lock, flags);
- unregister_hdlc_device(chans[ch.chan]->hdlcnetdev->netdev);
- spin_lock_irqsave(&chans[ch.chan]->lock, flags);
- free_netdev(chans[ch.chan]->hdlcnetdev->netdev);
- kfree(chans[ch.chan]->hdlcnetdev);
- chans[ch.chan]->hdlcnetdev = NULL;
- chans[ch.chan]->flags &= ~DAHDI_FLAG_NETDEV;
+ spin_unlock_irqrestore(&chan->lock, flags);
+ unregister_hdlc_device(chan->hdlcnetdev->netdev);
+ spin_lock_irqsave(&chan->lock, flags);
+ free_netdev(chan->hdlcnetdev->netdev);
+ kfree(chan->hdlcnetdev);
+ chan->hdlcnetdev = NULL;
+ chan->flags &= ~DAHDI_FLAG_NETDEV;
}
#else
if (ch.sigtype == DAHDI_SIG_HDLCNET) {
- spin_unlock_irqrestore(&chans[ch.chan]->lock, flags);
+ spin_unlock_irqrestore(&chan->lock, flags);
module_printk(KERN_WARNING, "DAHDI networking not supported by this build.\n");
return -ENOSYS;
}
#endif
- sigcap = chans[ch.chan]->sigcap;
+ sigcap = chan->sigcap;
/* If they support clear channel, then they support the HDLC and such through
us. */
if (sigcap & DAHDI_SIG_CLEAR)
@@ -4249,143 +4251,141 @@
if ((sigcap & ch.sigtype) != ch.sigtype)
res = -EINVAL;
- if (chans[ch.chan]->master != chans[ch.chan]) {
- struct dahdi_chan *oldmaster = chans[ch.chan]->master;
+ if (chan->master != chan) {
+ struct dahdi_chan *oldmaster = chan->master;
/* Clear the master channel */
- chans[ch.chan]->master = chans[ch.chan];
- chans[ch.chan]->nextslave = 0;
+ chan->master = chan;
+ chan->nextslave = 0;
/* Unlink this channel from the master's channel list */
recalc_slaves(oldmaster);
}
if (!res) {
- chans[ch.chan]->sig = ch.sigtype;
- if (chans[ch.chan]->sig == DAHDI_SIG_CAS)
- chans[ch.chan]->idlebits = ch.idlebits;
+ chan->sig = ch.sigtype;
+ if (chan->sig == DAHDI_SIG_CAS)
+ chan->idlebits = ch.idlebits;
else
- chans[ch.chan]->idlebits = 0;
+ chan->idlebits = 0;
if ((ch.sigtype & DAHDI_SIG_CLEAR) == DAHDI_SIG_CLEAR) {
/* Set clear channel flag if appropriate */
- chans[ch.chan]->flags &= ~DAHDI_FLAG_AUDIO;
- chans[ch.chan]->flags |= DAHDI_FLAG_CLEAR;
+ chan->flags &= ~DAHDI_FLAG_AUDIO;
+ chan->flags |= DAHDI_FLAG_CLEAR;
} else {
/* Set audio flag and not clear channel otherwise */
- chans[ch.chan]->flags |= DAHDI_FLAG_AUDIO;
- chans[ch.chan]->flags &= ~DAHDI_FLAG_CLEAR;
+ chan->flags |= DAHDI_FLAG_AUDIO;
+ chan->flags &= ~DAHDI_FLAG_CLEAR;
}
if ((ch.sigtype & DAHDI_SIG_HDLCRAW) == DAHDI_SIG_HDLCRAW) {
/* Set the HDLC flag */
- chans[ch.chan]->flags |= DAHDI_FLAG_HDLC;
+ chan->flags |= DAHDI_FLAG_HDLC;
} else {
/* Clear the HDLC flag */
- chans[ch.chan]->flags &= ~DAHDI_FLAG_HDLC;
+ chan->flags &= ~DAHDI_FLAG_HDLC;
}
if ((ch.sigtype & DAHDI_SIG_HDLCFCS) == DAHDI_SIG_HDLCFCS) {
/* Set FCS to be calculated if appropriate */
- chans[ch.chan]->flags |= DAHDI_FLAG_FCS;
+ chan->flags |= DAHDI_FLAG_FCS;
} else {
/* Clear FCS flag */
- chans[ch.chan]->flags &= ~DAHDI_FLAG_FCS;
+ chan->flags &= ~DAHDI_FLAG_FCS;
}
if ((ch.sigtype & __DAHDI_SIG_DACS) == __DAHDI_SIG_DACS) {
/* Setup conference properly */
- chans[ch.chan]->confmode = DAHDI_CONF_DIGITALMON;
- chans[ch.chan]->confna = ch.idlebits;
- res = dahdi_chan_dacs(chans[ch.chan],
+ chan->confmode = DAHDI_CONF_DIGITALMON;
+ chan->confna = ch.idlebits;
+ res = dahdi_chan_dacs(chan,
chans[ch.idlebits]);
} else {
- dahdi_disable_dacs(chans[ch.chan]);
- }
- chans[ch.chan]->master = newmaster;
+ dahdi_disable_dacs(chan);
+ }
+ chan->master = newmaster;
/* Note new slave if we are not our own master */
- if (newmaster != chans[ch.chan]) {
- recalc_slaves(chans[ch.chan]->master);
+ if (newmaster != chan) {
+ recalc_slaves(chan->master);
}
if ((ch.sigtype & DAHDI_SIG_HARDHDLC) == DAHDI_SIG_HARDHDLC) {
- chans[ch.chan]->flags &= ~DAHDI_FLAG_FCS;
- chans[ch.chan]->flags &= ~DAHDI_FLAG_HDLC;
- chans[ch.chan]->flags |= DAHDI_FLAG_NOSTDTXRX;
+ chan->flags &= ~DAHDI_FLAG_FCS;
+ chan->flags &= ~DAHDI_FLAG_HDLC;
+ chan->flags |= DAHDI_FLAG_NOSTDTXRX;
} else {
- chans[ch.chan]->flags &= ~DAHDI_FLAG_NOSTDTXRX;
+ chan->flags &= ~DAHDI_FLAG_NOSTDTXRX;
}
if ((ch.sigtype & DAHDI_SIG_MTP2) == DAHDI_SIG_MTP2)
- chans[ch.chan]->flags |= DAHDI_FLAG_MTP2;
+ chan->flags |= DAHDI_FLAG_MTP2;
else
- chans[ch.chan]->flags &= ~DAHDI_FLAG_MTP2;
- }
-
- if (!res && chans[ch.chan]->span->ops->chanconfig) {
- res = chans[ch.chan]->span->ops->chanconfig(chans[ch.chan],
- ch.sigtype);
- }
+ chan->flags &= ~DAHDI_FLAG_MTP2;
+ }
+
+ if (!res && chan->span->ops->chanconfig)
+ res = chan->span->ops->chanconfig(chan, ch.sigtype);
#ifdef CONFIG_DAHDI_NET
if (!res &&
- (newmaster == chans[ch.chan]) &&
- (chans[ch.chan]->sig == DAHDI_SIG_HDLCNET)) {
- chans[ch.chan]->hdlcnetdev = dahdi_hdlc_alloc();
- if (chans[ch.chan]->hdlcnetdev) {
-/* struct hdlc_device *hdlc = chans[ch.chan]->hdlcnetdev;
+ (newmaster == chan) &&
+ (chan->sig == DAHDI_SIG_HDLCNET)) {
+ chan->hdlcnetdev = dahdi_hdlc_alloc();
+ if (chan->hdlcnetdev) {
+/* struct hdlc_device *hdlc = chan->hdlcnetdev;
struct net_device *d = hdlc_to_dev(hdlc); mmm...get it right later --byg */
- chans[ch.chan]->hdlcnetdev->netdev = alloc_hdlcdev(chans[ch.chan]->hdlcnetdev);
- if (chans[ch.chan]->hdlcnetdev->netdev) {
- chans[ch.chan]->hdlcnetdev->chan = chans[ch.chan];
+ chan->hdlcnetdev->netdev = alloc_hdlcdev(chan->hdlcnetdev);
+ if (chan->hdlcnetdev->netdev) {
+ chan->hdlcnetdev->chan = chan;
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 23)
- SET_MODULE_OWNER(chans[ch.chan]->hdlcnetdev->netdev);
-#endif
- chans[ch.chan]->hdlcnetdev->netdev->irq = chans[ch.chan]->span->irq;
- chans[ch.chan]->hdlcnetdev->netdev->tx_queue_len = 50;
+ SET_MODULE_OWNER(chan->hdlcnetdev->netdev);
+#endif
+ chan->hdlcnetdev->netdev->irq = chan->span->irq;
+ chan->hdlcnetdev->netdev->tx_queue_len = 50;
#ifdef HAVE_NET_DEVICE_OPS
- chans[ch.chan]->hdlcnetdev->netdev->netdev_ops = &dahdi_netdev_ops;
+ chan->hdlcnetdev->netdev->netdev_ops = &dahdi_netdev_ops;
#else
- chans[ch.chan]->hdlcnetdev->netdev->do_ioctl = dahdi_net_ioctl;
- chans[ch.chan]->hdlcnetdev->netdev->open = dahdi_net_open;
- chans[ch.chan]->hdlcnetdev->netdev->stop = dahdi_net_stop;
-#endif
- dev_to_hdlc(chans[ch.chan]->hdlcnetdev->netdev)->attach = dahdi_net_attach;
- dev_to_hdlc(chans[ch.chan]->hdlcnetdev->netdev)->xmit = dahdi_xmit;
- spin_unlock_irqrestore(&chans[ch.chan]->lock, flags);
+ chan->hdlcnetdev->netdev->do_ioctl = dahdi_net_ioctl;
+ chan->hdlcnetdev->netdev->open = dahdi_net_open;
+ chan->hdlcnetdev->netdev->stop = dahdi_net_stop;
+#endif
+ dev_to_hdlc(chan->hdlcnetdev->netdev)->attach = dahdi_net_attach;
+ dev_to_hdlc(chan->hdlcnetdev->netdev)->xmit = dahdi_xmit;
+ spin_unlock_irqrestore(&chan->lock, flags);
/* Briefly restore interrupts while we register the device */
- res = dahdi_register_hdlc_device(chans[ch.chan]->hdlcnetdev->netdev, ch.netdev_name);
- spin_lock_irqsave(&chans[ch.chan]->lock, flags);
+ res = dahdi_register_hdlc_device(chan->hdlcnetdev->netdev, ch.netdev_name);
+ spin_lock_irqsave(&chan->lock, flags);
} else {
module_printk(KERN_NOTICE, "Unable to allocate hdlc: *shrug*\n");
res = -1;
}
if (!res)
- chans[ch.chan]->flags |= DAHDI_FLAG_NETDEV;
+ chan->flags |= DAHDI_FLAG_NETDEV;
} else {
module_printk(KERN_NOTICE, "Unable to allocate netdev: out of memory\n");
res = -1;
}
}
#endif
- if ((chans[ch.chan]->sig == DAHDI_SIG_HDLCNET) &&
- (chans[ch.chan] == newmaster) &&
- !(chans[ch.chan]->flags & DAHDI_FLAG_NETDEV))
- module_printk(KERN_NOTICE, "Unable to register HDLC device for channel %s\n", chans[ch.chan]->name);
+ if ((chan->sig == DAHDI_SIG_HDLCNET) &&
+ (chan == newmaster) &&
+ !(chan->flags & DAHDI_FLAG_NETDEV))
+ module_printk(KERN_NOTICE, "Unable to register HDLC device for channel %s\n", chan->name);
if (!res) {
/* Setup default law */
- chans[ch.chan]->deflaw = ch.deflaw;
+ chan->deflaw = ch.deflaw;
/* Copy back any modified settings */
- spin_unlock_irqrestore(&chans[ch.chan]->lock, flags);
+ spin_unlock_irqrestore(&chan->lock, flags);
if (copy_to_user((void __user *)data, &ch, sizeof(ch)))
return -EFAULT;
- spin_lock_irqsave(&chans[ch.chan]->lock, flags);
+ spin_lock_irqsave(&chan->lock, flags);
/* And hangup */
- dahdi_hangup(chans[ch.chan]);
- y = dahdi_q_sig(chans[ch.chan]) & 0xff;
+ dahdi_hangup(chan);
+ y = dahdi_q_sig(chan) & 0xff;
if (y >= 0)
- chans[ch.chan]->rxsig = (unsigned char) y;
- chans[ch.chan]->rxhooksig = DAHDI_RXSIG_INITIAL;
+ chan->rxsig = (unsigned char) y;
+ chan->rxhooksig = DAHDI_RXSIG_INITIAL;
}
#ifdef CONFIG_DAHDI_DEBUG
- module_printk(KERN_NOTICE, "Configured channel %s, flags %04lx, sig %04x\n", chans[ch.chan]->name, chans[ch.chan]->flags, chans[ch.chan]->sig);
-#endif
- spin_unlock_irqrestore(&chans[ch.chan]->lock, flags);
+ module_printk(KERN_NOTICE, "Configured channel %s, flags %04lx, sig %04x\n", chan->name, chan->flags, chan->sig);
+#endif
+ spin_unlock_irqrestore(&chan->lock, flags);
return res;
}
More information about the svn-commits
mailing list