From patchwork Fri Feb 15 16:51:59 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: 220773 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 A5DEE2C007A for ; Sat, 16 Feb 2013 03:52:38 +1100 (EST) Received: from localhost ([::1]:35221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6OWa-0002IJ-Tz for incoming@patchwork.ozlabs.org; Fri, 15 Feb 2013 11:52:36 -0500 Received: from eggs.gnu.org ([208.118.235.92]:36471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6OWM-0002I9-EM for qemu-devel@nongnu.org; Fri, 15 Feb 2013 11:52:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U6OW9-0006UV-Nl for qemu-devel@nongnu.org; Fri, 15 Feb 2013 11:52:22 -0500 Received: from cantor2.suse.de ([195.135.220.15]:34918 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U6OW9-0006UE-HN; Fri, 15 Feb 2013 11:52:09 -0500 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 64644A0FED; Fri, 15 Feb 2013 17:52:07 +0100 (CET) From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Fri, 15 Feb 2013 17:51:59 +0100 Message-Id: <1360947119-26115-1-git-send-email-afaerber@suse.de> X-Mailer: git-send-email 1.7.10.4 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:ppce500" , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Alexander Graf Subject: [Qemu-devel] [PATCH qom-cpu-next] ppce500_spin: Replace open-coded CPU 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 Potentially env could be NULL whereas cpu would still be valid and correspond to a previous env. Wrapping this in qemu_get_cpu(), env is no longer needed, so simplify code that existed before 55e5c2850293547203874098f7cec148ffd12dfa. Signed-off-by: Andreas Färber Acked-by: Alexander Graf --- hw/ppce500_spin.c | 15 ++++----------- 1 Datei geändert, 4 Zeilen hinzugefügt(+), 11 Zeilen entfernt(-) diff --git a/hw/ppce500_spin.c b/hw/ppce500_spin.c index 7e90fb9..5bdce52 100644 --- a/hw/ppce500_spin.c +++ b/hw/ppce500_spin.c @@ -123,18 +123,11 @@ static void spin_write(void *opaque, hwaddr addr, uint64_t value, { SpinState *s = opaque; int env_idx = addr / sizeof(SpinInfo); - CPUPPCState *env; - CPUState *cpu = NULL; + CPUState *cpu; SpinInfo *curspin = &s->spin[env_idx]; uint8_t *curspin_p = (uint8_t*)curspin; - for (env = first_cpu; env != NULL; env = env->next_cpu) { - cpu = CPU(ppc_env_get_cpu(env)); - if (cpu->cpu_index == env_idx) { - break; - } - } - + cpu = qemu_get_cpu(env_idx); if (cpu == NULL) { /* Unknown CPU */ return; @@ -161,11 +154,11 @@ static void spin_write(void *opaque, hwaddr addr, uint64_t value, if (!(ldq_p(&curspin->addr) & 1)) { /* run CPU */ SpinKick kick = { - .cpu = ppc_env_get_cpu(env), + .cpu = POWERPC_CPU(cpu), .spin = curspin, }; - run_on_cpu(CPU(kick.cpu), spin_kick, &kick); + run_on_cpu(cpu, spin_kick, &kick); } }