All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: David Gibson <david@gibson.dropbear.id.au>,
	Alexander Graf <agraf@suse.de>,
	qemu-ppc@nongnu.org
Subject: [Qemu-devel] [PATCH for-2.11 5/6] ppc: simplify cpu model lookup by PVR
Date: Thu, 24 Aug 2017 10:21:50 +0200	[thread overview]
Message-ID: <1503562911-2776-6-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1503562911-2776-1-git-send-email-imammedo@redhat.com>

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
 target/ppc/translate_init.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/target/ppc/translate_init.c b/target/ppc/translate_init.c
index f1a559d..ca9f1e3 100644
--- a/target/ppc/translate_init.c
+++ b/target/ppc/translate_init.c
@@ -34,6 +34,7 @@
 #include "hw/ppc/ppc.h"
 #include "mmu-book3s-v3.h"
 #include "sysemu/qtest.h"
+#include "qemu/cutils.h"
 
 //#define PPC_DUMP_CPU
 //#define PPC_DEBUG_SPR
@@ -10203,22 +10204,16 @@ static ObjectClass *ppc_cpu_class_by_name(const char *name)
     char *cpu_model, *typename;
     ObjectClass *oc;
     const char *p;
-    int i, len;
-
-    /* Check if the given name is a PVR */
-    len = strlen(name);
-    if (len == 10 && name[0] == '0' && name[1] == 'x') {
-        p = name + 2;
-        goto check_pvr;
-    } else if (len == 8) {
-        p = name;
-    check_pvr:
-        for (i = 0; i < 8; i++) {
-            if (!qemu_isxdigit(*p++))
-                break;
-        }
-        if (i == 8) {
-            return OBJECT_CLASS(ppc_cpu_class_by_pvr(strtoul(name, NULL, 16)));
+    unsigned long pvr;
+
+    /* Lookup by PVR if cpu_model is valid 8 digit hex number
+     * (excl: 0x prefix if present)
+     */
+    if (!qemu_strtoul(name, &p, 16, &pvr)) {
+        int len = p - name;
+        len = (len == 10) && (name[1] == 'x') ? len - 2 : len;
+        if (len == 8) {
+            return OBJECT_CLASS(ppc_cpu_class_by_pvr(pvr));
         }
     }
 
-- 
2.7.4

  parent reply	other threads:[~2017-08-24  8:22 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-24  8:21 [Qemu-devel] [PATCH for-2.11 0/6] ppc: cpu_model handling cleanups Igor Mammedov
2017-08-24  8:21 ` [Qemu-devel] [PATCH for-2.11 1/6] ppc: use macros to make cpu type name from string literal Igor Mammedov
2017-08-25  1:30   ` David Gibson
2017-08-25  7:28     ` Igor Mammedov
2017-08-25 13:24       ` David Gibson
2017-08-24  8:21 ` [Qemu-devel] [PATCH for-2.11 2/6] ppc: make cpu_model translation to type consistent Igor Mammedov
2017-08-25  1:38   ` David Gibson
2017-08-25  7:27     ` Igor Mammedov
2017-08-25  9:45       ` David Gibson
2017-08-25 11:40         ` Igor Mammedov
2017-08-25 13:28           ` David Gibson
2017-08-25 14:34             ` Igor Mammedov
2017-08-29  7:26               ` David Gibson
2017-08-24  8:21 ` [Qemu-devel] [PATCH for-2.11 3/6] ppc: make cpu alias point only to real cpu models Igor Mammedov
2017-08-25  1:40   ` David Gibson
2017-08-24  8:21 ` [Qemu-devel] [PATCH for-2.11 4/6] ppc: replace inter-function cyclic dependency/recurssion with 2 simple lookups Igor Mammedov
2017-08-25  4:12   ` David Gibson
2017-08-25  7:34     ` Igor Mammedov
2017-08-30  3:05       ` David Gibson
2017-08-30  6:16         ` Igor Mammedov
2017-08-24  8:21 ` Igor Mammedov [this message]
2017-08-25  4:16   ` [Qemu-devel] [PATCH for-2.11 5/6] ppc: simplify cpu model lookup by PVR David Gibson
2017-08-25  7:40     ` Igor Mammedov
2017-08-25  9:32       ` David Gibson
2017-08-25 11:41         ` Igor Mammedov
2017-08-30 10:50         ` Igor Mammedov
2017-08-31  5:54           ` David Gibson
2017-08-24  8:21 ` [Qemu-devel] [PATCH for-2.11 6/6] ppc: drop caching ObjectClass from PowerPCCPUAlias Igor Mammedov
2017-08-25  4:22   ` David Gibson
2017-08-25  7:49     ` Igor Mammedov
2017-08-29  7:30       ` 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=1503562911-2776-6-git-send-email-imammedo@redhat.com \
    --to=imammedo@redhat.com \
    --cc=agraf@suse.de \
    --cc=david@gibson.dropbear.id.au \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.