From a0ddf07aadaec6600d5597e4430a0f0270ff011c Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Sat, 22 Nov 2008 18:04:50 +0000 Subject: [PATCH] Handle special case chips more efficiently. Instead of listing every chip twice with just the driver field differing, we put the chip entry in the main list directly and resolve the driver field at run-time. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5402 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + prog/detect/sensors-detect | 65 ++++++++++++-------------------------- 2 files changed, 21 insertions(+), 45 deletions(-) diff --git a/CHANGES b/CHANGES index de8af62a..41e6c63f 100644 --- a/CHANGES +++ b/CHANGES @@ -15,6 +15,7 @@ SVN-HEAD Fix detection of SMSC LPC47M292 Add SMSC LPC47M233 support Drop support for Linux 2.4 (#2325) + Handle special case chips more efficiently 3.0.3 (2008-09-28) libsensors: Avoid namespace pollution diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index 09947462..62a4e11f 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -1286,6 +1286,12 @@ use vars qw(@pci_adapters_sis5595 @pci_adapters_sis96x); i2c_addrs => [0x50..0x53], i2c_detect => sub { ddcmonitor_detect(@_); }, }, + { + name => "FSC Poseidon I", + driver => sub { kernel_version_at_least(2, 6, 24) ? "fschmd" : "fscpos" }, + i2c_addrs => [0x73], + i2c_detect => sub { fsc_detect(0, @_); }, + }, { name => "FSC Poseidon II", driver => "to-be-written", @@ -1298,6 +1304,12 @@ use vars qw(@pci_adapters_sis5595 @pci_adapters_sis96x); i2c_addrs => [0x73], i2c_detect => sub { fsc_detect(2, @_); }, }, + { + name => "FSC Hermes", + driver => sub { kernel_version_at_least(2, 6, 24) ? "fschmd" : "fscher" }, + i2c_addrs => [0x73], + i2c_detect => sub { fsc_detect(3, @_); }, + }, { name => "FSC Heimdal", driver => "fschmd", @@ -1402,41 +1414,6 @@ use vars qw(@pci_adapters_sis5595 @pci_adapters_sis96x); }, ); -# Special case chip information goes here and would be included in -# the chip_special_cases routine below -use vars qw(@chip_oldfsc_ids @chip_fschmd_ids); - -# sigh special case for old seperate FSC drivers to new merged one mapping -@chip_oldfsc_ids = ( - { - name => "FSC Poseidon I", - driver => "fscpos", - i2c_addrs => [0x73], - i2c_detect => sub { fsc_detect(0, @_); }, - }, - { - name => "FSC Hermes", - driver => "fscher", - i2c_addrs => [0x73], - i2c_detect => sub { fsc_detect(3, @_); }, - }, -); - -@chip_fschmd_ids = ( - { - name => "FSC Poseidon I", - driver => "fschmd", - i2c_addrs => [0x73], - i2c_detect => sub { fsc_detect(0, @_); }, - }, - { - name => "FSC Hermes", - driver => "fschmd", - i2c_addrs => [0x73], - i2c_detect => sub { fsc_detect(3, @_); }, - }, -); - # This is a list of all recognized superio chips. # Each entry must have the following fields: @@ -3437,18 +3414,16 @@ sub scan_cpu($) # CHIP DETECTION # ################## -# This routine allows you to select which chips are optionally added to the -# chip detection list. The most common use is to allow for different chip -# detection/drivers based on different linux kernels -# This routine follows the pattern of the SiS adapter special cases +# This routine allows you to dynamically update the chip detection list. +# The most common use is to allow for different chip to driver mappings +# based on different linux kernels sub chip_special_cases { - # Based on the kernel, add the appropriate chip structures to the - # chip_ids detection list - if (kernel_version_at_least(2, 6, 24)) { - push @chip_ids, @chip_fschmd_ids; - } else { - push @chip_ids, @chip_oldfsc_ids; + # Some chip to driver mappings depend on the environment + foreach my $chip (@chip_ids) { + if (ref($chip->{driver}) eq 'CODE') { + $chip->{driver} = $chip->{driver}->(); + } } }