From nobody Sun Feb 8 23:05:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1503563275033937.0469815539507; Thu, 24 Aug 2017 01:27:55 -0700 (PDT) Received: from localhost ([::1]:47208 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dknUX-0004RR-W8 for importer@patchew.org; Thu, 24 Aug 2017 04:27:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dknOs-0008G2-Hw for qemu-devel@nongnu.org; Thu, 24 Aug 2017 04:22:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dknOr-0006ii-OM for qemu-devel@nongnu.org; Thu, 24 Aug 2017 04:22:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40054) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dknOr-0006iE-Io; Thu, 24 Aug 2017 04:22:01 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 936535D686; Thu, 24 Aug 2017 08:22:00 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.34.112.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 97BEB69AFD; Thu, 24 Aug 2017 08:21:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 936535D686 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=imammedo@redhat.com From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 24 Aug 2017 10:21:50 +0200 Message-Id: <1503562911-2776-6-git-send-email-imammedo@redhat.com> In-Reply-To: <1503562911-2776-1-git-send-email-imammedo@redhat.com> References: <1503562911-2776-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 24 Aug 2017 08:22:00 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH for-2.11 5/6] ppc: simplify cpu model lookup by PVR X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-ppc@nongnu.org, Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Igor Mammedov --- 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" =20 //#define PPC_DUMP_CPU //#define PPC_DEBUG_SPR @@ -10203,22 +10204,16 @@ static ObjectClass *ppc_cpu_class_by_name(const c= har *name) char *cpu_model, *typename; ObjectClass *oc; const char *p; - int i, len; - - /* Check if the given name is a PVR */ - len =3D strlen(name); - if (len =3D=3D 10 && name[0] =3D=3D '0' && name[1] =3D=3D 'x') { - p =3D name + 2; - goto check_pvr; - } else if (len =3D=3D 8) { - p =3D name; - check_pvr: - for (i =3D 0; i < 8; i++) { - if (!qemu_isxdigit(*p++)) - break; - } - if (i =3D=3D 8) { - return OBJECT_CLASS(ppc_cpu_class_by_pvr(strtoul(name, NULL, 1= 6))); + 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 =3D p - name; + len =3D (len =3D=3D 10) && (name[1] =3D=3D 'x') ? len - 2 : len; + if (len =3D=3D 8) { + return OBJECT_CLASS(ppc_cpu_class_by_pvr(pvr)); } } =20 --=20 2.7.4