From patchwork Tue Jun 18 08:26:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 252165 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C0B0F2C043B for ; Tue, 18 Jun 2013 18:45:30 +1000 (EST) Received: from localhost ([::1]:59915 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UorIz-0005NG-Ux for incoming@patchwork.ozlabs.org; Tue, 18 Jun 2013 04:30:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UorFY-0008Qm-KY for qemu-devel@nongnu.org; Tue, 18 Jun 2013 04:26:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UorFW-00065M-SJ for qemu-devel@nongnu.org; Tue, 18 Jun 2013 04:26:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43942) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UorFW-00063s-Ht for qemu-devel@nongnu.org; Tue, 18 Jun 2013 04:26:46 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5I8QjAu021260 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 18 Jun 2013 04:26:46 -0400 Received: from dhcp-200-207.str.redhat.com (ovpn-116-46.ams2.redhat.com [10.36.116.46]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r5I8QHIU020592; Tue, 18 Jun 2013 04:26:44 -0400 From: Kevin Wolf To: qemu-devel@nongnu.org Date: Tue, 18 Jun 2013 10:26:11 +0200 Message-Id: <1371543971-23241-18-git-send-email-kwolf@redhat.com> In-Reply-To: <1371543971-23241-1-git-send-email-kwolf@redhat.com> References: <1371543971-23241-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, stefanha@redhat.com Subject: [Qemu-devel] [PATCH 17/17] ide: Clean up ide_exec_cmd() 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 All commands are now converted to ide_cmd_table handlers, so it can be unconditional now and the old switch block can go. Signed-off-by: Kevin Wolf --- hw/ide/core.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 1c8f414..03d1cfa 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -1694,6 +1694,7 @@ static bool ide_cmd_permitted(IDEState *s, uint32_t cmd) void ide_exec_cmd(IDEBus *bus, uint32_t val) { IDEState *s; + bool complete; #if defined(DEBUG_IDE) printf("ide: CMD=%02x\n", val); @@ -1708,37 +1709,24 @@ void ide_exec_cmd(IDEBus *bus, uint32_t val) return; if (!ide_cmd_permitted(s, val)) { - goto abort_cmd; + ide_abort_command(s); + ide_set_irq(s->bus); + return; } - if (ide_cmd_table[val].handler != NULL) { - bool complete; - - s->status = READY_STAT | BUSY_STAT; - s->error = 0; - - complete = ide_cmd_table[val].handler(s, val); - if (complete) { - s->status &= ~BUSY_STAT; - assert(!!s->error == !!(s->status & ERR_STAT)); + s->status = READY_STAT | BUSY_STAT; + s->error = 0; - if ((ide_cmd_table[val].flags & SET_DSC) && !s->error) { - s->status |= SEEK_STAT; - } + complete = ide_cmd_table[val].handler(s, val); + if (complete) { + s->status &= ~BUSY_STAT; + assert(!!s->error == !!(s->status & ERR_STAT)); - ide_set_irq(s->bus); + if ((ide_cmd_table[val].flags & SET_DSC) && !s->error) { + s->status |= SEEK_STAT; } - return; - } - - switch(val) { - default: - /* should not be reachable */ - abort_cmd: - ide_abort_command(s); ide_set_irq(s->bus); - break; } }