[PATCH] sensors-detect: Refactor AMD CPU sensor detection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
Jean Delvare

_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors



[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux