Received: from eggs.gnu.org ([208.118.235.92]:41656) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUcUb-0007lo-Py for qemu-devel@nongnu.org; Tue, 23 Apr 2013 08:38:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UUcUa-0000rA-D8 for qemu-devel@nongnu.org; Tue, 23 Apr 2013 08:38:41 -0400 Received: from e06smtp11.uk.ibm.com ([195.75.94.107]:33790) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UUcUa-0000qv-3D for qemu-devel@nongnu.org; Tue, 23 Apr 2013 08:38:40 -0400 Received: from /spool/local by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 23 Apr 2013 13:34:57 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 2882C17D8100 for ; Tue, 23 Apr 2013 13:38:25 +0100 (BST) Received: from d06av12.portsmouth.uk.ibm.com (d06av12.portsmouth.uk.ibm.com [9.149.37.247]) by b06cxnps3074.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3NCbHUs53477556 for ; Tue, 23 Apr 2013 12:37:17 GMT Received: from d06av12.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av12.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r3NCbPmH003572 for ; Tue, 23 Apr 2013 06:37:26 -0600 From: Cornelia Huck Date: Tue, 23 Apr 2013 14:37:11 +0200 Message-Id: <1366720634-13184-2-git-send-email-cornelia.huck@de.ibm.com> In-Reply-To: <1366720634-13184-1-git-send-email-cornelia.huck@de.ibm.com> References: <1366720634-13184-1-git-send-email-cornelia.huck@de.ibm.com> Subject: [Qemu-devel] [PATCH 1/4] s390-ccw.img: Detect devices with stsch. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Graf Cc: Cornelia Huck , Christian Borntraeger , qemu-devel@nongnu.org, Dominik Dingel stsch is the canonical way to detect devices. As a bonus, we can abort the loop if we get cc 3, and we need to check only the valid devices (dnv set). Signed-off-by: Cornelia Huck --- pc-bios/s390-ccw/main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pc-bios/s390-ccw/main.c b/pc-bios/s390-ccw/main.c index 67f4987..fd40fa5 100644 --- a/pc-bios/s390-ccw/main.c +++ b/pc-bios/s390-ccw/main.c @@ -22,7 +22,7 @@ void virtio_panic(const char *string) static void virtio_setup(void) { - struct irb irb; + struct schib schib; int i; int r; bool found = false; @@ -31,8 +31,11 @@ static void virtio_setup(void) for (i = 0; i < 0x10000; i++) { blk_schid.sch_no = i; - r = tsch(blk_schid, &irb); - if (r != 3) { + r = stsch_err(blk_schid, &schib); + if (r == 3) { + break; + } + if (schib.pmcw.dnv) { if (virtio_is_blk(blk_schid)) { found = true; break; -- 1.7.12.4