]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: move ARM decoding to lscpu-arm.c
authorKarel Zak <kzak@redhat.com>
Mon, 22 Jan 2018 12:08:11 +0000 (13:08 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 22 Jan 2018 12:08:11 +0000 (13:08 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/Makemodule.am
sys-utils/lscpu-arm.c [moved from sys-utils/lscpu-arm.h with 81% similarity]
sys-utils/lscpu.c
sys-utils/lscpu.h

index b8486e836f3390be0fac8af560b27ffed9f525ef..c2e99ca2df40259465068531f34fb8daa0ff1234 100644 (file)
@@ -357,7 +357,7 @@ usrbin_exec_PROGRAMS += lscpu
 lscpu_SOURCES = \
        sys-utils/lscpu.c \
        sys-utils/lscpu.h \
-       sys-utils/lscpu-arm.h \
+       sys-utils/lscpu-arm.c \
        sys-utils/lscpu-dmi.c
 lscpu_LDADD = $(LDADD) libcommon.la libsmartcols.la $(RTAS_LIBS)
 lscpu_CFLAGS = $(AM_CFLAGS) -I$(ul_libsmartcols_incdir)
similarity index 81%
rename from sys-utils/lscpu-arm.h
rename to sys-utils/lscpu-arm.c
index 289a900f1502b390d21811473423f4623d457d92..9cc9362efce8e3864dc0bf3ce8a03818f62fda81 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * lscpu-arm.h - ARM CPU identification tables
+ * lscpu-arm.c - ARM CPU identification tables
  *
  * Copyright (C) 2018 Riku Voipio <riku.voipio@iki.fi>
  *
@@ -23,8 +23,7 @@
  *  - GCC sources: config/arch/arch-cores.def
  *  - Ancient wisdom
  */
-#ifndef LSCPU_ARM_H
-#define LSCPU_ARM_H
+#include "lscpu.h"
 
 struct id_part {
     const int id;
@@ -186,4 +185,43 @@ static const struct hw_impl hw_implementer[] = {
     { -1,   unknown_part, "unknown" },
 };
 
-#endif /* LSCPU_ARM_H */
+void arm_cpu_decode(struct lscpu_desc *desc)
+{
+       int j, impl, part;
+       const struct id_part *parts = NULL;
+       char buf[8];
+       if (desc->vendor == NULL || desc->model == NULL)
+               return;
+       if ((strncmp(desc->vendor,"0x",2) ||
+                strncmp(desc->model,"0x",2) ))
+               return;
+
+       impl=(int)strtol(desc->vendor, NULL, 0);
+       part=(int)strtol(desc->model, NULL, 0);
+
+       for (j = 0; hw_implementer[j].id != -1; j++) {
+       if (hw_implementer[j].id == impl) {
+               parts = hw_implementer[j].parts;
+               desc->vendor = (char *)hw_implementer[j].name;
+               break;
+               }
+       }
+       if ( parts == NULL)
+               return;
+
+       for (j = 0; parts[j].id != -1; j++) {
+       if (parts[j].id == part) {
+               desc->modelname = (char *)parts[j].name;
+               break;
+               }
+       }
+
+       /* Print out the rXpY string for ARM cores */
+       if (impl == 0x41 && desc->revision != NULL &&
+               desc->stepping != NULL) {
+               int revision = atoi(desc->revision);
+               int variant = (int)strtol(desc->stepping, NULL, 0);
+               snprintf(buf, sizeof(buf), "r%dp%d", variant, revision );
+               desc->stepping=xstrdup(buf);
+       }
+}
index 08e5df5bcee3bb43043d88a6c733088383caf03c..6d1fde555e02d64067cdd71ca4ba7bf9e34156d3 100644 (file)
@@ -62,7 +62,6 @@
 #include "optutils.h"
 
 #include "lscpu.h"
-#include "lscpu-arm.h"
 
 #define CACHE_MAX 100
 
@@ -386,47 +385,6 @@ static void read_physical_info_powerpc(
 }
 #endif
 
-static void
-arm_cpu_decode(struct lscpu_desc *desc)
-{
-       int j, impl, part;
-       const struct id_part *parts = NULL;
-       char buf[8];
-       if (desc->vendor == NULL || desc->model == NULL)
-               return;
-       if ((strncmp(desc->vendor,"0x",2) ||
-                strncmp(desc->model,"0x",2) ))
-               return;
-
-       impl=(int)strtol(desc->vendor, NULL, 0);
-       part=(int)strtol(desc->model, NULL, 0);
-
-       for (j = 0; hw_implementer[j].id != -1; j++) {
-       if (hw_implementer[j].id == impl) {
-               parts = hw_implementer[j].parts;
-               desc->vendor = (char *)hw_implementer[j].name;
-               break;
-               }
-       }
-       if ( parts == NULL)
-               return;
-
-       for (j = 0; parts[j].id != -1; j++) {
-       if (parts[j].id == part) {
-               desc->modelname = (char *)parts[j].name;
-               break;
-               }
-       }
-
-       /* Print out the rXpY string for ARM cores */
-       if (impl == 0x41 && desc->revision != NULL &&
-               desc->stepping != NULL) {
-               int revision = atoi(desc->revision);
-               int variant = (int)strtol(desc->stepping, NULL, 0);
-               snprintf(buf, sizeof(buf), "r%dp%d", variant, revision );
-               desc->stepping=xstrdup(buf);
-       }
-}
 
 static void
 read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod)
index 1aa546138bd23098a52ade61137b4711062732b1..3d1885a3ed5e335c14d2073ab23f3537893c1e41 100644 (file)
@@ -183,5 +183,6 @@ struct lscpu_modifier {
 };
 
 extern int read_hypervisor_dmi(void);
+extern void arm_cpu_decode(struct lscpu_desc *desc);
 
 #endif /* LSCPU_H */