[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 02/16] target-ppc: Define kvmppc_read_int_dt()
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 02/16] target-ppc: Define kvmppc_read_int_dt() |
Date: |
Mon, 11 Jan 2016 15:37:24 +1100 |
From: Sukadev Bhattiprolu <address@hidden>
Extract code from the function kvmppc_read_int_cpu_dt() that actually
reads the file into a separate function, so it can be called from
other places.
Signed-off-by: Sukadev Bhattiprolu <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
target-ppc/kvm.c | 36 ++++++++++++++++++++++--------------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c
index ac70f08..9940a90 100644
--- a/target-ppc/kvm.c
+++ b/target-ppc/kvm.c
@@ -1838,13 +1838,8 @@ static int kvmppc_find_cpu_dt(char *buf, int buf_len)
return 0;
}
-/* Read a CPU node property from the host device tree that's a single
- * integer (32-bit or 64-bit). Returns 0 if anything goes wrong
- * (can't find or open the property, or doesn't understand the
- * format) */
-static uint64_t kvmppc_read_int_cpu_dt(const char *propname)
+static uint64_t kvmppc_read_int_dt(const char *filename)
{
- char buf[PATH_MAX], *tmp;
union {
uint32_t v32;
uint64_t v64;
@@ -1852,14 +1847,7 @@ static uint64_t kvmppc_read_int_cpu_dt(const char
*propname)
FILE *f;
int len;
- if (kvmppc_find_cpu_dt(buf, sizeof(buf))) {
- return -1;
- }
-
- tmp = g_strdup_printf("%s/%s", buf, propname);
-
- f = fopen(tmp, "rb");
- g_free(tmp);
+ f = fopen(filename, "rb");
if (!f) {
return -1;
}
@@ -1877,6 +1865,26 @@ static uint64_t kvmppc_read_int_cpu_dt(const char
*propname)
return 0;
}
+/* Read a CPU node property from the host device tree that's a single
+ * integer (32-bit or 64-bit). Returns 0 if anything goes wrong
+ * (can't find or open the property, or doesn't understand the
+ * format) */
+static uint64_t kvmppc_read_int_cpu_dt(const char *propname)
+{
+ char buf[PATH_MAX], *tmp;
+ uint64_t val;
+
+ if (kvmppc_find_cpu_dt(buf, sizeof(buf))) {
+ return -1;
+ }
+
+ tmp = g_strdup_printf("%s/%s", buf, propname);
+ val = kvmppc_read_int_dt(tmp);
+ g_free(tmp);
+
+ return val;
+}
+
uint64_t kvmppc_get_clockfreq(void)
{
return kvmppc_read_int_cpu_dt("clock-frequency");
--
2.5.0
- [Qemu-ppc] [PULL 00/16] ppc-for-2.6 queue 20160111, David Gibson, 2016/01/10
- [Qemu-ppc] [PULL 14/16] hw/ppc/spapr: Use XHCI as host controller for new spapr machines, David Gibson, 2016/01/10
- [Qemu-ppc] [PULL 16/16] hw/ppc/spapr: fix spapr->kvm_type leak, David Gibson, 2016/01/10
- [Qemu-ppc] [PULL 09/16] pseries: Use SET_MACHINE_COMPAT, David Gibson, 2016/01/10
- [Qemu-ppc] [PULL 10/16] pseries: DEFINE_SPAPR_MACHINE, David Gibson, 2016/01/10
- [Qemu-ppc] [PULL 12/16] pseries: Improve setting of default machine version, David Gibson, 2016/01/10
- [Qemu-ppc] [PULL 15/16] spapr vio: fix to incomplete QOMify, David Gibson, 2016/01/10
- [Qemu-ppc] [PULL 04/16] pseries: Remove redundant setting of mc->name for pseries-2.5 machine, David Gibson, 2016/01/10
- [Qemu-ppc] [PULL 13/16] pseries: Add pseries-2.6 machine type, David Gibson, 2016/01/10
- [Qemu-ppc] [PULL 01/16] hw/ppc/spapr_rtc: Remove bad class_size value, David Gibson, 2016/01/10
- [Qemu-ppc] [PULL 02/16] target-ppc: Define kvmppc_read_int_dt(),
David Gibson <=
- [Qemu-ppc] [PULL 03/16] spapr: Add /system-id, David Gibson, 2016/01/10
- [Qemu-ppc] [PULL 07/16] pseries: Remove versions from mc->desc, David Gibson, 2016/01/10
- [Qemu-ppc] [PULL 08/16] Move SET_MACHINE_COMPAT macro to boards.h, David Gibson, 2016/01/10
- [Qemu-ppc] [PULL 06/16] pseries: Remove redundant calls to spapr_machine_initfn(), David Gibson, 2016/01/10
- [Qemu-ppc] [PULL 11/16] pseries: Restructure class_options functions, David Gibson, 2016/01/10
- [Qemu-ppc] [PULL 05/16] pseries: Rearrange versioned machine type code, David Gibson, 2016/01/10
- Re: [Qemu-ppc] [PULL 00/16] ppc-for-2.6 queue 20160111, Peter Maydell, 2016/01/11