[dahdi-commits] rmeyerriecks: linux/trunk r9102 - /linux/trunk/drivers/dahdi/wct4xxp/base.c

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Fri Aug 6 15:10:37 CDT 2010


Author: rmeyerriecks
Date: Fri Aug  6 15:10:26 2010
New Revision: 9102

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=9102
Log:
wct4xxp: Added card level timing information in sysfs

For kernels >= 2.6.18, each individual card has it's local
timing hung off the pci device in the sysfs tree. dahdi-626

Modified:
    linux/trunk/drivers/dahdi/wct4xxp/base.c

Modified: linux/trunk/drivers/dahdi/wct4xxp/base.c
URL: http://svnview.digium.com/svn/dahdi/linux/trunk/drivers/dahdi/wct4xxp/base.c?view=diff&rev=9102&r1=9101&r2=9102
==============================================================================
--- linux/trunk/drivers/dahdi/wct4xxp/base.c (original)
+++ linux/trunk/drivers/dahdi/wct4xxp/base.c Fri Aug  6 15:10:26 2010
@@ -2267,6 +2267,44 @@
 	__t4_pci_out(wc, WC_DMACTRL, wc->dmactrl);
 }
 
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18))
+static ssize_t t4_timing_master_show(struct device *dev,
+				     struct device_attribute *attr,
+				     char *buf)
+{
+	struct t4 *wc = dev_get_drvdata(dev);
+	if (wc->dmactrl & (1 << 29))
+		return sprintf(buf, "%d\n", wc->syncsrc);
+	else
+		return sprintf(buf, "%d\n", -1);
+}
+
+static DEVICE_ATTR(timing_master, 0400, t4_timing_master_show, NULL);
+
+static void create_sysfs_files(struct t4 *wc)
+{
+        int ret;
+        ret = device_create_file(&wc->dev->dev,
+                                 &dev_attr_timing_master);
+        if (ret) {
+                dev_info(&wc->dev->dev,
+                        "Failed to create device attributes.\n");
+        }
+}
+
+static void remove_sysfs_files(struct t4 *wc)
+{
+        device_remove_file(&wc->dev->dev,
+                           &dev_attr_timing_master);
+}
+
+#else
+
+static inline void create_sysfs_files(struct t4 *wc) { return; }
+static inline void remove_sysfs_files(struct t4 *wc) { return; }
+
+#endif /* LINUX_KERNEL > 2.6.18 */
+
 static inline void __t4_update_timing(struct t4 *wc)
 {
 	int i;
@@ -4744,6 +4782,8 @@
 	t4_pci_out(wc, WC_GPIO, wc->gpio);
 	t4_gpio_setdir(wc, (1 << 17), (1 << 17));
 	t4_gpio_setdir(wc, (0xff), (0xff));
+
+	create_sysfs_files(wc);
 	
 #if 0
 	for (x=0;x<0x10000;x++) {
@@ -4797,6 +4837,8 @@
 	if (!wc) {
 		return;
 	}
+
+	remove_sysfs_files(wc);
 
 	/* Stop hardware */
 	t4_hardware_stop(wc);




More information about the dahdi-commits mailing list