[svn-commits] sruffell: branch linux/sruffell/dahdi-linux-withidle r7511 - in /linux/team/s...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Fri Nov 6 14:33:31 CST 2009
Author: sruffell
Date: Fri Nov 6 14:33:21 2009
New Revision: 7511
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7511
Log:
voicebus: Add optional sysfs entry for reading a boards current latency.
This is off by default since it hasn't been tested on a full range of kernels,
but can be useful for quickly seeing differences for latencies on different
cards installed in the system.
Modified:
linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/voicebus/voicebus.c
linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/voicebus/voicebus.h
linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/wctdm24xxp/base.c
linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/wcte12xp/base.c
Modified: linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/voicebus/voicebus.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/voicebus/voicebus.c?view=diff&rev=7511&r1=7510&r2=7511
==============================================================================
--- linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/voicebus/voicebus.c (original)
+++ linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/voicebus/voicebus.c Fri Nov 6 14:33:21 2009
@@ -26,6 +26,9 @@
* Free Software Foundation. See the LICENSE file included with
* this program for more details.
*/
+
+/* Set this to allow the voicebus driver to hang some attributes off of the pci
+ * device. */
#include <linux/version.h>
#include <linux/slab.h>
@@ -55,6 +58,11 @@
#else
#define VOICEBUS_ALLOC_FLAGS GFP_ATOMIC
#endif
+
+/* Define CONFIG_VOICEBUS_SYSFS to create some attributes under the pci device.
+ * This is disabled by default because it hasn't been tested on the full range
+ * of supported kernels. */
+#undef CONFIG_VOICEBUS_SYSFS
#if VOICEBUS_DEFERRED == TIMER
#if HZ < 1000
@@ -1039,6 +1047,10 @@
assert(!in_interrupt());
+ WARN_ON(pci_get_drvdata(vb->pdev) != vb);
+ if (pci_get_drvdata(vb->pdev) != vb)
+ return -EFAULT;
+
if (!vb_is_stopped(vb))
return -EBUSY;
@@ -1194,6 +1206,24 @@
}
EXPORT_SYMBOL(voicebus_stop);
+#ifdef CONFIG_VOICEBUS_SYSFS
+static ssize_t
+voicebus_current_latency_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ unsigned long flags;
+ struct voicebus *vb = dev_get_drvdata(dev);
+ unsigned int current_latency;
+ spin_lock_irqsave(&vb->lock, flags);
+ current_latency = vb->min_tx_buffer_count;
+ spin_unlock_irqrestore(&vb->lock, flags);
+ return sprintf(buf, "%d\n", current_latency);
+}
+
+DEVICE_ATTR(voicebus_current_latency, 0444,
+ voicebus_current_latency_show, NULL);
+#endif
+
/*!
* \brief Prepare the interface for module unload.
*
@@ -1207,6 +1237,9 @@
voicebus_release(struct voicebus *vb)
{
assert(!in_interrupt());
+#ifdef CONFIG_VOICEBUS_SYSFS
+ device_remove_file(&vb->pdev->dev, &dev_attr_voicebus_current_latency);
+#endif
/* quiesce the hardware */
voicebus_stop(vb);
@@ -1636,8 +1669,7 @@
* \todo Complete this description.
*/
int
-voicebus_init(struct pci_dev *pdev, u32 framesize,
- const char *board_name,
+voicebus_init(struct pci_dev *pdev, u32 framesize, const char *board_name,
void (*handle_receive)(void *vbb, void *context),
void (*handle_transmit)(void *vbb, void *context),
void *context,
@@ -1667,6 +1699,7 @@
}
memset(vb, 0, sizeof(*vb));
vb->pdev = pdev;
+ pci_set_drvdata(pdev, vb);
voicebus_setdebuglevel(vb, debuglevel);
vb->max_latency = VOICEBUS_DEFAULT_MAXLATENCY;
@@ -1727,7 +1760,16 @@
goto cleanup;
}
-
+#ifdef CONFIG_VOICEBUS_SYSFS
+ dev_dbg(&vb->pdev->dev, "Creating sysfs attributes.\n");
+ retval = device_create_file(&vb->pdev->dev,
+ &dev_attr_voicebus_current_latency);
+ if (retval) {
+ dev_dbg(&vb->pdev->dev,
+ "Failed to create device attributes.\n");
+ goto cleanup;
+ }
+#endif
/* ----------------------------------------------------------------
Configure the hardware / kernel module interfaces.
---------------------------------------------------------------- */
@@ -1842,6 +1884,12 @@
return vb->pdev;
}
EXPORT_SYMBOL(voicebus_get_pci_dev);
+
+void *voicebus_pci_dev_to_context(struct pci_dev *pdev)
+{
+ return ((struct voicebus *)pci_get_drvdata(pdev))->context;
+}
+EXPORT_SYMBOL(voicebus_pci_dev_to_context);
static spinlock_t loader_list_lock;
static struct list_head binary_loader_list;
Modified: linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/voicebus/voicebus.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/voicebus/voicebus.h?view=diff&rev=7511&r1=7510&r2=7511
==============================================================================
--- linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/voicebus/voicebus.h (original)
+++ linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/voicebus/voicebus.h Fri Nov 6 14:33:21 2009
@@ -37,7 +37,8 @@
void voicebus_setdebuglevel(struct voicebus *vb, u32 level);
int voicebus_getdebuglevel(struct voicebus *vb);
-struct pci_dev * voicebus_get_pci_dev(struct voicebus *vb);
+struct pci_dev *voicebus_get_pci_dev(struct voicebus *vb);
+void *voicebus_pci_dev_to_context(struct pci_dev *pdev);
int voicebus_init(struct pci_dev* pdev, u32 framesize,
const char *board_name,
void (*handle_receive)(void *buffer, void *context),
@@ -54,7 +55,7 @@
void voicebus_release(struct voicebus *vb);
int voicebus_start(struct voicebus *vb);
int voicebus_stop(struct voicebus *vb);
-void * voicebus_alloc(struct voicebus* vb);
+void *voicebus_alloc(struct voicebus* vb);
void voicebus_free(struct voicebus *vb, void *vbb);
int voicebus_transmit(struct voicebus *vb, void *vbb);
int voicebus_set_minlatency(struct voicebus *vb, unsigned int milliseconds);
Modified: linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/wctdm24xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/wctdm24xxp/base.c?view=diff&rev=7511&r1=7510&r2=7511
==============================================================================
--- linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/wctdm24xxp/base.c (original)
+++ linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/wctdm24xxp/base.c Fri Nov 6 14:33:21 2009
@@ -3777,13 +3777,8 @@
return -EIO;
}
-
- /* Keep track of which device we are */
- pci_set_drvdata(pdev, wc);
-
voicebus_lock_latency(wc->vb);
- /* Start the hardware processing. */
if (voicebus_start(wc->vb)) {
BUG_ON(1);
}
@@ -3832,7 +3827,7 @@
static void __devexit wctdm_remove_one(struct pci_dev *pdev)
{
- struct wctdm *wc = pci_get_drvdata(pdev);
+ struct wctdm *wc = voicebus_pci_dev_to_context(pdev);
struct vpmadt032 *vpm = wc->vpmadt032;
if (wc) {
Modified: linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/wcte12xp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/wcte12xp/base.c?view=diff&rev=7511&r1=7510&r2=7511
==============================================================================
--- linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/wcte12xp/base.c (original)
+++ linux/team/sruffell/dahdi-linux-withidle/drivers/dahdi/wcte12xp/base.c Fri Nov 6 14:33:21 2009
@@ -1785,8 +1785,6 @@
return res;
}
- /* Keep track of which device we are */
- pci_set_drvdata(pdev, wc);
if (VOICEBUS_DEFAULT_LATENCY != latency) {
voicebus_set_minlatency(wc->vb, latency);
}
@@ -1819,7 +1817,7 @@
static void __devexit te12xp_remove_one(struct pci_dev *pdev)
{
- struct t1 *wc = pci_get_drvdata(pdev);
+ struct t1 *wc = voicebus_pci_dev_to_context(pdev);
#ifdef VPM_SUPPORT
unsigned long flags;
struct vpmadt032 *vpm = wc->vpmadt032;
More information about the svn-commits
mailing list