diff options
author | Shaun Ruffell <sruffell@digium.com> | 2010-04-26 23:29:16 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2010-04-26 23:29:16 +0000 |
commit | a7fcb5ecea3f415a8398ec04961f989a18017b0c (patch) | |
tree | 067e1d2c4c6c32be5cd6df0499424654a69a73d6 /drivers/dahdi | |
parent | 83ba77163a3e206c086dd945991f134de939c6ec (diff) |
wcte12xp, wctdm24xxp: Add vpm_firmware_version sysfs attribute.
Currently only exported if CONFIG_VOICEBUS_SYSFS is defined in
drivers/dahdi/voicebus.h. Reading from the 'vpm_firmware_version' attribute
will poll the firmware on the VPMADT032 for it's current version.
git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@8574 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi')
-rw-r--r-- | drivers/dahdi/wctdm24xxp/base.c | 74 | ||||
-rw-r--r-- | drivers/dahdi/wcte12xp/base.c | 33 |
2 files changed, 94 insertions, 13 deletions
diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c index 97d77d2..16e3a28 100644 --- a/drivers/dahdi/wctdm24xxp/base.c +++ b/drivers/dahdi/wctdm24xxp/base.c @@ -4594,8 +4594,62 @@ voicebus_current_latency_show(struct device *dev, static DEVICE_ATTR(voicebus_current_latency, 0400, voicebus_current_latency_show, NULL); -#endif +static ssize_t vpm_firmware_version_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int res; + u16 version = 0; + struct wctdm *wc = dev_get_drvdata(dev); + + if (wc->vpmadt032) { + res = gpakPingDsp(wc->vpmadt032->dspid, &version); + if (res) { + dev_info(&wc->vb.pdev->dev, "Failed gpakPingDsp %d\n", res); + version = -1; + } + } + + return sprintf(buf, "%x.%02x\n", (version & 0xff00) >> 8, (version & 0xff)); +} + +static DEVICE_ATTR(vpm_firmware_version, 0400, + vpm_firmware_version_show, NULL); + +static void create_sysfs_files(struct wctdm *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"); + } + + ret = device_create_file(&wc->vb.pdev->dev, + &dev_attr_vpm_firmware_version); + if (ret) { + dev_info(&wc->vb.pdev->dev, + "Failed to create device attributes.\n"); + } +} + +static void remove_sysfs_files(struct wctdm *wc) +{ + device_remove_file(&wc->vb.pdev->dev, + &dev_attr_vpm_firmware_version); + + device_remove_file(&wc->vb.pdev->dev, + &dev_attr_voicebus_current_latency); +} + +#else + +static inline void create_sysfs_files(struct wctdm *wc) { return; } +static inline void remove_sysfs_files(struct wctdm *wc) { return; } + +#endif /* CONFIG_VOICEBUS_SYSFS */ #ifdef USE_ASYNC_INIT struct async_data { @@ -4661,14 +4715,9 @@ __wctdm_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) return ret; } -#ifdef CONFIG_VOICEBUS_SYSFS - 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"); - } -#endif + + create_sysfs_files(wc); + voicebus_lock_latency(&wc->vb); init_waitqueue_head(&wc->regq); @@ -4890,12 +4939,11 @@ static void __devexit wctdm_remove_one(struct pci_dev *pdev) struct vpmadt032 *vpm = wc->vpmadt032; int i; -#ifdef CONFIG_VOICEBUS_SYSFS - device_remove_file(&wc->vb.pdev->dev, - &dev_attr_voicebus_current_latency); -#endif if (wc) { + + remove_sysfs_files(wc); + if (vpm) { clear_bit(VPM150M_DTMFDETECT, &vpm->control); clear_bit(VPM150M_ACTIVE, &vpm->control); diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c index 42a7341..802f832 100644 --- a/drivers/dahdi/wcte12xp/base.c +++ b/drivers/dahdi/wcte12xp/base.c @@ -2112,6 +2112,29 @@ static ssize_t voicebus_current_latency_show(struct device *dev, static DEVICE_ATTR(voicebus_current_latency, 0400, voicebus_current_latency_show, NULL); + +static ssize_t vpm_firmware_version_show(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int res; + u16 version = 0; + struct t1 *wc = dev_get_drvdata(dev); + + if (wc->vpmadt032) { + res = gpakPingDsp(wc->vpmadt032->dspid, &version); + if (res) { + t1_info(wc, "Failed gpakPingDsp %d\n", res); + version = -1; + } + } + + return sprintf(buf, "%x.%02x\n", (version & 0xff00) >> 8, (version & 0xff)); +} + +static DEVICE_ATTR(vpm_firmware_version, 0400, + vpm_firmware_version_show, NULL); + static void create_sysfs_files(struct t1 *wc) { int ret; @@ -2121,11 +2144,21 @@ static void create_sysfs_files(struct t1 *wc) dev_info(&wc->vb.pdev->dev, "Failed to create device attributes.\n"); } + + ret = device_create_file(&wc->vb.pdev->dev, + &dev_attr_vpm_firmware_version); + 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_vpm_firmware_version); + + device_remove_file(&wc->vb.pdev->dev, &dev_attr_voicebus_current_latency); } |