From 96ff880b93b374c9f72da79815447b2af8db2a25 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 5 Jul 2010 18:40:44 +0000 Subject: [PATCH] Fix r5847 was incomplete. Handling misdetections that happen after correct detections isn't sufficient, we also have to handle misdetections which happen first. In that case, we must delete the driver entry as we remove the last misdetection from it. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5849 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/detect/sensors-detect | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index f2a69e1f..e797cecb 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -2951,7 +2951,7 @@ use vars qw(%chips_detected); sub add_i2c_to_chips_detected { my ($chipdriver, $datahash) = @_; - my ($i, $detected_ref, $detected_entry, + my ($i, $detected_ref, $detected_entry, $driver, $put_in_detected, @hash_addrs, @entry_addrs); # Find out whether our new entry should go into the detected list @@ -2984,7 +2984,8 @@ sub add_i2c_to_chips_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 $detected_ref (values %chips_detected) { + foreach $driver (keys %chips_detected) { + $detected_ref = $chips_detected{$driver}; for ($i = @$detected_ref-1; $i >=0; $i--) { next unless defined $detected_ref->[$i]->{i2c_addr}; @entry_addrs = ($detected_ref->[$i]->{i2c_addr}); @@ -2993,6 +2994,8 @@ sub add_i2c_to_chips_detected if ($detected_ref->[$i]->{i2c_devnr} == $datahash->{i2c_devnr} && any_list_match(\@entry_addrs, \@hash_addrs)) { splice @$detected_ref, $i, 1; + delete $chips_detected{$driver} + if (!@$detected_ref); } } }