summaryrefslogtreecommitdiffstats
path: root/MDV
diff options
context:
space:
mode:
authorDexter Morgan <dmorgan@mageia.org>2011-06-02 20:49:50 +0000
committerDexter Morgan <dmorgan@mageia.org>2011-06-02 20:49:50 +0000
commitdb5a94788a783a716de6c79e23f2e45093aca398 (patch)
treef0448c53425509d4272a355f120cb7249d4d58e8 /MDV
downloadldetect-db5a94788a783a716de6c79e23f2e45093aca398.tar
ldetect-db5a94788a783a716de6c79e23f2e45093aca398.tar.gz
ldetect-db5a94788a783a716de6c79e23f2e45093aca398.tar.bz2
ldetect-db5a94788a783a716de6c79e23f2e45093aca398.tar.xz
ldetect-db5a94788a783a716de6c79e23f2e45093aca398.zip
Branch for updatesdistro/mga1
Diffstat (limited to 'MDV')
-rwxr-xr-xMDV/Lspciusb.pm63
1 files changed, 63 insertions, 0 deletions
diff --git a/MDV/Lspciusb.pm b/MDV/Lspciusb.pm
new file mode 100755
index 0000000..f3a3227
--- /dev/null
+++ b/MDV/Lspciusb.pm
@@ -0,0 +1,63 @@
+package MDV::Lspciusb;
+#*****************************************************************************
+#
+# Copyright (c) 2006-2007 Mandriva SA
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2, as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+#*****************************************************************************
+#
+# $Id: Lspciusb.pm 44676 2007-02-26 16:56:43Z tv $
+
+use lib qw(/usr/lib/libDrakX);
+use modalias;
+use MDK::Common;
+use detect_devices;
+
+my %bus_get_description = (
+ usb => sub {
+ my ($dev_path, $_values) = @_;
+ my $full_path = dirname($dev_path) . "/" . readlink($dev_path);
+ my $parent_path = dirname($full_path);
+ chomp_(cat_("$parent_path/product"));
+ },
+);
+
+sub list {
+ my (@bus) = @_;
+ @bus = qw(usb) if !@bus;
+ map {
+ my ($modalias_path, $desc);
+ if (ref $_) {
+ my $device = $_;
+ $modalias_path = sprintf('/sys/bus/pci/devices/%04x:%02x:%02x.%x/modalias', $device->{pci_domain}, $device->{pci_bus}, $device->{pci_device}, $device->{pci_function});
+ $desc = $device->{description};
+ } else {
+ $modalias_path = $_;
+ }
+ my $modalias = chomp_(cat_($modalias_path));
+ my $dev_path = dirname($modalias_path);
+ my ($bus, $values) = $modalias =~ /^([^:]+):(\S+)$/; # modalias::get_bus
+ my @modules = modalias::get_modules($modalias);
+ my $module = first(@modules) || "unknown";
+ my $modules = @modules > 1 ? " (" . join(",", @modules) . ")" : "";
+ if (my $get_desc = $bus_get_description{$bus} and !$desc) {
+ $desc = $get_desc->($dev_path, $values);
+ }
+ $desc ||= "unknown";
+ { module => $module, descr => $desc, modules => $modules };
+ } detect_devices::pci_probe(), map { glob("/sys/bus/$_/devices/*/modalias") } @bus;
+}
+
+1;