mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-09-03 15:55:15 +00:00
Reindent pci access functions.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5446 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
@@ -2395,47 +2395,50 @@ use vars qw(%pci_list);
|
|||||||
# 'domain', 'bus', 'slot' and 'func' uniquely identify a PCI device in a
|
# 'domain', 'bus', 'slot' and 'func' uniquely identify a PCI device in a
|
||||||
# computer; 'vendid' and 'devid' uniquely identify a type of device.
|
# computer; 'vendid' and 'devid' uniquely identify a type of device.
|
||||||
# 'class' lets us spot unknown SMBus adapters.
|
# 'class' lets us spot unknown SMBus adapters.
|
||||||
sub read_sys_dev_pci($)
|
sub read_sys_dev_pci
|
||||||
{
|
{
|
||||||
my $devices = shift;
|
my $devices = shift;
|
||||||
my ($dev, @pci_list);
|
my ($dev, @pci_list);
|
||||||
|
|
||||||
opendir(local *DEVICES, "$devices")
|
opendir(local *DEVICES, "$devices")
|
||||||
or die "$devices: $!";
|
or die "$devices: $!";
|
||||||
|
|
||||||
while (defined($dev = readdir(DEVICES))) {
|
while (defined($dev = readdir(DEVICES))) {
|
||||||
my %record;
|
my %record;
|
||||||
next unless $dev =~
|
next unless $dev =~
|
||||||
m/^(?:([\da-f]+):)?([\da-f]+):([\da-f]+)\.([\da-f]+)$/;
|
m/^(?:([\da-f]+):)?([\da-f]+):([\da-f]+)\.([\da-f]+)$/;
|
||||||
|
|
||||||
$record{domain} = hex $1;
|
$record{domain} = hex $1;
|
||||||
$record{bus} = hex $2;
|
$record{bus} = hex $2;
|
||||||
$record{slot} = hex $3;
|
$record{slot} = hex $3;
|
||||||
$record{func} = hex $4;
|
$record{func} = hex $4;
|
||||||
|
|
||||||
$record{vendid} = oct sysfs_device_attribute("$devices/$dev", "vendor");
|
$record{vendid} = oct sysfs_device_attribute("$devices/$dev",
|
||||||
$record{devid} = oct sysfs_device_attribute("$devices/$dev", "device");
|
"vendor");
|
||||||
$record{class} = (oct sysfs_device_attribute("$devices/$dev", "class"))
|
$record{devid} = oct sysfs_device_attribute("$devices/$dev",
|
||||||
>> 8;
|
"device");
|
||||||
|
$record{class} = (oct sysfs_device_attribute("$devices/$dev",
|
||||||
|
"class")) >> 8;
|
||||||
|
|
||||||
push @pci_list, \%record;
|
push @pci_list, \%record;
|
||||||
}
|
}
|
||||||
|
|
||||||
return \@pci_list;
|
return \@pci_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub initialize_pci
|
sub initialize_pci
|
||||||
{
|
{
|
||||||
my $pci_list;
|
my $pci_list;
|
||||||
|
local $_;
|
||||||
|
|
||||||
$pci_list = read_sys_dev_pci("$sysfs_root/bus/pci/devices");
|
$pci_list = read_sys_dev_pci("$sysfs_root/bus/pci/devices");
|
||||||
|
|
||||||
# Note that we lose duplicate devices at this point, but we don't
|
# Note that we lose duplicate devices at this point, but we don't
|
||||||
# really care. What matters to us is which unique devices are present,
|
# really care. What matters to us is which unique devices are present,
|
||||||
# not how many of each.
|
# not how many of each.
|
||||||
%pci_list = map {
|
%pci_list = map {
|
||||||
sprintf("%04x:%04x", $_->{vendid}, $_->{devid}) => $_
|
sprintf("%04x:%04x", $_->{vendid}, $_->{devid}) => $_
|
||||||
} @{$pci_list};
|
} @{$pci_list};
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
|
Reference in New Issue
Block a user