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

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