[svn-commits] tzafrir: branch tools/tzafrir/perl-sysstate r8209 - in /tools/team/tzafrir/pe...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Mar 2 07:56:22 CST 2010


Author: tzafrir
Date: Tue Mar  2 07:56:18 2010
New Revision: 8209

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8209
Log:
Move setting of the virt_base to a BEGIN block

Set environment variables in a perl BEGIN block.

* But in Dahdi::Utils rather than Dahdi.
* No need for set_virt_base.

Modified:
    tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi.pm
    tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Hardware.pm
    tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Utils.pm
    tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Xpp.pm

Modified: tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi.pm?view=diff&rev=8209&r1=8208&r2=8209
==============================================================================
--- tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi.pm (original)
+++ tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi.pm Tue Mar  2 07:56:18 2010
@@ -43,19 +43,6 @@
 #
 # Other modules should use e.g. $Dahdi::proc_dahdi_base instead of
 # '/proc/dahdi' directly.
-sub set_virt_base() {
-	return if defined $virt_base;
-
-	if (exists $ENV{DAHDI_VIRT_TOP}) {
-		$virt_base = $ENV{DAHDI_VIRT_TOP};
-	} else {
-		$virt_base = '';
-	}
-	$proc_dahdi_base = "$virt_base/proc/dahdi";
-	$proc_xpp_base = "$virt_base/proc/xpp";
-	$proc_usb_base = "$virt_base/proc/bus/usb";
-	$sys_base = "$virt_base/sys";
-}
 
 =head1 spans()
 
@@ -66,7 +53,6 @@
 sub spans() {
 	my @spans;
 
-	set_virt_base();
 	-d $proc_dahdi_base or return ();
 	foreach my $zfile (glob "$proc_dahdi_base/*") {
 		next unless ($zfile =~ m{^$proc_dahdi_base/\d+$});

Modified: tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Hardware.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Hardware.pm?view=diff&rev=8209&r1=8208&r2=8209
==============================================================================
--- tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Hardware.pm (original)
+++ tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Hardware.pm Tue Mar  2 07:56:18 2010
@@ -176,7 +176,6 @@
 	my $pack = shift || die;
 
 	return if $hardware_scanned++;
-	Dahdi::set_virt_base();
 
 	foreach my $type (qw(PCI USB)) {
 		eval "use Dahdi::Hardware::$type";

Modified: tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Utils.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Utils.pm?view=diff&rev=8209&r1=8208&r2=8209
==============================================================================
--- tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Utils.pm (original)
+++ tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Utils.pm Tue Mar  2 07:56:18 2010
@@ -21,6 +21,18 @@
 		#print STDERR "get: $key ($val)\n";
 		return $val;
 	}
+}
+
+BEGIN {
+	if (exists $ENV{DAHDI_VIRT_TOP}) {
+		$Dahdi::virt_base = $ENV{DAHDI_VIRT_TOP};
+	} else {
+		$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";
 }
 
 sub xpp_dump($) {

Modified: tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Xpp.pm
URL: http://svnview.digium.com/svn/dahdi/tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Xpp.pm?view=diff&rev=8209&r1=8208&r2=8209
==============================================================================
--- tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Xpp.pm (original)
+++ tools/team/tzafrir/perl-sysstate/xpp/perl_modules/Dahdi/Xpp.pm Tue Mar  2 07:56:18 2010
@@ -38,10 +38,7 @@
 our $sysfs_xpds;
 our $sysfs_ab_driver;
 
-sub set_virt_base() {
-	return if defined $sysfs_xpds;
-	Dahdi::set_virt_base();
-
+BEGIN {
 	my $virt_base = $Dahdi::virt_base;
 	$sysfs_astribanks = "$virt_base/sys/bus/astribanks/devices";
 	$sysfs_xpds = "$virt_base/sys/bus/xpds/devices";
@@ -51,7 +48,6 @@
 sub scan($) {
 	my $pack = shift || die;
 
-	set_virt_base();
 	opendir(D, $sysfs_astribanks) || return();
 	while(my $entry = readdir D) {
 		next unless $entry =~ /xbus-(\d+)/;




More information about the svn-commits mailing list