diff options
author | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2012-03-15 20:32:27 +0000 |
---|---|---|
committer | Tzafrir Cohen <tzafrir.cohen@xorcom.com> | 2012-03-15 20:32:27 +0000 |
commit | 906c7e3f92de6e3e0e2193ecdb0f232a40fd1d7e (patch) | |
tree | f6b1183639db85c81da55b3e97da8385d169bc1e /xpp/perl_modules/Dahdi/Xpp/Xpd.pm | |
parent | ab44f81dde27cb645a2934e71956b40dc1eb581f (diff) |
xpp: sysfs access cleanups
With /proc/xpp code removed, some cleanup can be done.
* No need to search alternative attribute names, so xbus_attr_path() is
redundant.
* Don't compose xbus sysfs directory in multiple code locations.
Do it once in Xbus->new() and use the result ($xbus->sysfs_dir)
* Pass XPD directory strings directly to Xpd->new()
- So we parse it for unit/subunit only in Xpd->new()
* Don't parse xbus sysfs name:
- Toplevel scan, pass it as is to Xbus->new()
- Xbus->new() deduce the xbus->num from the naming
of Xpd's inside (nn:m:k) -- this is a hack until
we add xbus number as an xbus sysfs attribute
Signed-off-by: Oron Peled <oron.peled@xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@10494 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'xpp/perl_modules/Dahdi/Xpp/Xpd.pm')
-rw-r--r-- | xpp/perl_modules/Dahdi/Xpp/Xpd.pm | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/xpp/perl_modules/Dahdi/Xpp/Xpd.pm b/xpp/perl_modules/Dahdi/Xpp/Xpd.pm index 7edfc58..810ad9e 100644 --- a/xpp/perl_modules/Dahdi/Xpp/Xpd.pm +++ b/xpp/perl_modules/Dahdi/Xpp/Xpd.pm @@ -99,14 +99,15 @@ my %file_warned; # Prevent duplicate warnings about same file. sub xpd_attr_path($@) { my $self = shift || die; + my $xbus = $self->xbus; my ($busnum, $unitnum, $subunitnum, @attr) = ( - $self->xbus->num, + $xbus->num, $self->unit, $self->subunit, @_); foreach my $attr (@attr) { - my $file = sprintf "$Dahdi::Xpp::sysfs_xpds/%02d:%1d:%1d/$attr", - $busnum, $unitnum, $subunitnum; + my $file = sprintf "%s/%02d:%1d:%1d/$attr", + $xbus->sysfs_dir, $busnum, $unitnum, $subunitnum; next unless -f $file; return $file; } @@ -217,12 +218,12 @@ sub xpds_by_spanno() { return @idx; } -sub new($$$$$) { +sub new($$$) { my $pack = shift or die "Wasn't called as a class method\n"; - my $xbus = shift || die; - my $unit = shift; # May be zero - my $subunit = shift; # May be zero - my $sysfsdir = shift || die; + my $xbus = shift or die; + my $xpdstr = shift or die; + my $sysfsdir = sprintf "%s/%s", $xbus->sysfs_dir, $xpdstr; + my ($busnum, $unit, $subunit) = split(/:/, $xpdstr); my $self = { XBUS => $xbus, ID => sprintf("%1d%1d", $unit, $subunit), |