[svn-commits] tzafrir: tools/trunk r5099 - in /tools/trunk: ./ xpp/ xpp/perl_modules/Dahdi/...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Oct 16 13:03:47 CDT 2008


Author: tzafrir
Date: Thu Oct 16 13:03:47 2008
New Revision: 5099

URL: http://svn.digium.com/view/dahdi?view=rev&rev=5099
Log:
xpp: userspace support for sysfx migration.

The userspace side of dahdi-linux r5097.

* Perl modules default to using xpp sysfs but will fallback (with warning)
  to procfs interface.
* An additional /usr/share/dahdi/waitfor_xpds to replace the line in the
  init.d script.

Added:
    tools/trunk/xpp/waitfor_xpds   (with props)
Modified:
    tools/trunk/dahdi.init
    tools/trunk/xpp/Makefile
    tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm
    tools/trunk/xpp/perl_modules/Dahdi/Xpp/Line.pm
    tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xpd.pm

Modified: tools/trunk/dahdi.init
URL: http://svn.digium.com/view/dahdi/tools/trunk/dahdi.init?view=diff&rev=5099&r1=5098&r2=5099
==============================================================================
--- tools/trunk/dahdi.init (original)
+++ tools/trunk/dahdi.init Thu Oct 16 13:03:47 2008
@@ -76,9 +76,8 @@
 	# do nothing if there are no astribank devices:
 	if ! grep -q connected /proc/xpp/xbuses 2>/dev/null; then return 0; fi
 
-	echo "Waiting for Astribank devices to initialize:"
-	cat /proc/xpp/XBUS-[0-9]*/waitfor_xpds 2>/dev/null || true
-	
+	if ! /usr/share/dahdi/waitfor_xpds; then return 0; fi
+
 	# overriding locales for the above two, as perl can be noisy
 	# when locales are missing.
 	# No register all the devices if they didn't auto-register:

Modified: tools/trunk/xpp/Makefile
URL: http://svn.digium.com/view/dahdi/tools/trunk/xpp/Makefile?view=diff&rev=5099&r1=5098&r2=5099
==============================================================================
--- tools/trunk/xpp/Makefile (original)
+++ tools/trunk/xpp/Makefile Thu Oct 16 13:03:47 2008
@@ -75,6 +75,7 @@
 	$(INSTALL) $(PROG_INSTALL) $(DESTDIR)$(SBINDIR)/
 	$(INSTALL) -d $(DESTDIR)$(DATADIR)
 	$(INSTALL) xpp_fxloader $(DESTDIR)$(DATADIR)/
+	$(INSTALL) waitfor_xpds $(DESTDIR)$(DATADIR)/
 	$(INSTALL) -d $(DESTDIR)$(MANDIR)
 	$(INSTALL_DATA) $(MAN_INSTALL) $(DESTDIR)$(MANDIR)/
 	$(INSTALL) -d $(DESTDIR)$(HOTPLUG_USB_DIR)

Modified: tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm
URL: http://svn.digium.com/view/dahdi/tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm?view=diff&rev=5099&r1=5098&r2=5099
==============================================================================
--- tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm (original)
+++ tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm Thu Oct 16 13:03:47 2008
@@ -31,6 +31,38 @@
 
 
 my $proc_base = "/proc/xpp";
+
+sub xpd_attr_path($$$@) {
+	my ($busnum, $unitnum, $subunitnum, @attr) = @_;
+	foreach my $attr (@attr) {
+		my $file = sprintf "/sys/bus/xpds/devices/%02d:%1d:%1d/$attr",
+		   $busnum, $unitnum, $subunitnum;
+		unless(-f $file) {
+			my $procfile = sprintf "/proc/xpp/XBUS-%02d/XPD-%1d%1d/$attr",
+			   $busnum, $unitnum, $subunitnum;
+			warn "$0: OLD DRIVER: missing '$file'. Fall back to '$procfile'\n";
+			$file = $procfile;
+		}
+		next unless -f $file;
+		return $file;
+	}
+	return undef;
+}
+
+sub xbus_attr_path($$) {
+	my ($busnum, @attr) = @_;
+	foreach my $attr (@attr) {
+		my $file = sprintf "/sys/bus/astribanks/devices/xbus-%02d/$attr", $busnum;
+		unless(-f $file) {
+			my $procfile = sprintf "/proc/xpp/XBUS-%02d/$attr", $busnum;
+			warn "$0: OLD DRIVER: missing '$file'. Fall back to '$procfile'\n";
+			$file = $procfile;
+		}
+		next unless -f $file;
+		return $file;
+	}
+	return undef;
+}
 
 # Nominal sorters for xbuses
 sub by_name {

Modified: tools/trunk/xpp/perl_modules/Dahdi/Xpp/Line.pm
URL: http://svn.digium.com/view/dahdi/tools/trunk/xpp/perl_modules/Dahdi/Xpp/Line.pm?view=diff&rev=5099&r1=5098&r2=5099
==============================================================================
--- tools/trunk/xpp/perl_modules/Dahdi/Xpp/Line.pm (original)
+++ tools/trunk/xpp/perl_modules/Dahdi/Xpp/Line.pm Thu Oct 16 13:03:47 2008
@@ -9,8 +9,6 @@
 #
 use strict;
 use Dahdi::Utils;
-
-my $proc_base = "/proc/xpp";
 
 sub new($$$) {
 	my $pack = shift or die "Wasn't called as a class method\n";
@@ -29,14 +27,17 @@
 	my $on = shift;
 	my $xpd = $self->xpd;
 	my $result;
-
-	my $file = "$proc_base/" . $xpd->fqn . "/blink";
+	my $file = Dahdi::Xpp::xpd_attr_path(
+			$xpd->xbus->num,
+			$xpd->unit,
+			$xpd->subunit, "blink");
 	die "$file is missing" unless -f $file;
 	# First query
 	open(F, "$file") or die "Failed to open $file for reading: $!";
 	$result = <F>;
 	chomp $result;
 	close F;
+	$result = hex($result);
 	if(defined($on)) {		# Now change
 		my $onbitmask = 1 << $self->index;
 		my $offbitmask = $result & ~$onbitmask;
@@ -67,14 +68,13 @@
 		push(@lines, $line);
 	}
 	$xpd->{LINES} = \@lines;
-	my ($infofile) = glob "$procdir/*_info";
-	die "Failed globbing '$procdir/*_info'" unless defined $infofile;
-	my $type = $xpd->type;
-	open(F, "$infofile") || die "Failed opening '$infofile': $!";
-	my $battery_info = 0;
-	while (<F>) {
-		chomp;
-		if($type eq 'FXO') {
+	if($xpd->type eq 'FXO') {
+		my ($infofile) = glob "$procdir/*_info";
+		die "Failed globbing '$procdir/*_info'" unless defined $infofile;
+		open(F, "$infofile") || die "Failed opening '$infofile': $!";
+		my $battery_info = 0;
+		while (<F>) {
+			chomp;
 			$battery_info = 1 if /^Battery:/;
 			if($battery_info && s/^\s*on\s*:\s*//) {
 				my @batt = split;

Modified: tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xpd.pm
URL: http://svn.digium.com/view/dahdi/tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xpd.pm?view=diff&rev=5099&r1=5098&r2=5099
==============================================================================
--- tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xpd.pm (original)
+++ tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xpd.pm Thu Oct 16 13:03:47 2008
@@ -12,14 +12,14 @@
 use Dahdi::Xpp;
 use Dahdi::Xpp::Line;
 
-my $proc_base = "/proc/xpp";
-
 sub blink($$) {
 	my $self = shift;
 	my $on = shift;
 	my $result;
-
-	my $file = "$proc_base/" . $self->fqn . "/blink";
+	my $file = Dahdi::Xpp::xpd_attr_path(
+		$self->xbus->num,
+		$self->unit,
+		$self->subunit, "blink");
 	die "$file is missing" unless -f $file;
 	# First query
 	open(F, "$file") or die "Failed to open $file for reading: $!";
@@ -44,8 +44,10 @@
 	my $self = shift;
 	my $on = shift;
 	my $result;
-
-	my $file = "$proc_base/" . $self->fqn . "/dahdi_registration";
+	my $file = Dahdi::Xpp::xpd_attr_path(
+		$self->xbus->num,
+		$self->unit,
+		$self->subunit, "span", "dahdi_registration");
 	die "$file is missing" unless -f $file;
 	# First query
 	open(F, "$file") or die "Failed to open $file for reading: $!";
@@ -101,8 +103,10 @@
 		}
 	}
 	close F;
-	$head =~ s/^(XPD-(\d\d))\s+// || die;
-	$self->{ID} = $2;
+	$head =~ s/^(XPD-(\d)(\d))\s+// || die;
+	$self->{ID} = "$2$3";
+	$self->{UNIT} = "$2";
+	$self->{SUBUNIT} = "$3";
 	$self->{FQN} = $xbus->name . "/" . $1;
 	$head =~ s/^.*\(// || die;
 	$head =~ s/\) */, / || die;

Added: tools/trunk/xpp/waitfor_xpds
URL: http://svn.digium.com/view/dahdi/tools/trunk/xpp/waitfor_xpds?view=auto&rev=5099
==============================================================================
--- tools/trunk/xpp/waitfor_xpds (added)
+++ tools/trunk/xpp/waitfor_xpds Thu Oct 16 13:03:47 2008
@@ -1,0 +1,31 @@
+#! /bin/sh
+
+set -e
+
+ab_list() {
+	ab=`find /sys/bus/astribanks/devices/xbus-*/ -name waitfor_xpds 2> /dev/null || :`
+	if [ "$ab" = "" ]; then
+		ab=`find /proc/xpp/XBUS-[0-9]*/ -name waitfor_xpds 2> /dev/null || :`
+		procfiles=1
+	fi
+	if [ "$ab" = "" ]; then
+		echo 1>&2 "$0: No XBUSES to wait for. Aborting..."
+		exit 1
+	fi
+	if [ -n "$procfiles" ]; then
+		echo 1>&2 "$0: No /sys attributes, fallback to /proc interface..."
+	fi
+	echo $ab
+}
+
+
+while
+	if ! ab=`ab_list`; then
+		exit 1
+	fi
+	test "$oldab" != "$ab"
+do
+	oldab="$ab"
+	echo 1>&2 "Waiting for XPDS"
+	cat $ab
+done

Propchange: tools/trunk/xpp/waitfor_xpds
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tools/trunk/xpp/waitfor_xpds
------------------------------------------------------------------------------
    svn:executable = *

Propchange: tools/trunk/xpp/waitfor_xpds
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Propchange: tools/trunk/xpp/waitfor_xpds
------------------------------------------------------------------------------
    svn:mime-type = text/plain




More information about the svn-commits mailing list