fireinfo: Import latest fixes for ARM
[ipfire-2.x.git] / src / patches / fireinfo / 0002-ARM-Read-board-model-from-device-tree-in-proc.patch
1 From b9a068e26261007d4a0592fcb47f82658af2c775 Mon Sep 17 00:00:00 2001
2 From: Michael Tremer <michael.tremer@ipfire.org>
3 Date: Mon, 3 Nov 2014 21:33:45 +0100
4 Subject: [PATCH 2/2] ARM: Read board model from device-tree in /proc
5
6 ---
7 src/fireinfo/system.py | 35 +++++++++--------------------------
8 1 file changed, 9 insertions(+), 26 deletions(-)
9
10 diff --git a/src/fireinfo/system.py b/src/fireinfo/system.py
11 index 890f58c05027..195832e9f7eb 100644
12 --- a/src/fireinfo/system.py
13 +++ b/src/fireinfo/system.py
14 @@ -304,27 +304,6 @@ class System(object):
15 """
16 return read_from_file("/sys/class/dmi/id/bios_vendor")
17
18 - def vendor_model_tuple(self):
19 - try:
20 - s = self.__cpuinfo["Hardware"]
21 - except KeyError:
22 - return (None, None)
23 -
24 - if s.startswith("ARM-Versatile"):
25 - return ("ARM", s)
26 -
27 - try:
28 - v, m = s.split(" ", 1)
29 - except ValueError:
30 - if s.startswith("BCM"):
31 - v = "Broadcom"
32 - m = s
33 - else:
34 - v = None
35 - m = s
36 -
37 - return v, m
38 -
39 @property
40 def vendor(self):
41 """
42 @@ -337,8 +316,10 @@ class System(object):
43 break
44
45 if ret is None:
46 - v, m = self.vendor_model_tuple()
47 - ret = v
48 + try:
49 + return self.__cpuinfo["Hardware"]
50 + except KeyError:
51 + pass
52
53 return ret
54
55 @@ -353,9 +334,11 @@ class System(object):
56 if ret:
57 break
58
59 - if ret is None:
60 - v, m = self.vendor_model_tuple()
61 - ret = m
62 + # Read device-tree model if available
63 + ret = read_from_file("/proc/device-tree/model")
64 + if ret:
65 + # replace the NULL byte with which the DT string ends
66 + ret = ret.replace(u"\u0000", "")
67
68 return ret
69
70 --
71 1.9.3
72