Skip to contentSkip to conversation

sensors-detect: Report proper processor information on ppc

PATCH In review Jean Delvare 2 participants 2 messages Sep 26, 2016 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sensors-detect: Report proper processor information on ppc

The format of /proc/cpuinfo on ppc differs from the x86 format. Add the missing pieces to the parsing code so that ppc processor information is reported properly.

---
 prog/detect/sensors-detect |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
prog/detect/sensors-detect +6 -2
@@ -2864,7 +2864,7 @@ sub initialize_cpu_list
 			};
 			next;
 		}
-		if (m/^(vendor_id|cpu family|model|model name|stepping|cpuid level)\s*:\s*(.+)$/) {
+		if (m/^(vendor_id|cpu family|model|model name|stepping|cpuid level|cpu|revision)\s*:\s*(.+)$/) {
 			my $k = $1;
 			my $v = $2;
 			$v =~ s/\s+/ /g;	# Merge multiple spaces
@@ -2880,7 +2880,11 @@ sub initialize_cpu_list
 sub print_cpu_info
 {
 	my $cpu = $cpu[0];
-	print "# Processor: $cpu->{'model name'} ($cpu->{'cpu family'}/$cpu->{model}/$cpu->{stepping})\n";
+	if (defined  $cpu->{'model name'}) {
+		print "# Processor: $cpu->{'model name'} ($cpu->{'cpu family'}/$cpu->{model}/$cpu->{stepping})\n";
+	} elsif (defined $cpu->{'cpu'}) {	# ppc
+		print "# Processor: $cpu->{'cpu'}, revision $cpu->{'revision'}\n";
+	}
 }
 
 # @i2c_adapters is a list of references to hashes, one hash per I2C/SMBus
Signature · 2 lines
Jean Delvare
SUSE L3 Support
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Jean Delvare

The format of /proc/cpuinfo on ppc differs from the x86 format. Add the missing pieces to the parsing code so that ppc processor information is reported properly.
---

Quoted 29 lines
 prog/detect/sensors-detect |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
prog/detect/sensors-detect +6 -2
@@ -2864,7 +2864,7 @@ sub initialize_cpu_list
 			};
 			next;
 		}
-		if (m/^(vendor_id|cpu family|model|model name|stepping|cpuid level)\s*:\s*(.+)$/) {
+		if (m/^(vendor_id|cpu family|model|model name|stepping|cpuid level|cpu|revision)\s*:\s*(.+)$/) {
 			my $k = $1;
 			my $v = $2;
 			$v =~ s/\s+/ /g;	# Merge multiple spaces
@@ -2880,7 +2880,11 @@ sub initialize_cpu_list
 sub print_cpu_info
 {
 	my $cpu = $cpu[0];
-	print "# Processor: $cpu->{'model name'} ($cpu->{'cpu family'}/$cpu->{model}/$cpu->{stepping})\n";
+	if (defined  $cpu->{'model name'}) {
+		print "# Processor: $cpu->{'model name'} ($cpu->{'cpu family'}/$cpu->{model}/$cpu->{stepping})\n";
+	} elsif (defined $cpu->{'cpu'}) {	# ppc
+		print "# Processor: $cpu->{'cpu'}, revision $cpu->{'revision'}\n";
+	}
 }
 
 # @i2c_adapters is a list of references to hashes, one hash per I2C/SMBus