From patchwork Fri Oct 22 13:43:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 68851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id B4F5BB6EED for ; Sat, 23 Oct 2010 00:55:35 +1100 (EST) Received: from localhost ([127.0.0.1]:40469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P9I5j-0000K6-I7 for incoming@patchwork.ozlabs.org; Fri, 22 Oct 2010 09:55:31 -0400 Received: from [140.186.70.92] (port=43299 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P9HuE-0002LZ-VN for qemu-devel@nongnu.org; Fri, 22 Oct 2010 09:43:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P9HuC-0003G5-RQ for qemu-devel@nongnu.org; Fri, 22 Oct 2010 09:43:38 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64925) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P9HuC-0003Fq-KP for qemu-devel@nongnu.org; Fri, 22 Oct 2010 09:43:36 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9MDhZ8K025375 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 22 Oct 2010 09:43:35 -0400 Received: from dhcp-5-188.str.redhat.com (vpn2-8-219.ams2.redhat.com [10.36.8.219]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9MDhEd1015077; Fri, 22 Oct 2010 09:43:33 -0400 From: Kevin Wolf To: anthony@codemonkey.ws Date: Fri, 22 Oct 2010 15:43:54 +0200 Message-Id: <1287755036-27688-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1287755036-27688-1-git-send-email-kwolf@redhat.com> References: <1287755036-27688-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 09/11] ide: Factor ide_flush_cache out X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org The next patch reuses this code, so put it in its own function. Signed-off-by: Kevin Wolf --- hw/ide/core.c | 14 ++++++++++---- 1 files changed, 10 insertions(+), 4 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 5ccb09c..6d8606e 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -801,6 +801,15 @@ static void ide_flush_cb(void *opaque, int ret) ide_set_irq(s->bus); } +static void ide_flush_cache(IDEState *s) +{ + if (s->bs) { + bdrv_aio_flush(s->bs, ide_flush_cb, s); + } else { + ide_flush_cb(s, 0); + } +} + static inline void cpu_to_ube16(uint8_t *buf, int val) { buf[0] = val >> 8; @@ -2031,10 +2040,7 @@ void ide_ioport_write(void *opaque, uint32_t addr, uint32_t val) break; case WIN_FLUSH_CACHE: case WIN_FLUSH_CACHE_EXT: - if (s->bs) - bdrv_aio_flush(s->bs, ide_flush_cb, s); - else - ide_flush_cb(s, 0); + ide_flush_cache(s); break; case WIN_STANDBY: case WIN_STANDBY2: