All of lore.kernel.org
 help / color / mirror / Atom feed
* [lm-sensors] [PATCH] sensors-detect: Refactor AMD CPU sensor
@ 2011-04-06 13:17 Jean Delvare
  2011-04-06 14:00 ` Andreas Herrmann
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jean Delvare @ 2011-04-06 13:17 UTC (permalink / raw)
  To: lm-sensors

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@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-04-07 14:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-06 13:17 [lm-sensors] [PATCH] sensors-detect: Refactor AMD CPU sensor Jean Delvare
2011-04-06 14:00 ` Andreas Herrmann
2011-04-06 14:32 ` Jean Delvare
2011-04-07 14:48 ` Jean Delvare

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.