[svn-commits] sruffell: linux/trunk r8574 - in /linux/trunk/drivers/dahdi: wctdm24xxp/ wcte...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Apr 26 18:29:26 CDT 2010


Author: sruffell
Date: Mon Apr 26 18:29:16 2010
New Revision: 8574

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8574
Log:
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.

Modified:
    linux/trunk/drivers/dahdi/wctdm24xxp/base.c
    linux/trunk/drivers/dahdi/wcte12xp/base.c

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=8574&r1=8573&r2=8574
==============================================================================
--- linux/trunk/drivers/dahdi/wctdm24xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wctdm24xxp/base.c Mon Apr 26 18:29:16 2010
@@ -4594,8 +4594,62 @@
 
 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 @@
 		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 @@
 	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);

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=8574&r1=8573&r2=8574
==============================================================================
--- linux/trunk/drivers/dahdi/wcte12xp/base.c (original)
+++ linux/trunk/drivers/dahdi/wcte12xp/base.c Mon Apr 26 18:29:16 2010
@@ -2112,6 +2112,29 @@
 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,10 +2144,20 @@
 		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);
 }




More information about the svn-commits mailing list