105
100
sub xpd_attr_path($@) {
106
101
my $self = shift || die;
102
my $xbus = $self->xbus;
107
103
my ($busnum, $unitnum, $subunitnum, @attr) = (
112
108
foreach my $attr (@attr) {
113
my $file = sprintf "$Dahdi::Xpp::sysfs_xpds/%02d:%1d:%1d/$attr",
114
$busnum, $unitnum, $subunitnum;
116
my $procfile = sprintf "/proc/xpp/XBUS-%02d/XPD-%1d%1d/$attr",
117
$busnum, $unitnum, $subunitnum;
118
warn "$0: warning - OLD DRIVER: missing '$file'. Fall back to /proc\n"
119
unless $file_warned{$attr}++;
109
my $file = sprintf "%s/%02d:%1d:%1d/$attr",
110
$xbus->sysfs_dir, $busnum, $unitnum, $subunitnum;
122
111
next unless -f $file;
128
# Backward compat plug for old /proc interface...
129
sub xpd_old_gettype($) {
130
my $xpd = shift || die;
131
my $summary = "/proc/xpp/" . $xpd->fqn . "/summary";
132
open(F, $summary) or die "Failed to open '$summary': $!";
136
$head =~ s/^XPD-\d+\s+\(//;
141
sub xpd_old_getspan($) {
142
my $xpd = shift || die;
143
my $dahdi_registration = "/proc/xpp/" . $xpd->fqn . "/dahdi_registration";
144
open(F, $dahdi_registration) or die "Failed to open '$dahdi_registration': $!";
151
sub xpd_old_getoffhook($) {
152
my $xpd = shift || die;
153
my $summary = "/proc/xpp/" . $xpd->fqn . "/summary";
157
open(F, "$summary") || die "Failed opening $summary: $!\n";
159
chomp $head; # "XPD-00 (BRI_TE ,card present, span 3)"
163
if(s/^\s*offhook\s*:\s*//) {
166
$offhook || die "No channels in '$summary'";
174
117
my %attr_missing_warned; # Prevent duplicate warnings
176
119
sub xpd_driver_getattr($$) {
198
141
$attr = lc($attr);
199
142
my $file = $xpd->xpd_attr_path(lc($attr));
201
# Handle special cases for backward compat
202
return xpd_old_gettype($xpd) if $attr eq 'type' and !defined $file;
203
return xpd_old_getspan($xpd) if $attr eq 'span' and !defined $file;
204
return xpd_old_getoffhook($xpd) if $attr eq 'offhook' and !defined $file;
205
144
if(!defined($file)) {
206
145
warn "$0: xpd_getattr($attr) -- Missing attribute.\n" if
207
146
$attr_missing_warned{$attr};
283
222
my $pack = shift or die "Wasn't called as a class method\n";
284
my $xbus = shift || die;
285
my $unit = shift; # May be zero
286
my $subunit = shift; # May be zero
287
my $procdir = shift || die;
288
my $sysfsdir = shift || die;
223
my $xbus = shift or die;
224
my $xpdstr = shift or die;
225
my $sysfsdir = sprintf "%s/%s", $xbus->sysfs_dir, $xpdstr;
226
my ($busnum, $unit, $subunit) = split(/:/, $xpdstr);
291
229
ID => sprintf("%1d%1d", $unit, $subunit),
292
230
FQN => $xbus->name . "/" . "XPD-$unit$subunit",
294
232
SUBUNIT => $subunit,
296
233
SYSFS_DIR => $sysfsdir,
298
235
bless $self, $pack;
327
264
# static xpd related helper functions
328
265
#------------------------------------
267
# Returns only the telephony XPD's from a list
268
# of one or more XPD's.
269
# I.e: Filters-out ECHO cancelers
271
my @devs = grep { $_->channels } @_;
330
275
sub format_rank($$) {
331
276
my ($rank, $prio) = @_;