Changeset 4472
- Timestamp:
- 06/26/07 09:47:30 (6 years ago)
- Location:
- lm-sensors/branches/lm-sensors-3.0.0
- Files:
-
- 2 modified
-
CHANGES (modified) (1 diff)
-
prog/detect/sensors-detect (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/CHANGES
r4469 r4472 47 47 Fix IPMI support for 2.6 kernels 48 48 Add detection for non-standard SMSC Super-I/Os 49 No longer depend on i2cdetect 49 50 50 51 -
lm-sensors/branches/lm-sensors-3.0.0/prog/detect/sensors-detect
r4469 r4472 35 35 use File::Basename; 36 36 37 # We will call modprobe and i2cdetect, which typically livein either /sbin,37 # We will call modprobe, which typically lives in either /sbin, 38 38 # /usr/sbin or /usr/local/bin. So make sure these are all in the PATH. 39 39 foreach ('/usr/sbin', '/usr/local/sbin', '/sbin') { … … 2298 2298 } 2299 2299 2300 # @i2c_adapters is a list of references to hashes, one hash per I2C/SMBus 2301 # adapter present on the system. Each entry has the following keys: name 2302 # (directly taken from either /proc/bus/i2c or /sys/class/i2c-adapter) and 2303 # driver. 2304 use vars qw(@i2c_adapters); 2305 2306 sub initialize_i2c_adapters_list 2307 { 2308 my $entry; 2309 local $_; 2310 2311 if (defined $sysfs_root) { 2312 my $class_dir = "${sysfs_root}/class/i2c-adapter"; 2313 opendir(local *ADAPTERS, $class_dir) or return; 2314 2315 while (defined($_ = readdir(ADAPTERS))) { 2316 next unless m/^i2c-(\d+)$/; 2317 $entry = {}; # New entry 2318 $entry->{'name'} = sysfs_device_attribute("${class_dir}/i2c-$1", "name") 2319 || sysfs_device_attribute("${class_dir}/i2c-$1/device", "name"); 2320 $entry->{'driver'} = find_adapter_driver($entry->{'name'}); 2321 $i2c_adapters[$1] = $entry; 2322 } 2323 closedir(ADAPTERS); 2324 } else { 2325 open(local *INPUTFILE, "/proc/bus/i2c") or return; 2326 2327 while (<INPUTFILE>) { 2328 my ($nr, $type, $name) = /^i2c-(\d+)\s+(\S+)\s+(.*?) *(\t|$)/; 2329 next if ($type eq "dummy" || $type eq "isa"); 2330 $entry = {}; # New entry 2331 $entry->{'name'} = $name; 2332 $entry->{'driver'} = find_adapter_driver($name); 2333 $i2c_adapters[$nr] = $entry; 2334 } 2335 close(INPUTFILE); 2336 } 2337 } 2338 2300 2339 ########### 2301 2340 # MODULES # … … 2543 2582 } 2544 2583 2545 # $_[0]: Adapter description as found in /proc/bus/i2c 2584 # $_[0]: Adapter description as found in /proc/bus/i2c or sysfs 2546 2585 sub find_adapter_driver 2547 2586 { … … 5496 5535 my ($chip,$detection,$nr,$i,@optionlist,@probelist,$driver,$isa,$adap); 5497 5536 my $ipmi = 0; 5498 my @adapters;5499 5537 my $modprobes = ""; 5500 5538 my $configfile = ""; … … 5503 5541 $configfile .= "# I2C module options\n"; 5504 5542 $configfile .= "alias char-major-89 i2c-dev\n"; 5505 5506 # Collect all loaded adapters5507 # i2cdetect -l either cats /proc/bus/i2c or scans sysfs for the same information5508 open(local *INPUTFILE, "i2cdetect -l |") or die "Couldn't find i2cdetect program!!";5509 local $_;5510 while (<INPUTFILE>) {5511 my ($dev_nr, $type, $adap) = /^i2c-(\d+)\s+(\S+)\s+(.*?) *(\t|$)/;5512 next if ($type eq "dummy" || $type eq "isa");5513 $adapters[$dev_nr]->{driver} = find_adapter_driver($adap);5514 $adapters[$dev_nr]->{adapname} = $adap;5515 }5516 close INPUTFILE;5517 5543 5518 5544 # Collect all adapters used … … 5524 5550 # still all added. So we number them in the correct order 5525 5551 if (exists $detection->{i2c_driver} and 5526 not exists $ adapters[$detection->{i2c_devnr}]->{nr_later} and5552 not exists $i2c_adapters[$detection->{i2c_devnr}]->{nr_later} and 5527 5553 not (exists $detection->{isa_addr} and $prefer_isa)) { 5528 foreach $adap (@ adapters) {5554 foreach $adap (@i2c_adapters) { 5529 5555 next unless exists $adap->{driver}; 5530 5556 $adap->{nr_later} = $nr++ if $adap->{driver} eq $detection->{i2c_driver}; … … 5544 5570 $modprobes .= "# I2C adapter drivers\n" if $nr; 5545 5571 for ($i = 0; $i < $nr; $i++) { 5546 foreach $adap (@ adapters) {5572 foreach $adap (@i2c_adapters) { 5547 5573 next unless exists $adap->{nr_later} and $adap->{nr_later} == $i; 5548 5574 if ($adap->{driver} eq "UNKNOWN") { 5549 $modprobes .= "# modprobe unknown adapter ".$adap->{ adapname}."\n";5575 $modprobes .= "# modprobe unknown adapter ".$adap->{name}."\n"; 5550 5576 } elsif ($adap->{driver} eq "DISABLED") { 5551 $modprobes .= "# modprobe disabled adapter ".$adap->{ adapname}."\n";5577 $modprobes .= "# modprobe disabled adapter ".$adap->{name}."\n"; 5552 5578 } elsif ($adap->{driver} eq "to-be-written") { 5553 $modprobes .= "# no driver available for adapter ".$adap->{ adapname}."\n";5579 $modprobes .= "# no driver available for adapter ".$adap->{name}."\n"; 5554 5580 } else { 5555 5581 $modprobes .= "modprobe $adap->{driver}\n" … … 5603 5629 # Handle misdetects 5604 5630 foreach $detection (@{$chip->{misdetected}}) { 5605 push @optionlist, $ adapters[$detection->{i2c_devnr}]->{nr_later},5631 push @optionlist, $i2c_adapters[$detection->{i2c_devnr}]->{nr_later}, 5606 5632 $detection->{i2c_addr} 5607 5633 if exists $detection->{i2c_addr} and 5608 exists $ adapters[$detection->{i2c_devnr}]->{nr_later};5634 exists $i2c_adapters[$detection->{i2c_devnr}]->{nr_later}; 5609 5635 push @optionlist, -1, $detection->{isa_addr} 5610 5636 if exists $detection->{isa_addr} and $isa; … … 5615 5641 if (exists $detection->{i2c_driver} and 5616 5642 exists $detection->{isa_addr} and 5617 exists $ adapters[$detection->{i2c_devnr}]->{nr_later} and5643 exists $i2c_adapters[$detection->{i2c_devnr}]->{nr_later} and 5618 5644 $isa) { 5619 5645 if ($prefer_isa) { 5620 push @optionlist, $adapters[$detection->{i2c_devnr}]->{nr_later},5646 push @optionlist, $i2c_adapters[$detection->{i2c_devnr}]->{nr_later}, 5621 5647 $detection->{i2c_addr}; 5622 5648 } else { … … 5704 5730 print "If you have undetectable or unsupported adapters, you can have them\n". 5705 5731 "scanned by manually loading the modules before running this script.\n\n"; 5732 initialize_i2c_adapters_list(); 5706 5733 5707 5734 if (!exists($modules_list{"i2c-dev"}) … … 5733 5760 5734 5761 my ($inp,@not_to_scan,$inp2); 5735 # i2cdetect -l either cats /proc/bus/i2c or scans sysfs for the same information 5736 open(local *INPUTFILE, "i2cdetect -l |") or die "Couldn't find i2cdetect program!!"; 5737 local $_; 5738 while (<INPUTFILE>) { 5739 my ($dev_nr, $type, $adap) = /^i2c-(\d+)\s+(\S+)\s+(.*?) *(\t|$)/; 5740 next if ($type eq "dummy" || $type eq "isa"); 5762 for (my $dev_nr = 0; $dev_nr < @i2c_adapters; $dev_nr++) { 5763 next unless exists $i2c_adapters[$dev_nr]; 5764 my $adap = $i2c_adapters[$dev_nr]->{'name'}; 5741 5765 print "\n"; 5742 5766 print "Next adapter: $adap (i2c-$dev_nr)\n"; … … 5755 5779 @not_to_scan = parse_not_to_scan 0,0x7f,$inp2; 5756 5780 } 5757 scan_adapter $dev_nr, $adap, find_adapter_driver($adap),5781 scan_adapter $dev_nr, $adap, $i2c_adapters[$dev_nr]->{'driver'}, 5758 5782 \@not_to_scan unless $inp =~ /^\s*[Nn]/; 5759 5783 }
