[svn-commits] tzafrir: branch tzafrir/sysfs r3497 - in /team/tzafrir/sysfs: ./ xpp/ xpp/uti...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Sun Dec 16 20:04:34 CST 2007


Author: tzafrir
Date: Sun Dec 16 20:04:34 2007
New Revision: 3497

URL: http://svn.digium.com/view/zaptel?view=rev&rev=3497
Log:
* Add a "conector" field to the span.
* Add a standard function to fill PCI data from span and device.
* Use the connector field to link between devices and spans in
  zaptel_hardware.
* Make wcfxo detect the clone I have at home.

Modified:
    team/tzafrir/sysfs/wcfxo.c
    team/tzafrir/sysfs/xpp/utils/zaptel_hardware
    team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Hardware/PCI.pm
    team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Span.pm
    team/tzafrir/sysfs/xpp/xpp_zap.c
    team/tzafrir/sysfs/zaptel-sysfs.c
    team/tzafrir/sysfs/zaptel.h

Modified: team/tzafrir/sysfs/wcfxo.c
URL: http://svn.digium.com/view/zaptel/team/tzafrir/sysfs/wcfxo.c?view=diff&rev=3497&r1=3496&r2=3497
==============================================================================
--- team/tzafrir/sysfs/wcfxo.c (original)
+++ team/tzafrir/sysfs/wcfxo.c Sun Dec 16 20:04:34 2007
@@ -627,8 +627,7 @@
 	sprintf(wc->span.name, "WCFXO/%d", wc->pos);
 	snprintf(wc->span.desc, sizeof(wc->span.desc) - 1, "%s Board %d", wc->variety, wc->pos + 1);
 	sprintf(wc->chan.name, "WCFXO/%d/%d", wc->pos, 0);
-	snprintf(wc->span.location, sizeof(wc->span.location) - 1,
-		 "PCI Bus %02d Slot %02d", wc->dev->bus->number, PCI_SLOT(wc->dev->devfn) + 1);
+	zt_fill_data_pci(&wc->span, wc->dev);
 	wc->span.manufacturer = "Digium";
 	strncpy(wc->span.devicetype, wc->variety, sizeof(wc->span.devicetype) - 1);
 	wc->chan.sigcap = ZT_SIG_FXSKS | ZT_SIG_FXSLS | ZT_SIG_SF;
@@ -636,7 +635,6 @@
 	wc->span.chans = &wc->chan;
 	wc->span.channels = 1;
 	wc->span.hooksig = wcfxo_hooksig;
-	wc->span.irq = wc->dev->irq;
 	wc->span.open = wcfxo_open;
 	wc->span.close = wcfxo_close;
 	wc->span.flags = ZT_FLAG_RBS;
@@ -979,6 +977,7 @@
 }
 
 static struct pci_device_id wcfxo_pci_tbl[] = {
+	{ 0xe159, 0x0001, 0x8084, PCI_ANY_ID, 0, 0, (unsigned long) &generic },
 	{ 0xe159, 0x0001, 0x8085, PCI_ANY_ID, 0, 0, (unsigned long) &wcx101p },
 	{ 0xe159, 0x0001, 0x8086, PCI_ANY_ID, 0, 0, (unsigned long) &generic },
 	{ 0xe159, 0x0001, 0x8087, PCI_ANY_ID, 0, 0, (unsigned long) &generic },

Modified: team/tzafrir/sysfs/xpp/utils/zaptel_hardware
URL: http://svn.digium.com/view/zaptel/team/tzafrir/sysfs/xpp/utils/zaptel_hardware?view=diff&rev=3497&r1=3496&r2=3497
==============================================================================
--- team/tzafrir/sysfs/xpp/utils/zaptel_hardware (original)
+++ team/tzafrir/sysfs/xpp/utils/zaptel_hardware Sun Dec 16 20:04:34 2007
@@ -63,6 +63,11 @@
 	$driver = "$driver" . (($loaded) ? "+" : "-");
 	my $description = $dev->description || "";
 	printf $format, $dev->hardware_name, $driver, $dev->vendor, $dev->product, $description;
+	my @spans_dev = grep {defined($_->device_path) && $_->bus_type.':'.$_->device_path eq $dev->hardware_name} 
+		@spans;
+	foreach my $span (@spans_dev) {
+		print "\tSpan: ". $span->num . $span->name. "\n";
+	}
 	if(!$xbus) {
 		next;
 	}

Modified: team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Hardware/PCI.pm
URL: http://svn.digium.com/view/zaptel/team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Hardware/PCI.pm?view=diff&rev=3497&r1=3496&r2=3497
==============================================================================
--- team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Hardware/PCI.pm (original)
+++ team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Hardware/PCI.pm Sun Dec 16 20:04:34 2007
@@ -45,9 +45,10 @@
 	'e159:0001/e16b'	=> { DRIVER => 'pciradio', DESCRIPTION => 'PCIRADIO' },
 
 	# from wcfxo
+	'e159:0001/8084'	=> { DRIVER => 'wcfxo', DESCRIPTION => 'Wildcard X101P Clone' },
 	'e159:0001/8085'	=> { DRIVER => 'wcfxo', DESCRIPTION => 'Wildcard X101P' },
-	'e159:0001/8086'	=> { DRIVER => 'wcfxo', DESCRIPTION => 'Generic Clone' },
-	'e159:0001/8087'	=> { DRIVER => 'wcfxo', DESCRIPTION => 'Generic Clone' },
+	'e159:0001/8086'	=> { DRIVER => 'wcfxo', DESCRIPTION => 'Wildcard X100P Clone' },
+	'e159:0001/8087'	=> { DRIVER => 'wcfxo', DESCRIPTION => 'Wildcard X100P Clone' },
 	'1057:5608'		=> { DRIVER => 'wcfxo', DESCRIPTION => 'Wildcard X100P' },
 
 	# from wct1xxp
@@ -193,6 +194,7 @@
 			);
 		push(@devices, $d);
 	}
+
 }
 
 1;

Modified: team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Span.pm
URL: http://svn.digium.com/view/zaptel/team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Span.pm?view=diff&rev=3497&r1=3496&r2=3497
==============================================================================
--- team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Span.pm (original)
+++ team/tzafrir/sysfs/xpp/utils/zconf/Zaptel/Span.pm Sun Dec 16 20:04:34 2007
@@ -73,6 +73,8 @@
 	$self->{TYPE} = "UNKNOWN";
 	my $sysfs_dir = sprintf("$sysfs_base/span-%02d", $num);
 	if ( -d $sysfs_dir ) {
+		$self->{CONNECTOR} = 
+			_read_one_line_file("$sysfs_dir/connector");
 		$self->{CODING} = 
 			_read_one_line_file("$sysfs_dir/digital_coding");
 		$self->{FRAMING} = 
@@ -83,6 +85,12 @@
 			_read_one_line_file("$sysfs_dir/sync_master");
 		$self->{NAME} = 
 			_read_one_line_file("$sysfs_dir/name");
+		my ($bus_type,$device_path) = split(/-/, $self->connector, 2);
+		if (defined $device_path) {
+			$self->{BUS_TYPE} = $bus_type;
+			$self->{DEVICE_PATH} = $device_path;
+		}
+
 	}
 	open(F, "$proc_base/$num") or die "Failed to open '$proc_base/$num\n";
 	my $head = <F>;

Modified: team/tzafrir/sysfs/xpp/xpp_zap.c
URL: http://svn.digium.com/view/zaptel/team/tzafrir/sysfs/xpp/xpp_zap.c?view=diff&rev=3497&r1=3496&r2=3497
==============================================================================
--- team/tzafrir/sysfs/xpp/xpp_zap.c (original)
+++ team/tzafrir/sysfs/xpp/xpp_zap.c Sun Dec 16 20:04:34 2007
@@ -1684,6 +1684,8 @@
 
 	span = &xpd->span;
 	snprintf(span->name, MAX_SPANNAME, "%s/%s", xbus->busname, xpd->xpdname);
+	snprintf(span->location,  sizeof(span->location),  "%s", xbus->busdesc);
+	snprintf(span->connector, sizeof(span->connector), "%s", xbus->busdesc);
 	span->deflaw = ZT_LAW_MULAW;
 	init_waitqueue_head(&span->maintq);
 	span->pvt = xpd;

Modified: team/tzafrir/sysfs/zaptel-sysfs.c
URL: http://svn.digium.com/view/zaptel/team/tzafrir/sysfs/zaptel-sysfs.c?view=diff&rev=3497&r1=3496&r2=3497
==============================================================================
--- team/tzafrir/sysfs/zaptel-sysfs.c (original)
+++ team/tzafrir/sysfs/zaptel-sysfs.c Sun Dec 16 20:04:34 2007
@@ -180,6 +180,13 @@
 }
 
 /*--------- Sysfs Device handling ----*/
+static DEVICE_ATTR_FUNC(connector_show, dev, buf)
+{
+	struct zt_span *span = dev_to_span(dev);
+	return snprintf(buf, PAGE_SIZE, "%s\n", span->connector);
+}
+static	DEVICE_ATTR(connector, S_IRUGO, connector_show, NULL);
+
 static DEVICE_ATTR_FUNC(digital_coding_show, dev, buf)
 {
 	struct	zt_span *span = dev_to_span(dev);
@@ -243,6 +250,7 @@
 	BUG_ON(!span);
 	zap_dbg_span(span, "\n");
 	device = &span->device;
+	device_remove_file(&span->device, &dev_attr_connector);
 	device_remove_file(&span->device, &dev_attr_digital_coding);
 	device_remove_file(&span->device, &dev_attr_digital_framing);
 	device_remove_file(&span->device, &dev_attr_flags);
@@ -276,6 +284,7 @@
 		zap_err_span(span, "%s: device_add failed: %d\n", __FUNCTION__, ret);
 		goto out;
 	}
+	span_add_attribute(connector);
 	span_add_attribute(digital_coding);
 	span_add_attribute(digital_framing);
 	span_add_attribute(flags);
@@ -367,4 +376,43 @@
 	return ret;
 }
 
-
+#include <linux/pci.h>
+#include <linux/usb.h>
+
+/*! Fill the PCI-specific fields in a zaptel span. 
+ * @span the span in which to fill the fields
+ * @dev the PCI device from which to fill details.
+ *
+ * Caller should have an exclusive access to span (e.g: hold lock).
+ */
+void zt_fill_data_pci(struct zt_span *span, struct pci_dev *dev) {
+	snprintf(span->location, sizeof(span->location) - 1,
+		 "PCI Bus %02d Slot %02d", dev->bus->number, PCI_SLOT(dev->devfn) + 1);
+	snprintf(span->connector, sizeof(span->connector) - 1,
+			"pci-%04x:%02x:%02x.%x", 
+			pci_domain_nr(dev->bus), dev->bus->number, 
+			PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)
+		);
+	span->irq = dev->irq;
+}
+
+
+/*! Fill the USB-specific fields in a zaptel span. 
+ * @span the span in which to fill the fields
+ * @dev the PCI device from which to fill details.
+ *
+ * Caller should have an exclusive access to span (e.g: hold lock).
+ */
+void zt_fill_data_usb(struct zt_span *span, struct usb_device *dev) {
+	char buf[80];
+
+	usb_make_path(dev, buf, sizeof(buf));
+	snprintf(span->location, sizeof(span->location) - 1, "USB %s", buf);
+	snprintf(span->connector, sizeof(span->connector) - 1, "usb:%s", buf);
+	span->irq = 0;
+}
+
+#include <linux/usb.h>
+
+EXPORT_SYMBOL(zt_fill_data_pci);
+EXPORT_SYMBOL(zt_fill_data_usb);

Modified: team/tzafrir/sysfs/zaptel.h
URL: http://svn.digium.com/view/zaptel/team/tzafrir/sysfs/zaptel.h?view=diff&rev=3497&r1=3496&r2=3497
==============================================================================
--- team/tzafrir/sysfs/zaptel.h (original)
+++ team/tzafrir/sysfs/zaptel.h Sun Dec 16 20:04:34 2007
@@ -1440,6 +1440,7 @@
 	const char *manufacturer;	/* span's device manufacturer */
 	char devicetype[80];		/* span's device type */
 	char location[40];		/* span device's location in system */
+	char connector[40];		/* span device's location in system */
 	int deflaw;			/* Default law (ZT_MULAW or ZT_ALAW) */
 	int alarms;			/* Pending alarms on span */
 	int flags;
@@ -1550,6 +1551,16 @@
 	int watchstate;
 #endif	
 };
+
+/* The following functions will only be included if usb.h/pci.h is 
+ * already loaded.
+ */
+#ifdef LINUX_PCI_H
+void zt_fill_data_pci(struct zt_span *span, struct pci_dev *dev);
+#endif
+#ifdef __LINUX_USB_H
+void zt_fill_data_usb(struct zt_span *span, struct usb_device *dev);
+#endif
 
 struct zt_transcoder_channel {
 	void *pvt;




More information about the svn-commits mailing list