mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-09-04 16:25:18 +00:00
Reindent more functions.
git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5476 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
@@ -2486,16 +2486,18 @@ use vars qw(@chips_detected);
|
||||
sub add_i2c_to_chips_detected
|
||||
{
|
||||
my ($chipdriver, $datahash) = @_;
|
||||
my ($i, $new_detected_ref, $detected_ref,
|
||||
$main_entry, $detected_entry, $put_in_detected, @hash_addrs, @entry_addrs);
|
||||
my ($i, $new_detected_ref, $detected_ref, $main_entry, $detected_entry,
|
||||
$put_in_detected, @hash_addrs, @entry_addrs);
|
||||
|
||||
# First determine where the hash has to be added.
|
||||
for ($i = 0; $i < @chips_detected; $i++) {
|
||||
last if ($chips_detected[$i]->{driver} eq $chipdriver);
|
||||
}
|
||||
if ($i == @chips_detected) {
|
||||
push @chips_detected, { driver => $chipdriver,
|
||||
detected => [] };
|
||||
push @chips_detected, {
|
||||
driver => $chipdriver,
|
||||
detected => [],
|
||||
};
|
||||
}
|
||||
$new_detected_ref = $chips_detected[$i]->{detected};
|
||||
|
||||
@@ -2513,7 +2515,7 @@ sub add_i2c_to_chips_detected
|
||||
@entry_addrs = ($detected_entry->{i2c_addr});
|
||||
push @entry_addrs, @{$detected_entry->{i2c_sub_addrs}}
|
||||
if exists $detected_entry->{i2c_sub_addrs};
|
||||
if ($detected_entry->{i2c_devnr} == $datahash->{i2c_devnr} and
|
||||
if ($detected_entry->{i2c_devnr} == $datahash->{i2c_devnr} &&
|
||||
any_list_match(\@entry_addrs, \@hash_addrs)) {
|
||||
if ($detected_entry->{conf} >= $datahash->{conf}) {
|
||||
$put_in_detected = 0;
|
||||
@@ -2523,18 +2525,18 @@ sub add_i2c_to_chips_detected
|
||||
}
|
||||
}
|
||||
|
||||
if ($put_in_detected) {
|
||||
# Here, we discard all entries which
|
||||
# match at least in one main or sub address. This may not be the
|
||||
# best idea to do, as it may remove detections without replacing
|
||||
# them with second-best ones. Too bad.
|
||||
return unless $put_in_detected;
|
||||
|
||||
# Here, we discard all entries which match at least in one main or
|
||||
# sub address. This may not be the best idea to do, as it may remove
|
||||
# detections without replacing them with second-best ones. Too bad.
|
||||
foreach $main_entry (@chips_detected) {
|
||||
$detected_ref = $main_entry->{detected};
|
||||
for ($i = @$detected_ref-1; $i >=0; $i--) {
|
||||
@entry_addrs = ($detected_ref->[$i]->{i2c_addr});
|
||||
push @entry_addrs, @{$detected_ref->[$i]->{i2c_sub_addrs}}
|
||||
if exists $detected_ref->[$i]->{i2c_sub_addrs};
|
||||
if ($detected_ref->[$i]->{i2c_devnr} == $datahash->{i2c_devnr} and
|
||||
if ($detected_ref->[$i]->{i2c_devnr} == $datahash->{i2c_devnr} &&
|
||||
any_list_match(\@entry_addrs, \@hash_addrs)) {
|
||||
splice @$detected_ref, $i, 1;
|
||||
}
|
||||
@@ -2543,7 +2545,6 @@ sub add_i2c_to_chips_detected
|
||||
|
||||
# Now add the new entry to detected
|
||||
push @$new_detected_ref, $datahash;
|
||||
}
|
||||
}
|
||||
|
||||
# This adds a detection to the above structure. We also do alias detection
|
||||
@@ -2563,15 +2564,17 @@ sub add_isa_to_chips_detected
|
||||
last if ($chips_detected[$i]->{driver} eq $chipdriver);
|
||||
}
|
||||
if ($i == @chips_detected) {
|
||||
push @chips_detected, { driver => $chipdriver,
|
||||
detected => [] };
|
||||
push @chips_detected, {
|
||||
driver => $chipdriver,
|
||||
detected => [],
|
||||
};
|
||||
}
|
||||
$new_detected_ref = $chips_detected[$i]->{detected};
|
||||
|
||||
# Now, we are looking for aliases. An alias can only be the same chiptype.
|
||||
# If it is found in the detected list, we
|
||||
# still have to check whether another chip has claimed this ISA address.
|
||||
# So we remove the old entry from the detected list and put it in datahash.
|
||||
# Now, we are looking for aliases. An alias can only be the same
|
||||
# chiptype. If it is found in the detected list, we still have to
|
||||
# check whether another chip has claimed this ISA address. So we
|
||||
# remove the old entry from the detected list and put it in datahash.
|
||||
for ($i = 0; $i < @$new_detected_ref; $i++) {
|
||||
if (exists $new_detected_ref->[$i]->{i2c_addr} and
|
||||
not exists $new_detected_ref->[$i]->{isa_addr} and
|
||||
@@ -2585,7 +2588,7 @@ sub add_isa_to_chips_detected
|
||||
print("Can't set I2C address for ",
|
||||
"$dev_i2c$new_detected_ref->[$i]->{i2c_devnr}?!?\n"),
|
||||
next;
|
||||
if (&$alias_detect ($datahash->{isa_addr}, \*FILE,
|
||||
if (&$alias_detect($datahash->{isa_addr}, \*FILE,
|
||||
$new_detected_ref->[$i]->{i2c_addr})) {
|
||||
$new_detected_ref->[$i]->{isa_addr} = $datahash->{isa_addr};
|
||||
($datahash) = splice (@$new_detected_ref, $i, 1);
|
||||
@@ -2690,9 +2693,10 @@ sub scan_adapter
|
||||
}
|
||||
|
||||
if (!i2c_set_slave_addr(\*FILE, $addr)) {
|
||||
# If the address is busy, we can normally find out which driver
|
||||
# requested it (if the kernel is recent enough, at least 2.6.16
|
||||
# and later are known to work), and we assume it is the right one.
|
||||
# If the address is busy, we can normally find out
|
||||
# which driver requested it (if the kernel is recent
|
||||
# enough, at least 2.6.16 and later are known to work),
|
||||
# and we assume it is the right one.
|
||||
my ($device, $driver);
|
||||
|
||||
$device = sprintf("$sysfs_root/bus/i2c/devices/\%d-\%04x",
|
||||
@@ -2703,7 +2707,8 @@ sub scan_adapter
|
||||
$new_hash = {
|
||||
conf => 6, # Arbitrary confidence
|
||||
i2c_addr => $addr,
|
||||
chipname => sysfs_device_attribute($device, "name") || "unknown",
|
||||
chipname => sysfs_device_attribute($device, "name")
|
||||
|| "unknown",
|
||||
i2c_adap => $adapter_name,
|
||||
i2c_driver => $adapter_driver,
|
||||
i2c_devnr => $adapter_nr,
|
||||
@@ -2713,9 +2718,10 @@ sub scan_adapter
|
||||
printf "Handled by driver `\%s' (already loaded), chip type `\%s'\n",
|
||||
$driver, $new_hash->{chipname};
|
||||
|
||||
# Only add it to the list if this is something we would have
|
||||
# detected, else we end up with random i2c chip drivers listed
|
||||
# (for example media/video drivers.)
|
||||
# Only add it to the list if this is something
|
||||
# we would have detected, else we end up with
|
||||
# random i2c chip drivers listed (for example
|
||||
# media/video drivers.)
|
||||
if (exists $modules_supported{$driver}) {
|
||||
add_i2c_to_chips_detected($driver, $new_hash);
|
||||
} else {
|
||||
@@ -2759,7 +2765,8 @@ sub scan_adapter
|
||||
next if ($chip->{driver} eq "not-a-sensor"
|
||||
|| $chip->{driver} eq "use-isa-instead");
|
||||
|
||||
$new_hash = { conf => $conf,
|
||||
$new_hash = {
|
||||
conf => $conf,
|
||||
i2c_addr => $addr,
|
||||
chipname => $chip->{name},
|
||||
i2c_adap => $adapter_name,
|
||||
@@ -2783,21 +2790,24 @@ sub scan_adapter
|
||||
sub scan_isa_bus
|
||||
{
|
||||
my ($chip, $addr, $conf);
|
||||
|
||||
$| = 1;
|
||||
foreach $chip (@chip_ids) {
|
||||
next if not exists $chip->{isa_addrs} or not exists $chip->{isa_detect};
|
||||
foreach $addr (@{$chip->{isa_addrs}}) {
|
||||
printf("\%-60s", sprintf("Probing for `\%s'\ at 0x\%x... ", $chip->{name},
|
||||
$addr));
|
||||
printf("\%-60s", sprintf("Probing for `\%s'\ at 0x\%x... ",
|
||||
$chip->{name}, $addr));
|
||||
$conf = &{$chip->{isa_detect}} ($addr);
|
||||
print("No\n"), next if not defined $conf;
|
||||
print "Success!\n";
|
||||
printf " (confidence %d, driver `%s')\n", $conf, $chip->{driver};
|
||||
my $new_hash = { conf => $conf,
|
||||
my $new_hash = {
|
||||
conf => $conf,
|
||||
isa_addr => $addr,
|
||||
chipname => $chip->{name}
|
||||
chipname => $chip->{name},
|
||||
};
|
||||
$new_hash = add_isa_to_chips_detected($chip->{alias_detect}, $chip->{driver},
|
||||
$new_hash = add_isa_to_chips_detected($chip->{alias_detect},
|
||||
$chip->{driver},
|
||||
$new_hash);
|
||||
if ($new_hash) {
|
||||
printf " Alias of the chip on I2C bus `%s', address 0x%02x\n",
|
||||
|
Reference in New Issue
Block a user