From: Kevin Wolf Date: Mon, 18 Oct 2010 15:10:49 +0000 (+0200) Subject: ide: Factor ide_flush_cache out X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~7036^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6bcb1a79a31563f2c414e1bd35d044d6ab385011;p=sdk%2Femulator%2Fqemu.git ide: Factor ide_flush_cache out The next patch reuses this code, so put it in its own function. Signed-off-by: Kevin Wolf --- 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: