From patchwork Sat Feb 16 15:45:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 221003 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 675822C008E for ; Sun, 17 Feb 2013 04:31:40 +1100 (EST) Received: from localhost ([::1]:38420 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6lbu-0008GE-G8 for incoming@patchwork.ozlabs.org; Sat, 16 Feb 2013 12:31:38 -0500 Received: from eggs.gnu.org ([208.118.235.92]:39264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6k1Q-0005Fv-73 for qemu-devel@nongnu.org; Sat, 16 Feb 2013 10:50:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U6k1L-0002Wg-Ij for qemu-devel@nongnu.org; Sat, 16 Feb 2013 10:49:48 -0500 Received: from cantor2.suse.de ([195.135.220.15]:40443 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6k1L-0002WZ-Cp; Sat, 16 Feb 2013 10:49:47 -0500 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D21FAA3A49; Sat, 16 Feb 2013 16:49:46 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Sat, 16 Feb 2013 16:45:36 +0100 Message-Id: <1361029542-8412-42-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1361029542-8412-1-git-send-email-afaerber@suse.de> References: <1361029542-8412-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Scott Wood , "open list:e500" , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Alexander Graf Subject: [Qemu-devel] [PATCH 41/47] e500: Replace open-coded loop with qemu_get_cpu() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Since we still need env for ppc-specific fields, obtain it via the new env_ptr fields to avoid "cpu" name conflicts between CPUState and PowerPCCPU for now. This fixes a potential issue with env being NULL at the end of the loop but cpu still being a valid pointer corresponding to a previous env. Acked-by: Alexander Graf Signed-off-by: Andreas Färber --- hw/ppc/e500.c | 11 +++-------- 1 Datei geändert, 3 Zeilen hinzugefügt(+), 8 Zeilen entfernt(-) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index b7474c0..451682c 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -240,20 +240,15 @@ static int ppce500_load_device_tree(CPUPPCState *env, /* We need to generate the cpu nodes in reverse order, so Linux can pick the first node as boot node and be happy */ for (i = smp_cpus - 1; i >= 0; i--) { - CPUState *cpu = NULL; + CPUState *cpu; char cpu_name[128]; uint64_t cpu_release_addr = MPC8544_SPIN_BASE + (i * 0x20); - for (env = first_cpu; env != NULL; env = env->next_cpu) { - cpu = ENV_GET_CPU(env); - if (cpu->cpu_index == i) { - break; - } - } - + cpu = qemu_get_cpu(i); if (cpu == NULL) { continue; } + env = cpu->env_ptr; snprintf(cpu_name, sizeof(cpu_name), "/cpus/PowerPC,8544@%x", cpu->cpu_index);