Changeset 720 for lm-sensors/trunk/prog/detect/sensors-detect
- Timestamp:
- 02/01/00 22:12:43 (13 years ago)
- Files:
-
- 1 modified
-
lm-sensors/trunk/prog/detect/sensors-detect (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/prog/detect/sensors-detect
r714 r720 1783 1783 1784 1784 # $_[0]: 1 if ISA bus is prefered, 0 for SMBus 1785 # We build here an array adapters, indexed on the number the adapter has 1786 # at this moment (we assume only loaded adapters are interesting at all; 1787 # everything that got scanned also got loaded). Each entry is a reference 1788 # to a hash containing: 1789 # driver: Name of the adapter driver 1790 # nr_now: Number of the bus now 1791 # nr_later: Number of the bus when the modprobes are done (not included if the 1792 # driver should not be loaded) 1793 # A second array, called 1785 1794 sub generate_modprobes 1786 1795 { 1787 1796 my ($prefer_isa) = @_; 1788 1797 1789 my ($chip,$detection,%adapters,$nr,$i,@optionlist,@probelist); 1798 my ($chip,$detection,$nr,$i,@optionlist,@probelist,$driver,$isa,$adap); 1799 my @adapters; 1790 1800 my $modprobes = ""; 1791 1801 my $configfile = ""; … … 1795 1805 $configfile .= "alias char-major-89 i2c-dev\n"; 1796 1806 1797 # Collect all adapters 1807 # Collect all loaded adapters 1808 open INPUTFILE,"/proc/bus/i2c" or die "Couldn't open /proc/bus/i2c?!?"; 1809 while (<INPUTFILE>) { 1810 my ($dev_nr,$type,$adap,$algo) = /^i2c-(\S+)\s+(\S+)\s+(.*?)\s*\t\s*(.*?)\s+$/; 1811 next if ($type eq "dummy"); 1812 $adapters[$dev_nr]->{driver} = find_adapter_driver($adap,$algo); 1813 } 1814 close INPUTFILE; 1815 1816 # Collect all adapters used 1798 1817 $nr = 0; 1818 $isa = 0; 1799 1819 $modprobes .= "# I2C adapter drivers\n"; 1800 1820 foreach $chip (@chips_detected) { 1801 1821 foreach $detection (@{$chip->{detected}}) { 1802 %adapters->{$detection->{i2c_driver}} = $nr ++ 1803 if exists $detection->{i2c_driver} and 1804 not exists %adapters->{$detection->{i2c_driver}} and 1805 not (exists $detection->{isa_addr} and $prefer_isa); 1806 %adapters->{"i2c-isa"} = $nr ++ 1807 if exists $detection->{isa_addr} and 1808 not exists %adapters->{"i2c-isa"} and 1809 not (exists $detection->{i2c_driver} and not $prefer_isa); 1810 } 1811 } 1812 for ($i = 0; $i < $nr; $i ++) { 1813 foreach $detection (keys %adapters) { 1814 $modprobes .= "modprobe $detection\n", last 1815 if $adapters{$detection} == $i; 1816 } 1817 } 1822 # If there is more than one bus detected by a driver, they are 1823 # still all added. So we number them in the correct order 1824 if (exists $detection->{i2c_driver} and 1825 not exists $adapters[$detection->{i2c_devnr}]->{nr} and 1826 not (exists $detection->{isa_addr} and $prefer_isa)) { 1827 foreach $adap (@adapters) { 1828 $adap->{nr_later} = $nr++ if $adap->{driver} eq $detection->{i2c_driver}; 1829 } 1830 } 1831 if (exists $detection->{isa_addr} and 1832 not (exists $detection->{i2c_driver} and not $prefer_isa)) { 1833 $isa=1; 1834 } 1835 } 1836 } 1837 1838 for ($i = 0; $i < $nr; $i++) { 1839 foreach $adap (@adapters) { 1840 $modprobes .= "modprobe $adap->{driver}\n" if (defined($adap->{nr_later}) and $adap->{nr_later} == $i); 1841 } 1842 } 1843 $modprobes .= "modprobe i2c-isa\n" if ($isa); 1818 1844 1819 1845 # Now determine the chip probe lines … … 1825 1851 @probelist = (); 1826 1852 1827 # Handle detects out-of-range1853 # Handle detects at addresses normally not probed 1828 1854 foreach $detection (@{$chip->{detected}}) { 1829 push @probelist, %adapters->{$detection->{i2c_driver}},1855 push @probelist, $adapters[$detection->{i2c_devnr}]->{nr_later}, 1830 1856 $detection->{i2c_addr} 1831 if exists $detection->{i2c_driver} and 1832 exists %adapters->{$detection->{i2c_driver}} and 1857 if exists $detection->{i2c_addr} and 1833 1858 exists $detection->{i2c_extra}; 1834 1859 push @probelist, -1, $detection->{isa_addr} 1835 1860 if exists $detection->{isa_addr} and 1836 exists %adapters->{"i2c-isa"} and1837 1861 exists $detection->{isa_extra}; 1838 1862 } … … 1840 1864 # Handle misdetects 1841 1865 foreach $detection (@{$chip->{misdetected}}) { 1842 push @optionlist, %adapters->{$detection->{i2c_driver}},1866 push @optionlist, $adapters[$detection->{i2c_devnr}]->{nr_later}, 1843 1867 $detection->{i2c_addr} 1844 if exists $detection->{i2c_ driver} and1845 exists %adapters->{$detection->{i2c_driver}};1868 if exists $detection->{i2c_addr} and 1869 exists $adapters[$detection->{i2c_devnr}]->{nr_later}; 1846 1870 push @optionlist, -1, $detection->{isa_addr} 1847 if exists $detection->{isa_addr} and 1848 exists %adapters->{"i2c-isa"}; 1871 if exists $detection->{isa_addr} and $isa; 1849 1872 } 1850 1873 … … 1853 1876 if (exists $detection->{i2c_driver} and 1854 1877 exists $detection->{isa_addr} and 1855 exists %adapters->{$detection->{i2c_driver}} and1856 exists %adapters->{"i2c-isa"}) {1878 exists $adapters[$detection->{i2c_devnr}]->{nr_later} and 1879 $isa) { 1857 1880 if ($prefer_isa) { 1858 push @optionlist, %adapters->{$detection->{i2c_driver}},1881 push @optionlist,$adapters[$detection->{i2c_devnr}]->{nr_later}, 1859 1882 $detection->{i2c_addr}; 1860 1883 } else {
