Blame SOURCES/0001-sensors-detect-Fix-printing-CPU-info-on-ppc-and-arm.patch

a6904f
From c28d20d19d620f42d239ed4b35139683035f11dc Mon Sep 17 00:00:00 2001
a6904f
From: =?UTF-8?q?Ond=C5=99ej=20Lyson=C4=9Bk?= <olysonek@redhat.com>
a6904f
Date: Thu, 17 Oct 2019 10:07:21 +0200
a6904f
Subject: [PATCH] sensors-detect: Fix printing CPU info on ppc and arm
a6904f
a6904f
The format of /proc/cpuinfo on other arches is different from the
a6904f
format on x86. Modify the print_cpu_info function to handle arm and
a6904f
ppc.
a6904f
a6904f
This change also eliminates Perl warnings caused by non-existent
a6904f
elements in the %cpu hash:
a6904f
Use of uninitialized value in concatenation (.) or string at
a6904f
./prog/detect/sensors-detect line 3124.
a6904f
a6904f
Based on a patch from Changqing Li <changqing.li@windriver.com>,
a6904f
GitHub PR: https://github.com/lm-sensors/lm-sensors/pull/168
a6904f
---
a6904f
 prog/detect/sensors-detect | 13 +++++++++++--
a6904f
 1 file changed, 11 insertions(+), 2 deletions(-)
a6904f
a6904f
diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect
a6904f
index c2cbe9b9..78b0b5a1 100755
a6904f
--- a/prog/detect/sensors-detect
a6904f
+++ b/prog/detect/sensors-detect
a6904f
@@ -3130,7 +3130,7 @@ sub initialize_cpu_list
a6904f
 			};
a6904f
 			next;
a6904f
 		}
a6904f
-		if (m/^(vendor_id|cpu family|model|model name|stepping|cpuid level)\s*:\s*(.+)$/) {
a6904f
+		if (m/^(vendor_id|cpu family|model|model name|stepping|cpuid level|cpu|revision)\s*:\s*(.+)$/) {
a6904f
 			my $k = $1;
a6904f
 			my $v = $2;
a6904f
 			$v =~ s/\s+/ /g;	# Merge multiple spaces
a6904f
@@ -3146,7 +3146,16 @@ sub initialize_cpu_list
a6904f
 sub print_cpu_info
a6904f
 {
a6904f
 	my $cpu = $cpu[0];
a6904f
-	print "# Processor: $cpu->{'model name'} ($cpu->{'cpu family'}/$cpu->{model}/$cpu->{stepping})\n";
a6904f
+	if ($kernel_arch =~ m/^ppc(64(le)?)?$/) {
a6904f
+		print "# Processor: $cpu->{cpu} ($cpu->{revision})\n";
a6904f
+	} elsif ($kernel_arch =~ m/^arm/) {
a6904f
+		print "# Processor: $cpu->{'model name'}\n";
a6904f
+	} elsif (exists $cpu->{'model name'} && exists $cpu->{'cpu family'}
a6904f
+	         && exists $cpu->{'model'} && exists $cpu->{'stepping'}) {
a6904f
+		print "# Processor: $cpu->{'model name'} ($cpu->{'cpu family'}/$cpu->{model}/$cpu->{stepping})\n";
a6904f
+	} else {
a6904f
+		print "# Cannot show processor info on $kernel_arch architecture.\n";
a6904f
+	}
a6904f
 }
a6904f
 
a6904f
 # @i2c_adapters is a list of references to hashes, one hash per I2C/SMBus
a6904f
-- 
a6904f
2.20.1
a6904f