[svn-commits] sruffell: linux/trunk r7522 - in /linux/trunk/drivers/dahdi: voicebus/ wctdm2...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Fri Nov 6 18:35:51 CST 2009
Author: sruffell
Date: Fri Nov 6 18:35:44 2009
New Revision: 7522
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=7522
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/trunk/drivers/dahdi/voicebus/voicebus.c
linux/trunk/drivers/dahdi/voicebus/voicebus.h
linux/trunk/drivers/dahdi/wctdm24xxp/base.c
linux/trunk/drivers/dahdi/wcte12xp/base.c
Modified: linux/trunk/drivers/dahdi/voicebus/voicebus.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/voicebus/voicebus.c?view=diff&rev=7522&r1=7521&r2=7522
==============================================================================
--- linux/trunk/drivers/dahdi/voicebus/voicebus.c (original)
+++ linux/trunk/drivers/dahdi/voicebus/voicebus.c Fri Nov 6 18:35:44 2009
@@ -55,6 +55,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
@@ -1050,6 +1055,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;
@@ -1205,6 +1214,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.
*
@@ -1218,6 +1245,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);
@@ -1674,8 +1704,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,
@@ -1705,6 +1734,7 @@
}
memset(vb, 0, sizeof(*vb));
vb->pdev = pdev;
+ pci_set_drvdata(pdev, vb);
voicebus_setdebuglevel(vb, debuglevel);
vb->max_latency = VOICEBUS_DEFAULT_MAXLATENCY;
@@ -1765,7 +1795,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.
---------------------------------------------------------------- */
@@ -1880,6 +1919,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/trunk/drivers/dahdi/voicebus/voicebus.h
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/voicebus/voicebus.h?view=diff&rev=7522&r1=7521&r2=7522
==============================================================================
--- linux/trunk/drivers/dahdi/voicebus/voicebus.h (original)
+++ linux/trunk/drivers/dahdi/voicebus/voicebus.h Fri Nov 6 18:35:44 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/trunk/drivers/dahdi/wctdm24xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wctdm24xxp/base.c?view=diff&rev=7522&r1=7521&r2=7522
==============================================================================
--- linux/trunk/drivers/dahdi/wctdm24xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wctdm24xxp/base.c Fri Nov 6 18:35:44 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/trunk/drivers/dahdi/wcte12xp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wcte12xp/base.c?view=diff&rev=7522&r1=7521&r2=7522
==============================================================================
--- linux/trunk/drivers/dahdi/wcte12xp/base.c (original)
+++ linux/trunk/drivers/dahdi/wcte12xp/base.c Fri Nov 6 18:35:44 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