dahdi-perl: fix xpp driver in dahdi_hardware

Don't require 'dahdi_hardware -v' to show the driver for a USB device.
Only works when the usbfs is not used (when /proc/bus/usb is not mounted).

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>

git-svn-id: http://svn.astersk.org/svn/dahdi/tools/trunk@9699 17933a7a-c749-41c5-a318-cba88f637d49
This commit is contained in:
Tzafrir Cohen 2011-01-25 10:11:36 +00:00
parent fae45054b1
commit d765176efd

View File

@ -140,8 +140,9 @@ sub scan_devices_sysfs($) {
# Older kernels, e.g. 2.6.9, don't have the attribute # Older kernels, e.g. 2.6.9, don't have the attribute
# busnum: # busnum:
m|/(\d+)-[\d.]+$|; m|/((\d+)-[\d.]+)$|;
my $busnum = $1 || next; my $busnum = $2 || next;
my $dev_sys_name = $1;
my $vendor = _get_attr("$_/idVendor"); my $vendor = _get_attr("$_/idVendor");
my $product = _get_attr("$_/idProduct"); my $product = _get_attr("$_/idProduct");
my $model = $usb_ids{"$vendor:$product"}; my $model = $usb_ids{"$vendor:$product"};
@ -149,6 +150,12 @@ sub scan_devices_sysfs($) {
my $devnum = _get_attr("$_/devnum"); my $devnum = _get_attr("$_/devnum");
my $serial = _get_attr_optional("$_/serial", ''); my $serial = _get_attr_optional("$_/serial", '');
my $devname = sprintf("%03d/%03d", $busnum, $devnum); my $devname = sprintf("%03d/%03d", $busnum, $devnum);
# Get driver for first interface of the device:
my $iface = "$_/$dev_sys_name:1.0";
my $loaded = readlink("$iface/driver");
if (defined $loaded) {
$loaded =~ s|.*/||;
}
my $d = Dahdi::Hardware::USB->new( my $d = Dahdi::Hardware::USB->new(
IS_ASTRIBANK => ($model->{DRIVER} eq 'xpp_usb')?1:0, IS_ASTRIBANK => ($model->{DRIVER} eq 'xpp_usb')?1:0,
PRIV_DEVICE_NAME => $devname, PRIV_DEVICE_NAME => $devname,
@ -157,6 +164,7 @@ sub scan_devices_sysfs($) {
SERIAL => $serial, SERIAL => $serial,
DESCRIPTION => $model->{DESCRIPTION}, DESCRIPTION => $model->{DESCRIPTION},
DRIVER => $model->{DRIVER}, DRIVER => $model->{DRIVER},
LOADED => $loaded,
); );
push(@devices, $d); push(@devices, $d);
} }