Changeset 5244

Show
Ignore:
Timestamp:
05/09/08 20:01:00 (3 months ago)
Author:
khali
Message:

Fix the parsing of I2C addresses not to scan.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lm-sensors/trunk/CHANGES

    r5234 r5244  
    1818                          Add Intel ICH10 (bus) detection 
    1919                          Don't probe I2C addresses 0x40-0x47 
     20                          Fix the parsing of I2C addresses not to scan 
    2021 
    21222.10.6 "Welcome Home Lina" (20080306) 
  • lm-sensors/trunk/prog/detect/sensors-detect

    r5234 r5244  
    20742074} 
    20752075 
     2076# Address can be decimal or hexadecimal 
     2077sub valid_address 
     2078{ 
     2079  my $value = shift; 
     2080 
     2081  if ($value !~ m/^(0x[0-9a-f]+|[0-9]+)$/i) { 
     2082    print "$value is not a valid address, sorry.\n"; 
     2083    exit -1; 
     2084  } 
     2085  $value = oct($value) if $value =~ /^0x/i; 
     2086 
     2087  return $value; 
     2088} 
     2089 
    20762090sub parse_not_to_scan 
    20772091{ 
     
    20812095  my $range; 
    20822096  foreach $range (@ranges) { 
    2083     my ($start,$end) = split /\s*-s*/, $range; 
    2084     $start = oct $start if $start =~ /^0/
     2097    my ($start, $end) = split /\s*-\s*/, $range; 
     2098    $start = valid_address($start)
    20852099    if (defined $end) { 
    2086       $end = oct $end if $end =~ /^0/; 
     2100      $end = valid_address($end); 
     2101      if ($end <= $start) { 
     2102        print "$start-$end is not a valid range, sorry.\n"; 
     2103        exit -1; 
     2104      } 
    20872105      $start = $min if $start < $min; 
    20882106      $end = $max if $end > $max; 
    2089       push @res, ($start+0..$end+0); 
     2107      push @res, ($start..$end); 
    20902108    } else { 
    2091       push @res, $start+0 if $start >= $min and $start <= $max; 
     2109      push @res, $start if $start >= $min and $start <= $max; 
    20922110    } 
    20932111  } 
     
    30423060  foreach $addr (@{$i2c_addresses_to_scan}) { 
    30433061    # As the not_to_scan list is sorted, we can check it fast 
     3062    shift @not_to_scan # User skipped an address which we didn't intend to probe anyway 
     3063      while (@not_to_scan and $not_to_scan[0] < $addr); 
    30443064    if (@not_to_scan and $not_to_scan[0] == $addr) { 
    30453065      shift @not_to_scan; 
     
    56765696      $inp2 = <STDIN>; 
    56775697      chop $inp2; 
    5678       @not_to_scan = parse_not_to_scan 0,0x7f,$inp2
     5698      @not_to_scan = parse_not_to_scan(0x03, 0x77, $inp2)
    56795699    } 
    56805700    scan_adapter $dev_nr, $adap, $i2c_adapters[$dev_nr]->{'driver'},