sensors-detect: Refactor AMD CPU sensor
PATCH 1/1 sensors-detect: Refactor AMD CPU sensor
Except for the Family 10h case which is more complex, AMD CPU sensor detection is straightforward, so we don't really need a dedicated function for each CPU family. By passing the expected F3 PCI device ID as a parameter, we can use the same function for all families.
Objection anyone? This could be seen as moving some of the detection code into @cpu_ids itself, but OTOH it saves quite a few lines of redundant code.
--- prog/detect/sensors-detect | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-)
Index: prog/detect/sensors-detect
=================================--- prog/detect/sensors-detect (révision 5955)
+++ prog/detect/sensors-detect (copie de travail)
@@ -2172,7 +2172,7 @@
}, {
name => "AMD K8 thermal sensors", driver => "k8temp",
- detect => \&k8temp_pci_detect,
+ detect => sub { amd_pci_detect('1103') },
}, {
name => "AMD Family 10h thermal sensors", driver => "k10temp",
@@ -2180,15 +2180,15 @@
}, {
name => "AMD Family 11h thermal sensors", driver => "k10temp",
- detect => \&fam11h_pci_detect,
+ detect => sub { amd_pci_detect('1303') },
}, {
name => "AMD Family 12h and 14h thermal sensors", driver => "k10temp",
- detect => \&fam12h_14h_pci_detect,
+ detect => sub { amd_pci_detect('1703') },
}, {
name => "AMD Family 15h thermal sensors", driver => "k10temp",
- detect => \&fam15h_pci_detect,
+ detect => sub { amd_pci_detect('1603') },
}, {
name => "Intel digital thermal sensor", driver => "coretemp",
@@ -6098,9 +6098,10 @@
return 9;
}
-sub k8temp_pci_detect
+sub amd_pci_detect
{
- return unless exists $pci_list{'1022:1103'};
+ my $f3_id = shift;
+ return unless exists $pci_list{"1022:$f3_id"};
return 9;
}
@@ -6130,24 +6131,6 @@
return;
}
-sub fam11h_pci_detect
-{
- return unless exists $pci_list{'1022:1303'};
- return 9;
-}
-
-sub fam12h_14h_pci_detect
-{
- return unless exists $pci_list{'1022:1703'};
- return 9;
-}
-
-sub fam15h_pci_detect
-{
- return unless exists $pci_list{'1022:1603'};
- return 9;
-}
-
sub intel_amb_detect
{
if ((exists $pci_list{'8086:25f0'}) || # Intel 5000
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 8 lines · Jean Delvare
Except for the Family 10h case which is more complex, AMD CPU sensor detection is straightforward, so we don't really need a dedicated function for each CPU family. By passing the expected F3 PCI device ID as a parameter, we can use the same function for all families.
Objection anyone? This could be seen as moving some of the detection code into @cpu_ids itself, but OTOH it saves quite a few lines of redundant code.
No objections -- of cours, it's a good idea.
BTW, detection for "AMD Family 15h thermal sensors" can also be used for f15h_power (once the driver is accepted/integrated).
Regards,
Andreas
_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Hi Andreas,
Quoted 6 lines · Andreas Herrmann
Quoted 5 lines · Jean Delvare
Except for the Family 10h case which is more complex, AMD CPU sensor detection is straightforward, so we don't really need a dedicated function for each CPU family. By passing the expected F3 PCI device ID as a parameter, we can use the same function for all families.
Quoted 8 lines
Quoted 3 lines
Objection anyone? This could be seen as moving some of the detection code into @cpu_ids itself, but OTOH it saves quite a few lines of redundant code.
No objections -- of cours, it's a good idea.
BTW, detection for "AMD Family 15h thermal sensors" can also be used for
f15h_power(once the driver is accepted/integrated).
Yes and no. A similar logic can be used, but the PCI device ID is different. Will you send a patch, or should I add it myself?
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 13 lines · Jean Delvare
Hi Andreas,
Quoted 10 lines · Andreas Herrmann
Quoted 8 lines · Jean Delvare
Except for the Family 10h case which is more complex, AMD CPU sensor detection is straightforward, so we don't really need a dedicated function for each CPU family. By passing the expected F3 PCI device ID as a parameter, we can use the same function for all families.
Objection anyone? This could be seen as moving some of the detection code into @cpu_ids itself, but OTOH it saves quite a few lines of redundant code.
Quoted 7 lines
Quoted 4 lines
No objections -- of cours, it's a good idea.
BTW, detection for "AMD Family 15h thermal sensors" can also be used for
f15h_power(once the driver is accepted/integrated).Yes and no. A similar logic can be used, but the PCI device ID is different. Will you send a patch, or should I add it myself?
Oh well, it was so easy, I've just done it myself.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors