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

* Re: [lm-sensors] [PATCH] sensors-detect: Refactor AMD CPU sensor
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Andreas Herrmann @ 2011-04-06 14:00 UTC (permalink / raw)
  To: lm-sensors

On Wed, Apr 06, 2011 at 03:17:36PM +0200, Jean Delvare wrote:
> 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
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors

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

* Re: [lm-sensors] [PATCH] sensors-detect: Refactor AMD CPU sensor
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Jean Delvare @ 2011-04-06 14:32 UTC (permalink / raw)
  To: lm-sensors

Hi Andreas,

On Wed, 6 Apr 2011 16:00:26 +0200, Andreas Herrmann wrote:
> On Wed, Apr 06, 2011 at 03:17:36PM +0200, Jean Delvare wrote:
> > 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).

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?

-- 
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

* Re: [lm-sensors] [PATCH] sensors-detect: Refactor AMD CPU sensor
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Jean Delvare @ 2011-04-07 14:48 UTC (permalink / raw)
  To: lm-sensors

On Wed, 6 Apr 2011 16:32:27 +0200, Jean Delvare wrote:
> Hi Andreas,
> 
> On Wed, 6 Apr 2011 16:00:26 +0200, Andreas Herrmann wrote:
> > On Wed, Apr 06, 2011 at 03:17:36PM +0200, Jean Delvare wrote:
> > > 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).
> 
> 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.

-- 
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.