Patchwork [RESEND,7/9] ide-core: allocate metadata storage for CFATA drives

login
register
mail settings
Submitter Dmitry Eremin-Solenikov
Date April 25, 2011, 9:06 a.m.
Message ID <1303722395-10791-7-git-send-email-dbaryshkov@gmail.com>
Download mbox | patch
Permalink /patch/92715/
State New
Headers show

Comments

Dmitry Eremin-Solenikov - April 25, 2011, 9:06 a.m.
Currently it's done by hw/ide/microdrive.c To simplify that part,
move this initialization to ide core.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
---
 hw/ide/core.c       |    4 ++++
 hw/ide/internal.h   |    2 ++
 hw/ide/microdrive.c |    6 +-----
 3 files changed, 7 insertions(+), 5 deletions(-)

Patch

diff --git a/hw/ide/core.c b/hw/ide/core.c
index f028ddb..16e6f67 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -2682,6 +2682,10 @@  int ide_init_drive(IDEState *s, BlockDriverState *bs,
             return -1;
         }
     }
+    if (s->drive_kind == IDE_CFATA) {
+        s->mdata_size = CFA_METADATA_SIZE;
+        s->mdata_storage = qemu_mallocz(CFA_METADATA_SIZE);
+    }
     if (serial) {
         strncpy(s->drive_serial_str, serial, sizeof(s->drive_serial_str));
     } else {
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index ba7e9a8..769de90 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -364,6 +364,8 @@  typedef struct IDEDMAOps IDEDMAOps;
 #define SMART_DISABLE         0xd9
 #define SMART_STATUS          0xda
 
+#define CFA_METADATA_SIZE     0x20
+
 typedef enum { IDE_HD, IDE_CD, IDE_CFATA } IDEDriveKind;
 
 typedef void EndTransferFunc(IDEState *);
diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c
index c080943..13459a0 100644
--- a/hw/ide/microdrive.c
+++ b/hw/ide/microdrive.c
@@ -34,8 +34,6 @@ 
 /***********************************************************/
 /* CF-ATA Microdrive */
 
-#define METADATA_SIZE	0x20
-
 /* DSCM-1XXXX Microdrive hard disk with CF+ II / PCMCIA interface.  */
 typedef struct {
     PCMCIACardState card;
@@ -533,9 +531,6 @@  PCMCIACardState *dscm1xxxx_init(PCMCIASocket *socket, DriveInfo *bdrv)
     md = DO_UPCAST(MicroDriveState, card.dev, dev);
 
     ide_create_drive(&md->bus, 0, bdrv);
-    md->bus.ifs[0].drive_kind = IDE_CFATA;
-    md->bus.ifs[0].mdata_size = METADATA_SIZE;
-    md->bus.ifs[0].mdata_storage = (uint8_t *) qemu_mallocz(METADATA_SIZE);
 
     return &md->card;
 }
@@ -552,6 +547,7 @@  static int dscm1xxxx_initfn(PCMCIACardState *state)
     qdev_init_gpio_in(&state->dev, md_set_irq, 1);
     ide_init2(&md->bus, qdev_get_gpio_in(&state->dev, 0));
 
+    md->bus.ifs[0].drive_kind = IDE_CFATA;
     return 0;
 }