From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:55065) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0xiA-0001xK-6s for qemu-devel@nongnu.org; Tue, 06 Sep 2011 11:37:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R0xi4-0003mk-En for qemu-devel@nongnu.org; Tue, 06 Sep 2011 11:37:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2376) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0xi3-0003ma-V3 for qemu-devel@nongnu.org; Tue, 06 Sep 2011 11:37:12 -0400 From: Kevin Wolf Date: Tue, 6 Sep 2011 17:39:32 +0200 Message-Id: <1315323586-23840-18-git-send-email-kwolf@redhat.com> In-Reply-To: <1315323586-23840-1-git-send-email-kwolf@redhat.com> References: <1315323586-23840-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 17/31] spitz tosa: Simplify "drive is suitable for microdrive" test List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Markus Armbruster We try the drive defined with -drive if=ide,index=0 (or equivalent sugar). We use it only if (dinfo && bdrv_is_inserted(dinfo->bdrv) && !bdrv_is_removable(dinfo->bdrv)). This is a convoluted way to test for "drive media can't be removed". The only way to create such a drive with -drive if=ide is media=cdrom. And that sets dinfo->media_cd, so just test that. Signed-off-by: Markus Armbruster Signed-off-by: Kevin Wolf --- hw/spitz.c | 10 +++------- hw/tosa.c | 10 +++------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/hw/spitz.c b/hw/spitz.c index c05b5f7..0adae59 100644 --- a/hw/spitz.c +++ b/hw/spitz.c @@ -708,17 +708,13 @@ static void spitz_ssp_attach(PXA2xxState *cpu) static void spitz_microdrive_attach(PXA2xxState *cpu, int slot) { PCMCIACardState *md; - BlockDriverState *bs; DriveInfo *dinfo; dinfo = drive_get(IF_IDE, 0, 0); - if (!dinfo) + if (!dinfo || dinfo->media_cd) return; - bs = dinfo->bdrv; - if (bdrv_is_inserted(bs) && !bdrv_is_removable(bs)) { - md = dscm1xxxx_init(dinfo); - pxa2xx_pcmcia_attach(cpu->pcmcia[slot], md); - } + md = dscm1xxxx_init(dinfo); + pxa2xx_pcmcia_attach(cpu->pcmcia[slot], md); } /* Wm8750 and Max7310 on I2C */ diff --git a/hw/tosa.c b/hw/tosa.c index a7967a2..7b407f4 100644 --- a/hw/tosa.c +++ b/hw/tosa.c @@ -51,17 +51,13 @@ static void tosa_microdrive_attach(PXA2xxState *cpu) { PCMCIACardState *md; - BlockDriverState *bs; DriveInfo *dinfo; dinfo = drive_get(IF_IDE, 0, 0); - if (!dinfo) + if (!dinfo || dinfo->media_cd) return; - bs = dinfo->bdrv; - if (bdrv_is_inserted(bs) && !bdrv_is_removable(bs)) { - md = dscm1xxxx_init(dinfo); - pxa2xx_pcmcia_attach(cpu->pcmcia[0], md); - } + md = dscm1xxxx_init(dinfo); + pxa2xx_pcmcia_attach(cpu->pcmcia[0], md); } static void tosa_out_switch(void *opaque, int line, int level) -- 1.7.6