]> git.proxmox.com Git - pve-common.git/commitdiff
SysFSTools: lspci: fixup: improve naming and refactor a bit
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 19 Nov 2018 10:18:02 +0000 (11:18 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Mon, 19 Nov 2018 12:45:13 +0000 (13:45 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/SysFSTools.pm

index c16e7d3720947c7b43684443c4c73650816fa9c2..e83d1630f3be9cef930b9013a2da73d76f381672 100644 (file)
@@ -11,16 +11,17 @@ my $pcisysfs = "/sys/bus/pci";
 my $pciregex = "([a-f0-9]{4}):([a-f0-9]{2}):([a-f0-9]{2})\.([a-f0-9])";
 
 sub lspci {
-    my ($filter) = @_;
+    my ($id_filter) = @_;
 
     my $devices = {};
 
     dir_glob_foreach("$pcisysfs/devices", $pciregex, sub {
             my (undef, undef, $bus, $slot, $function) = @_;
+
            my $id = "$bus:$slot";
-           return if defined($filter) && $id ne $filter;
-           my $res = { id => $id, function => $function};
-           push @{$devices->{$id}}, $res;
+           return if defined($id_filter) && $id_filter ne $id;
+
+           push @{$devices->{$id}}, { id => $id, function => $function };
     });
 
     # Entries should be sorted by functions.