From patchwork Mon Jul 12 11:47:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 58604 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F31C8B6EF7 for ; Mon, 12 Jul 2010 22:21:49 +1000 (EST) Received: from localhost ([127.0.0.1]:48170 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OYHYX-0008Lx-Q9 for incoming@patchwork.ozlabs.org; Mon, 12 Jul 2010 07:52:17 -0400 Received: from [140.186.70.92] (port=50889 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OYHUK-0006mF-Qa for qemu-devel@nongnu.org; Mon, 12 Jul 2010 07:47:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OYHUI-0007u3-CK for qemu-devel@nongnu.org; Mon, 12 Jul 2010 07:47:56 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:44777) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OYHUI-0007tU-1u for qemu-devel@nongnu.org; Mon, 12 Jul 2010 07:47:54 -0400 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id D0CF910775F; Mon, 12 Jul 2010 20:47:49 +0900 (JST) Received: (nullmailer pid 2644 invoked by uid 1000); Mon, 12 Jul 2010 11:47:52 -0000 From: Isaku Yamahata To: seabios@seabios.org Date: Mon, 12 Jul 2010 20:47:46 +0900 Message-Id: X-Mailer: git-send-email 1.7.1.1 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: yamahata@valinux.co.jp, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 1/7] seabios: pci: introduce helper function to find device from table and initialize it. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org introduce helper function to find device from table and initialize it. pci_find_init_device(). This will be used later. Signed-off-by: Isaku Yamahata --- src/pci.c | 12 ++++++++++++ src/pci.h | 1 + 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/src/pci.c b/src/pci.c index c54b084..611d0e2 100644 --- a/src/pci.c +++ b/src/pci.c @@ -203,3 +203,15 @@ int pci_init_device(const struct pci_device_id *ids, u16 bdf, void *arg) } return -1; } + +int pci_find_init_device(const struct pci_device_id *ids, void *arg) +{ + int bdf, max; + + foreachpci(bdf, max) { + if (pci_init_device(ids, bdf, arg) == 0) { + return bdf; + } + } + return -1; +} diff --git a/src/pci.h b/src/pci.h index fa6a32d..9c3108c 100644 --- a/src/pci.h +++ b/src/pci.h @@ -93,6 +93,7 @@ struct pci_device_id { } int pci_init_device(const struct pci_device_id *table, u16 bdf, void *arg); +int pci_find_init_device(const struct pci_device_id *ids, void *arg); // pirtable.c void create_pirtable(void);