From patchwork Tue Jul 20 07:37:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 59283 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 5ADA9B70AE for ; Tue, 20 Jul 2010 17:39:15 +1000 (EST) Received: from localhost ([127.0.0.1]:46281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ob7Q0-0001yq-92 for incoming@patchwork.ozlabs.org; Tue, 20 Jul 2010 03:39:12 -0400 Received: from [140.186.70.92] (port=59467 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ob7MV-0000eU-1r for qemu-devel@nongnu.org; Tue, 20 Jul 2010 03:35:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Ob7MN-0002ku-7i for qemu-devel@nongnu.org; Tue, 20 Jul 2010 03:35:34 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:58563) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Ob7MN-0002ja-05 for qemu-devel@nongnu.org; Tue, 20 Jul 2010 03:35:27 -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 621CA10784B; Tue, 20 Jul 2010 16:35:22 +0900 (JST) Received: (nullmailer pid 26770 invoked by uid 1000); Tue, 20 Jul 2010 07:37:19 -0000 From: Isaku Yamahata To: seabios@seabios.org Date: Tue, 20 Jul 2010 16:37:15 +0900 Message-Id: <2d9c26703e7caab05efc2e0a4b1ad7c393c6ae16.1279611182.git.yamahata@valinux.co.jp> 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/5] 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);