From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
To: aik@ozlabs.ru, agraf@suse.de, benh@au1.ibm.com,
david@gibson.dropbear.id.au, paulus@au1.ibm.com,
stewart@linux.vnet.ibm.com
Cc: nacc@linux.vnet.ibm.com, qemu-ppc@nongnu.org, thuth@redhat.com,
qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v3 1/2] target-ppc: Define kvmppc_read_int_dt()
Date: Fri, 13 Nov 2015 18:13:07 -0800 [thread overview]
Message-ID: <1447467188-4458-1-git-send-email-sukadev@linux.vnet.ibm.com> (raw)
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 <sukadev@linux.vnet.ibm.com>
---
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.1.0
next reply other threads:[~2015-11-14 2:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-14 2:13 Sukadev Bhattiprolu [this message]
2015-11-14 2:13 ` [Qemu-devel] [PATCH v3 2/2] target-ppc: Implement rtas_get_sysparm(PROCESSOR_MODULE_INFO) Sukadev Bhattiprolu
2015-11-25 6:30 ` [Qemu-devel] [Qemu-ppc] " Sukadev Bhattiprolu
2015-11-27 6:47 ` David Gibson
2015-11-27 6:47 ` [Qemu-devel] " David Gibson
2015-12-01 19:49 ` Sukadev Bhattiprolu
2015-12-02 2:32 ` David Gibson
2015-12-03 1:42 ` [Qemu-devel] [Qemu-ppc] " Sukadev Bhattiprolu
2015-11-16 7:41 ` [Qemu-devel] [PATCH v3 1/2] target-ppc: Define kvmppc_read_int_dt() David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1447467188-4458-1-git-send-email-sukadev@linux.vnet.ibm.com \
--to=sukadev@linux.vnet.ibm.com \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=benh@au1.ibm.com \
--cc=david@gibson.dropbear.id.au \
--cc=nacc@linux.vnet.ibm.com \
--cc=paulus@au1.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=stewart@linux.vnet.ibm.com \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).