Patchwork [1/2] ide: Factor ide_flush_cache out

login
register
mail settings
Submitter Kevin Wolf
Date Oct. 19, 2010, 3:08 p.m.
Message ID <1287500932-7366-2-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/68347/
State New
Headers show

Comments

Kevin Wolf - Oct. 19, 2010, 3:08 p.m.
The next patch reuses this code, so put it in its own function.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 hw/ide/core.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
Christoph Hellwig - Oct. 21, 2010, 5:21 a.m.
On Tue, Oct 19, 2010 at 05:08:51PM +0200, Kevin Wolf wrote:
> The next patch reuses this code, so put it in its own function.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>

ACK

Patch

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: