From cb76d5af685ef1a52f2f4c0b5656d9d52465747b Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 5 Jul 2010 16:50:27 +0000 Subject: [PATCH] Don't create entries for new drivers before we have something to add to them. If we have multiple detections at the same I2C address, one will be discarded so its driver shouldn't be recorded. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5847 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/detect/sensors-detect | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index dfa34a37..61b0061f 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -2951,14 +2951,9 @@ use vars qw(%chips_detected); sub add_i2c_to_chips_detected { my ($chipdriver, $datahash) = @_; - my ($i, $new_detected_ref, $detected_ref, $detected_entry, + my ($i, $detected_ref, $detected_entry, $put_in_detected, @hash_addrs, @entry_addrs); - # First determine where the hash has to be added. - $chips_detected{$chipdriver} = [] - unless exists $chips_detected{$chipdriver}; - $new_detected_ref = $chips_detected{$chipdriver}; - # Find out whether our new entry should go into the detected list # or not. We compare all i2c addresses; if at least one matches, # but our confidence value is lower, we assume this is a misdetection, @@ -3003,7 +2998,9 @@ sub add_i2c_to_chips_detected } # Now add the new entry to detected - push @$new_detected_ref, $datahash; + $chips_detected{$chipdriver} = [] + unless exists $chips_detected{$chipdriver}; + push @{$chips_detected{$chipdriver}}, $datahash; } # This adds a detection to the above structure.