[dahdi-commits] tzafrir: tools/trunk r10492 - in /tools/trunk/xpp: ./ perl_modules/ perl_modu...

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Thu Mar 15 15:30:46 CDT 2012


Author: tzafrir
Date: Thu Mar 15 15:30:41 2012
New Revision: 10492

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10492
Log:
xpp: perl_modules: Remove /proc/xpp usage

* All references to old /proc/xpp interface were removed.
* Everything is now done via sysfs

Information has been available from /sys/bus/astribanks since before
Dahdi-linux 2.2 .

Signed-off-by: Oron Peled <oron.peled at xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>

Modified:
    tools/trunk/xpp/perl_modules/Dahdi.pm
    tools/trunk/xpp/perl_modules/Dahdi/Utils.pm
    tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm
    tools/trunk/xpp/perl_modules/Dahdi/Xpp/Line.pm
    tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xbus.pm
    tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xpd.pm
    tools/trunk/xpp/xpp_sync

Modified: tools/trunk/xpp/perl_modules/Dahdi.pm
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/perl_modules/Dahdi.pm?view=diff&rev=10492&r1=10491&r2=10492
==============================================================================
--- tools/trunk/xpp/perl_modules/Dahdi.pm (original)
+++ tools/trunk/xpp/perl_modules/Dahdi.pm Thu Mar 15 15:30:41 2012
@@ -34,7 +34,6 @@
 
 our $virt_base;
 our $proc_dahdi_base;
-our $proc_xpp_base;
 our $proc_usb_base;
 our $sys_base;
 

Modified: tools/trunk/xpp/perl_modules/Dahdi/Utils.pm
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/perl_modules/Dahdi/Utils.pm?view=diff&rev=10492&r1=10491&r2=10492
==============================================================================
--- tools/trunk/xpp/perl_modules/Dahdi/Utils.pm (original)
+++ tools/trunk/xpp/perl_modules/Dahdi/Utils.pm Thu Mar 15 15:30:41 2012
@@ -32,7 +32,6 @@
 		$Dahdi::virt_base = '';
 	}
 	$Dahdi::proc_dahdi_base = "$Dahdi::virt_base/proc/dahdi";
-	$Dahdi::proc_xpp_base = "$Dahdi::virt_base/proc/xpp";
 	$Dahdi::proc_usb_base = "$Dahdi::virt_base/proc/bus/usb";
 	$Dahdi::sys_base = "$Dahdi::virt_base/sys";
 }

Modified: tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm?view=diff&rev=10492&r1=10491&r2=10492
==============================================================================
--- tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm (original)
+++ tools/trunk/xpp/perl_modules/Dahdi/Xpp.pm Thu Mar 15 15:30:41 2012
@@ -104,8 +104,8 @@
 
 =head1 xbuses([sort_order])
 
-Scans system (/proc and /sys) and returns a list of Astribank (Xbus) 
-objects. The optional parameter sort_order is the order in which 
+Scans system (via /sys) and returns a list of Astribank (Xbus)
+objects. The optional parameter sort_order is the order in which
 the Astribanks will be returns:
 
 
@@ -249,53 +249,17 @@
 Gets (and optionally sets) the internal Astribanks synchronization
 source. When used to set sync source, returns the original sync source.
 
-A synchronization source is a value valid writing into /proc/xpp/sync .
+A synchronization source is a value valid writing into
+  /sys/bus/astribanks/drivers/xppdrv/sync
 For more information read that file and see README.Astribank .
 
 =cut
-
-sub sync_via_proc {
-	my $newsync = shift;
-	my $result;
-	my $newapi = 0;
-
-	my $proc_base = $Dahdi::proc_xpp_base;
-	my $file = "$proc_base/sync";
-	return '' unless -f $file;
-	# First query
-	open(F, "$file") or die "Failed to open $file for reading: $!";
-	while(<F>) {
-		chomp;
-		/SYNC=/ and $newapi = 1;
-		s/#.*//;
-		if(/\S/) {	# First non-comment line
-			s/^SYNC=\D*// if $newapi;
-			$result = $_;
-			last;
-		}
-	}
-	close F;
-	if(defined($newsync)) {		# Now change
-		$newsync =~ s/.*/\U$&/;
-		if($newsync =~ /^(\d+)$/) {
-			$newsync = ($newapi)? "SYNC=$1" : "$1 0";
-		} elsif($newsync ne 'DAHDI') {
-			die "Bad sync parameter '$newsync'";
-		}
-		open(F, ">$file") or die "Failed to open $file for writing: $!";
-		print F $newsync;
-		close(F) or die "Failed in closing $file: $!";
-	}
-	return $result;
-}
 
 sub sync {
 	my ($newsync) = @_;
 	my $result;
 	my $file = "$sysfs_ab_driver/sync";
-	if(! -f $file) {	# Old /proc interface
-		return sync_via_proc(@_);
-	}
+	die "Missing '$file'\n" unless -f $file;
 	open(F, "$file") or die "Failed to open $file for reading: $!";
 	$result = <F>;
 	close F;
@@ -329,7 +293,7 @@
 
 =item L<Dahdi::Xpp::Line>
 
-Object for a line: an analog port or a time-slot in a adapter. 
+Object for a line: an analog port or a time-slot in a adapter.
 Equivalent of a channel in Dahdi.
 
 =item L<Dahdi>

Modified: tools/trunk/xpp/perl_modules/Dahdi/Xpp/Line.pm
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/perl_modules/Dahdi/Xpp/Line.pm?view=diff&rev=10492&r1=10491&r2=10492
==============================================================================
--- tools/trunk/xpp/perl_modules/Dahdi/Xpp/Line.pm (original)
+++ tools/trunk/xpp/perl_modules/Dahdi/Xpp/Line.pm Thu Mar 15 15:30:41 2012
@@ -42,7 +42,6 @@
 sub create_all($$) {
 	my $pack = shift or die "Wasn't called as a class method\n";
 	my $xpd = shift || die;
-	my $procdir = shift || die;
 	local $/ = "\n";
 	my @lines;
 	for(my $i = 0; $i < $xpd->{CHANNELS}; $i++) {
@@ -52,37 +51,14 @@
 	$xpd->{LINES} = \@lines;
 	if($xpd->type eq 'FXO') {
 		my $battery = $xpd->xpd_getattr("fxo_battery");
-		if(defined $battery) {
-			my @batt = split(/\s+/, $battery);
-			foreach my $l (@lines) {
-				die unless @batt;
-				my $state = shift @batt;
-				$l->{BATTERY} = ($state eq '+') ? 1 : 0;
-			}
-		} else {
-			# Fallback to old interface
-			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;
-					foreach my $l (@lines) {
-						die unless @batt;
-						my $state = shift @batt;
-						$l->{BATTERY} = ($state eq '+') ? 1 : 0;
-					}
-					$battery_info = 0;
-					die if @batt;
-				}
-			}
-			close F;
+		die "Missing '$battery' attribute\n" unless defined $battery;
+		my @batt = split(/\s+/, $battery);
+		foreach my $l (@lines) {
+			die unless @batt;
+			my $state = shift @batt;
+			$l->{BATTERY} = ($state eq '+') ? 1 : 0;
 		}
 	}
-	close F;
 }
 
 

Modified: tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xbus.pm
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xbus.pm?view=diff&rev=10492&r1=10491&r2=10492
==============================================================================
--- tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xbus.pm (original)
+++ tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xbus.pm Thu Mar 15 15:30:41 2012
@@ -51,12 +51,6 @@
 	my ($busnum, @attr) = @_;
 	foreach my $attr (@attr) {
 		my $file = sprintf "$Dahdi::Xpp::sysfs_astribanks/xbus-%02d/$attr", $busnum;
-		unless(-f $file) {
-			my $procfile = sprintf "$Dahdi::proc_xpp_base/XBUS-%02d/$attr", $busnum;
-			warn "$0: warning - OLD DRIVER: missing '$file'. Fall back to '$procfile'\n"
-				unless $file_warned{$attr}++;
-			$file = $procfile;
-		}
 		next unless -f $file;
 		return $file;
 	}
@@ -109,21 +103,6 @@
 	return $xbus->{TRANSPORT_TYPE};
 }
 
-sub read_xpdnames_old($) {
-	my $xbus_num = shift || die;
-	my $pat = sprintf "$Dahdi::proc_xpp_base/XBUS-%02d/XPD-[0-9][0-9]", $xbus_num;
-	my @xpdnames;
-
-	#print STDERR "read_xpdnames_old($xbus_num): $pat\n";
-	foreach (glob $pat) {
-		die "Bad /proc entry: '$_'" unless /^.*XPD-([0-9])([0-9])$/;
-		my $name = sprintf("%02d:%1d:%1d", $xbus_num, $1, $2);
-		#print STDERR "\t> $_ ($name)\n";
-		push(@xpdnames, $name);
-	}
-	return @xpdnames;
-}
-
 sub read_xpdnames($) {
 	my $xbus_num = shift || die;
 	my $xbus_dir = "$Dahdi::Xpp::sysfs_astribanks/xbus-$xbus_num";
@@ -140,8 +119,6 @@
 	}
 	return @xpdnames;
 }
-
-my $warned_notransport = 0;
 
 sub new($$) {
 	my $pack = shift or die "Wasn't called as a class method\n";
@@ -164,17 +141,11 @@
 	}
 	my @xpdnames;
 	my @xpds;
-	if(-e $transport) {
-		@xpdnames = read_xpdnames($num);
-	} else {
-		@xpdnames = read_xpdnames_old($num);
-		warn "$0: warning - OLD DRIVER: missing '$transport'. Fall back to /proc\n"
-			unless $warned_notransport++;
-	}
+	die "OLD DRIVER: missing '$transport'\n" unless -e $transport;
+	@xpdnames = read_xpdnames($num);
 	foreach my $xpdstr (@xpdnames) {
 		my ($busnum, $unit, $subunit) = split(/:/, $xpdstr);
-		my $procdir = "$Dahdi::proc_xpp_base/XBUS-$busnum/XPD-$unit$subunit";
-		my $xpd = Dahdi::Xpp::Xpd->new($self, $unit, $subunit, $procdir, "$xbus_dir/$xpdstr");
+		my $xpd = Dahdi::Xpp::Xpd->new($self, $unit, $subunit, "$xbus_dir/$xpdstr");
 		push(@xpds, $xpd);
 	}
 	@{$self->{XPDS}} = sort { $a->id <=> $b->id } @xpds;

Modified: tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xpd.pm
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xpd.pm?view=diff&rev=10492&r1=10491&r2=10492
==============================================================================
--- tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xpd.pm (original)
+++ tools/trunk/xpp/perl_modules/Dahdi/Xpp/Xpd.pm Thu Mar 15 15:30:41 2012
@@ -52,11 +52,6 @@
 
 Textual name: E.g. C<XPD-10>.
 
-=head1 dir
-
-The ProcFS directory with information about the XPD. e.g.
-C</proc/xpp/XBUS-00/XPD-10>.
-
 =head1 sysfs_dir
 
 The SysFS directory with information about the module. E.g.
@@ -112,63 +107,10 @@
 	foreach my $attr (@attr) {
 		my $file = sprintf "$Dahdi::Xpp::sysfs_xpds/%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: warning - OLD DRIVER: missing '$file'. Fall back to /proc\n"
-				unless $file_warned{$attr}++;
-			$file = $procfile;
-		}
 		next unless -f $file;
 		return $file;
 	}
 	return undef;
-}
-
-# Backward compat plug for old /proc interface...
-sub xpd_old_gettype($) {
-	my $xpd = shift || die;
-	my $summary = "/proc/xpp/" . $xpd->fqn . "/summary";
-	open(F, $summary) or die "Failed to open '$summary': $!";
-	my $head = <F>;
-	close F;
-	chomp $head;
-	$head =~ s/^XPD-\d+\s+\(//;
-	$head =~ s/,.*//;
-	return $head;
-}
-
-sub xpd_old_getspan($) {
-	my $xpd = shift || die;
-	my $dahdi_registration = "/proc/xpp/" . $xpd->fqn . "/dahdi_registration";
-	open(F, $dahdi_registration) or die "Failed to open '$dahdi_registration': $!";
-	my $head = <F>;
-	close F;
-	chomp $head;
-	return $head;
-}
-
-sub xpd_old_getoffhook($) {
-	my $xpd = shift || die;
-	my $summary = "/proc/xpp/" . $xpd->fqn . "/summary";
-	my $channels;
-
-	local $/ = "\n";
-	open(F, "$summary") || die "Failed opening $summary: $!\n";
-	my $head = <F>;
-	chomp $head;	# "XPD-00 (BRI_TE ,card present, span 3)"
-	my $offhook;
-	while(<F>) {
-		chomp;
-		if(s/^\s*offhook\s*:\s*//) {
-			s/\s*$//;
-			$offhook = $_;
-			$offhook || die "No channels in '$summary'";
-			last;
-		}
-	}
-	close F;
-	return $offhook;
 }
 
 my %attr_missing_warned;	# Prevent duplicate warnings
@@ -198,10 +140,6 @@
 	$attr = lc($attr);
 	my $file = $xpd->xpd_attr_path(lc($attr));
 
-	# Handle special cases for backward compat
-	return xpd_old_gettype($xpd) if $attr eq 'type' and !defined $file;
-	return xpd_old_getspan($xpd) if $attr eq 'span' and !defined $file;
-	return xpd_old_getoffhook($xpd) if $attr eq 'offhook' and !defined $file;
 	if(!defined($file)) {
 		warn "$0: xpd_getattr($attr) -- Missing attribute.\n" if
 			$attr_missing_warned{$attr};
@@ -284,7 +222,6 @@
 	my $xbus = shift || die;
 	my $unit = shift;	# May be zero
 	my $subunit = shift;	# May be zero
-	my $procdir = shift || die;
 	my $sysfsdir = shift || die;
 	my $self = {
 		XBUS		=> $xbus,
@@ -292,7 +229,6 @@
 		FQN		=> $xbus->name . "/" . "XPD-$unit$subunit",
 		UNIT		=> $unit,
 		SUBUNIT		=> $subunit,
-		DIR		=> $procdir,
 		SYSFS_DIR	=> $sysfsdir,
 		};
 	bless $self, $pack;
@@ -319,7 +255,7 @@
 		}
 	}
 	$self->{IS_DIGITAL} = ( $self->{IS_BRI} || $self->{IS_PRI} );
-	Dahdi::Xpp::Line->create_all($self, $procdir);
+	Dahdi::Xpp::Line->create_all($self);
 	return $self;
 }
 

Modified: tools/trunk/xpp/xpp_sync
URL: http://svnview.digium.com/svn/dahdi/tools/trunk/xpp/xpp_sync?view=diff&rev=10492&r1=10491&r2=10492
==============================================================================
--- tools/trunk/xpp/xpp_sync (original)
+++ tools/trunk/xpp/xpp_sync Thu Mar 15 15:30:41 2012
@@ -19,7 +19,7 @@
 my $autoselect;
 
 sub usage() {
-	print 
+	print
 		"$0: show / set Astribank sync source\n".
 		"\n".
 		"Usage: $0 [-v]                    Show sync source.\n".
@@ -158,7 +158,7 @@
 (xbuses) that are connected and registered as Dahdi spans. The current
 xpp sync master will be marked.
 
-If you this an Astribank is connected and yet it does not appear on the 
+If you this an Astribank is connected and yet it does not appear on the
 output of xpp_sync, it may be unregistered. Try running dahdi_registration .
 
 =head2 Parameters
@@ -199,12 +199,12 @@
 		XBUS-00
 	==================================================
 
-In this example we see that the recommended xpp sync master is XBUS-02 - 
+In this example we see that the recommended xpp sync master is XBUS-02 -
 it is the first on the list. It is also the actual syncer, as we can see
 from the '+' beside it.
 
 xpp_sync is normally called from the dahdi init.d script.
-The parameter it is called with defaults to 
+The parameter it is called with defaults to
 I<auto>, but it is possible to override that parameter (e.g: set it to
 I<dahdi>) through the value of XPP_SYNC in /etc/dahdi/init.conf .
 
@@ -212,12 +212,13 @@
 
 =over
 
-=item /proc/xpp/sync
-
-(Deprecated: no longer supported)
-xpp_sync is essentially a nicer interface to /proc/xpp/sync . That file
-shows the current xpp sync master (and in what format you need to write
-to it to set the master).
+=item /sys/bus/astribanks/drivers/xppdrv/sync
+
+xpp_sync is essentially a nicer interface to
+C</sys/bus/astribanks/drivers/xppdrv/sync>. That file
+shows the current xpp sync master.
+
+Writing to it, force XPP drivers to use a different sync master
 
 =back
 




More information about the dahdi-commits mailing list