diff options
author | Shaun Ruffell <sruffell@digium.com> | 2010-04-26 23:29:15 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2010-04-26 23:29:15 +0000 |
commit | 5d837276b92814ca1eb6c138ee575aeb617012b6 (patch) | |
tree | 11288ba69809a90646e40984160bfbeb3352edde /drivers/dahdi/wcte12xp/base.c | |
parent | 6c1f6af1b0d9263aa8f1fec21d951798e573a13c (diff) |
wcte12xp: Add the voicebus_current_latency sysfs node.
'voicebus_current_latency' is only exported when CONFIG_VOICEBUS_SYSFS is
defined in voicebus.h. This is a debugging aide which enables determing the
board specific latency without parsing through the kernel logs.
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@8573 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/wcte12xp/base.c')
-rw-r--r-- | drivers/dahdi/wcte12xp/base.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c index e5cd7cc..42a7341 100644 --- a/drivers/dahdi/wcte12xp/base.c +++ b/drivers/dahdi/wcte12xp/base.c @@ -2095,6 +2095,48 @@ static const struct voicebus_operations voicebus_operations = { .handle_error = t1_handle_error, }; +#ifdef CONFIG_VOICEBUS_SYSFS +static ssize_t voicebus_current_latency_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + unsigned long flags; + struct t1 *wc = dev_get_drvdata(dev); + unsigned int current_latency; + spin_lock_irqsave(&wc->vb.lock, flags); + current_latency = wc->vb.min_tx_buffer_count; + spin_unlock_irqrestore(&wc->vb.lock, flags); + return sprintf(buf, "%d\n", current_latency); +} + +static DEVICE_ATTR(voicebus_current_latency, 0400, + voicebus_current_latency_show, NULL); + +static void create_sysfs_files(struct t1 *wc) +{ + int ret; + ret = device_create_file(&wc->vb.pdev->dev, + &dev_attr_voicebus_current_latency); + if (ret) { + dev_info(&wc->vb.pdev->dev, + "Failed to create device attributes.\n"); + } +} + +static void remove_sysfs_files(struct t1 *wc) +{ + device_remove_file(&wc->vb.pdev->dev, + &dev_attr_voicebus_current_latency); +} + +#else + +static inline void create_sysfs_files(struct t1 *wc) { return; } +static inline void remove_sysfs_files(struct t1 *wc) { return; } + +#endif /* CONFIG_VOICEBUS_SYSFS */ + + static int __devinit te12xp_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) { struct t1 *wc; @@ -2173,6 +2215,8 @@ static int __devinit te12xp_init_one(struct pci_dev *pdev, const struct pci_devi voicebus_set_maxlatency(&wc->vb, max_latency); max_latency = wc->vb.max_latency; + create_sysfs_files(wc); + voicebus_lock_latency(&wc->vb); if (voicebus_start(&wc->vb)) { voicebus_release(&wc->vb); @@ -2212,6 +2256,8 @@ static void __devexit te12xp_remove_one(struct pci_dev *pdev) if (!wc) return; + remove_sysfs_files(wc); + clear_bit(INITIALIZED, &wc->bit_flags); del_timer_sync(&wc->timer); |