From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Kevin Wolf 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> Subject: [Qemu-devel] [PATCH 09/11] ide: Factor ide_flush_cache out List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@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: -- 1.7.2.3