From patchwork Fri Apr 26 18:19:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 239912 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 5B1B52C00F1 for ; Sat, 27 Apr 2013 04:30:02 +1000 (EST) Received: from localhost ([::1]:43620 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVnPE-00067X-DP for incoming@patchwork.ozlabs.org; Fri, 26 Apr 2013 14:30:00 -0400 Received: from eggs.gnu.org ([208.118.235.92]:54437) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVnFG-0007oU-BV for qemu-devel@nongnu.org; Fri, 26 Apr 2013 14:19:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVnFA-0004DU-Nn for qemu-devel@nongnu.org; Fri, 26 Apr 2013 14:19:42 -0400 Received: from cantor2.suse.de ([195.135.220.15]:38748 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVnFA-0004Cl-7M; Fri, 26 Apr 2013 14:19:36 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 82BC45E000211; Fri, 26 Apr 2013 20:19:34 +0200 (CEST) From: Alexander Graf To: qemu-ppc@nongnu.org Date: Fri, 26 Apr 2013 20:19:24 +0200 Message-Id: <1367000373-7972-16-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1367000373-7972-1-git-send-email-agraf@suse.de> References: <1367000373-7972-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x X-Received-From: 195.135.220.15 Cc: Blue Swirl , Cornelia Huck , qemu-devel@nongnu.org, Aurelien Jarno Subject: [Qemu-devel] [PATCH 15/24] s390-ccw.img: Detect devices with stsch. 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 From: Cornelia Huck 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 Signed-off-by: Alexander Graf --- pc-bios/s390-ccw/main.c | 9 ++++++--- 1 files 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;