From patchwork Wed Aug 3 13:08:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 108249 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 1D3D3B71DE for ; Thu, 4 Aug 2011 00:54:58 +1000 (EST) Received: from localhost ([::1]:45349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QobIH-00078F-Uo for incoming@patchwork.ozlabs.org; Wed, 03 Aug 2011 09:15:29 -0400 Received: from eggs.gnu.org ([140.186.70.92]:52638) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QobHg-0005Mh-Nn for qemu-devel@nongnu.org; Wed, 03 Aug 2011 09:14:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QobHe-0002VW-Ni for qemu-devel@nongnu.org; Wed, 03 Aug 2011 09:14:52 -0400 Received: from oxygen.pond.sub.org ([78.46.104.156]:36881) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QobHe-0002VF-GC for qemu-devel@nongnu.org; Wed, 03 Aug 2011 09:14:50 -0400 Received: from blackfin.pond.sub.org (p5B32D904.dip.t-dialin.net [91.50.217.4]) by oxygen.pond.sub.org (Postfix) with ESMTPA id BDD84A2C89; Wed, 3 Aug 2011 15:14:49 +0200 (CEST) Received: by blackfin.pond.sub.org (Postfix, from userid 500) id C680860075; Wed, 3 Aug 2011 15:08:26 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Wed, 3 Aug 2011 15:08:13 +0200 Message-Id: <1312376904-16115-35-git-send-email-armbru@redhat.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1312376904-16115-1-git-send-email-armbru@redhat.com> References: <1312376904-16115-1-git-send-email-armbru@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 78.46.104.156 Cc: kwolf@redhat.com, quintela@redhat.com, stefano.stabellini@eu.citrix.com, lcapitulino@redhat.com, hare@suse.de, amit.shah@redhat.com, hch@lst.de Subject: [Qemu-devel] [PATCH v2 34/45] spitz tosa: Simplify "drive is suitable for microdrive" test X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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)