a5bd9f6
From ded88969f8361b022582023d32e0a8e9f30eafe0 Mon Sep 17 00:00:00 2001
a5bd9f6
From: Colin Watson <cjwatson@ubuntu.com>
a5bd9f6
Date: Sun, 13 Jan 2013 01:10:41 +0000
a5bd9f6
Subject: [PATCH 101/364] Remove nested functions from PCI iterators.
a5bd9f6
a5bd9f6
* grub-core/bus/pci.c (grub_pci_iterate): Add hook_data argument,
a5bd9f6
passed to hook.  Update all callers to pass appropriate hook data.
a5bd9f6
* grub-core/bus/emu/pci.c (grub_pci_iterate): Likewise.
a5bd9f6
* include/grub/pci.h (grub_pci_iteratefunc_t): Add data argument.
a5bd9f6
Remove NESTED_FUNC_ATTR from here and from all users.
a5bd9f6
(grub_pci_iterate): Update prototype.
a5bd9f6
* grub-core/bus/cs5536.c (grub_cs5536_find: hook): Make static
a5bd9f6
instead of nested.  Rename to ...
a5bd9f6
(grub_cs5536_find_iter): ... this.
a5bd9f6
* grub-core/kern/efi/mm.c (stop_broadcom: find_card): Likewise.
a5bd9f6
* grub-core/kern/mips/loongson/init.c (init_pci: set_card):
a5bd9f6
Likewise.
a5bd9f6
* grub-core/kern/vga_init.c (grub_qemu_init_cirrus: find_card):
a5bd9f6
Likewise.
a5bd9f6
* grub-core/video/bochs.c (grub_video_bochs_setup: find_card):
a5bd9f6
Likewise.
a5bd9f6
* grub-core/video/cirrus.c (grub_video_cirrus_setup: find_card):
a5bd9f6
Likewise.
a5bd9f6
* grub-core/video/efi_uga.c (find_framebuf: find_card): Likewise.
a5bd9f6
* grub-core/video/radeon_fuloong2e.c
a5bd9f6
(grub_video_radeon_fuloong2e_setup: find_card): Likewise.
a5bd9f6
* grub-core/video/sis315pro.c (grub_video_sis315pro_setup:
a5bd9f6
find_card): Likewise.
a5bd9f6
* grub-core/video/sm712.c (grub_video_sm712_setup: find_card):
a5bd9f6
Likewise.
a5bd9f6
---
a5bd9f6
 ChangeLog                           |  30 +++++++++
a5bd9f6
 grub-core/bus/cs5536.c              |  45 ++++++++------
a5bd9f6
 grub-core/bus/emu/pci.c             |   4 +-
a5bd9f6
 grub-core/bus/pci.c                 |   4 +-
a5bd9f6
 grub-core/bus/usb/ehci.c            |   7 ++-
a5bd9f6
 grub-core/bus/usb/ohci.c            |   8 +--
a5bd9f6
 grub-core/bus/usb/uhci.c            |   7 ++-
a5bd9f6
 grub-core/commands/efi/fixvideo.c   |   8 ++-
a5bd9f6
 grub-core/commands/lspci.c          |   8 ++-
a5bd9f6
 grub-core/commands/setpci.c         |   7 ++-
a5bd9f6
 grub-core/disk/ahci.c               |   7 ++-
a5bd9f6
 grub-core/disk/pata.c               |   7 ++-
a5bd9f6
 grub-core/kern/efi/mm.c             |  53 ++++++++--------
a5bd9f6
 grub-core/kern/mips/loongson/init.c |  74 +++++++++++-----------
a5bd9f6
 grub-core/kern/vga_init.c           |  61 +++++++++---------
a5bd9f6
 grub-core/video/bochs.c             |  46 +++++++-------
a5bd9f6
 grub-core/video/cirrus.c            |  46 +++++++-------
a5bd9f6
 grub-core/video/efi_uga.c           | 119 ++++++++++++++++++++----------------
a5bd9f6
 grub-core/video/radeon_fuloong2e.c  |  50 ++++++++-------
a5bd9f6
 grub-core/video/sis315pro.c         |  60 +++++++++---------
a5bd9f6
 grub-core/video/sm712.c             |  50 ++++++++-------
a5bd9f6
 include/grub/pci.h                  |   7 ++-
a5bd9f6
 22 files changed, 396 insertions(+), 312 deletions(-)
a5bd9f6
a5bd9f6
diff --git a/ChangeLog b/ChangeLog
a5bd9f6
index b527f7a..14bff81 100644
a5bd9f6
--- a/ChangeLog
a5bd9f6
+++ b/ChangeLog
a5bd9f6
@@ -1,3 +1,33 @@
a5bd9f6
+2013-01-13  Colin Watson  <cjwatson@ubuntu.com>
a5bd9f6
+
a5bd9f6
+	Remove nested functions from PCI iterators.
a5bd9f6
+
a5bd9f6
+	* grub-core/bus/pci.c (grub_pci_iterate): Add hook_data argument,
a5bd9f6
+	passed to hook.  Update all callers to pass appropriate hook data.
a5bd9f6
+	* grub-core/bus/emu/pci.c (grub_pci_iterate): Likewise.
a5bd9f6
+	* include/grub/pci.h (grub_pci_iteratefunc_t): Add data argument.
a5bd9f6
+	Remove NESTED_FUNC_ATTR from here and from all users.
a5bd9f6
+	(grub_pci_iterate): Update prototype.
a5bd9f6
+	* grub-core/bus/cs5536.c (grub_cs5536_find: hook): Make static
a5bd9f6
+	instead of nested.  Rename to ...
a5bd9f6
+	(grub_cs5536_find_iter): ... this.
a5bd9f6
+	* grub-core/kern/efi/mm.c (stop_broadcom: find_card): Likewise.
a5bd9f6
+	* grub-core/kern/mips/loongson/init.c (init_pci: set_card):
a5bd9f6
+	Likewise.
a5bd9f6
+	* grub-core/kern/vga_init.c (grub_qemu_init_cirrus: find_card):
a5bd9f6
+	Likewise.
a5bd9f6
+	* grub-core/video/bochs.c (grub_video_bochs_setup: find_card):
a5bd9f6
+	Likewise.
a5bd9f6
+	* grub-core/video/cirrus.c (grub_video_cirrus_setup: find_card):
a5bd9f6
+	Likewise.
a5bd9f6
+	* grub-core/video/efi_uga.c (find_framebuf: find_card): Likewise.
a5bd9f6
+	* grub-core/video/radeon_fuloong2e.c
a5bd9f6
+	(grub_video_radeon_fuloong2e_setup: find_card): Likewise.
a5bd9f6
+	* grub-core/video/sis315pro.c (grub_video_sis315pro_setup:
a5bd9f6
+	find_card): Likewise.
a5bd9f6
+	* grub-core/video/sm712.c (grub_video_sm712_setup: find_card):
a5bd9f6
+	Likewise.
a5bd9f6
+
a5bd9f6
 2013-01-12  Vladimir Serbinenko  <phcoder@gmail.com>
a5bd9f6
 
a5bd9f6
 	* grub-core/commands/verify.c: Mark messages for translating.
a5bd9f6
diff --git a/grub-core/bus/cs5536.c b/grub-core/bus/cs5536.c
a5bd9f6
index 9e7796e..bb9aa27 100644
a5bd9f6
--- a/grub-core/bus/cs5536.c
a5bd9f6
+++ b/grub-core/bus/cs5536.c
a5bd9f6
@@ -29,28 +29,39 @@
a5bd9f6
 
a5bd9f6
 GRUB_MOD_LICENSE ("GPLv3+");
a5bd9f6
 
a5bd9f6
+/* Context for grub_cs5536_find.  */
a5bd9f6
+struct grub_cs5536_find_ctx
a5bd9f6
+{
a5bd9f6
+  grub_pci_device_t *devp;
a5bd9f6
+  int found;
a5bd9f6
+};
a5bd9f6
+
a5bd9f6
+/* Helper for grub_cs5536_find.  */
a5bd9f6
+static int
a5bd9f6
+grub_cs5536_find_iter (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
a5bd9f6
+{
a5bd9f6
+  struct grub_cs5536_find_ctx *ctx = data;
a5bd9f6
+
a5bd9f6
+  if (pciid == GRUB_CS5536_PCIID)
a5bd9f6
+    {
a5bd9f6
+      *ctx->devp = dev;
a5bd9f6
+      ctx->found = 1;
a5bd9f6
+      return 1;
a5bd9f6
+    }
a5bd9f6
+  return 0;
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
 int
a5bd9f6
 grub_cs5536_find (grub_pci_device_t *devp)
a5bd9f6
 {
a5bd9f6
-  int found = 0;
a5bd9f6
-  auto int NESTED_FUNC_ATTR hook (grub_pci_device_t dev,
a5bd9f6
-				  grub_pci_id_t pciid);
a5bd9f6
-
a5bd9f6
-  int NESTED_FUNC_ATTR hook (grub_pci_device_t dev,
a5bd9f6
-			     grub_pci_id_t pciid)
a5bd9f6
-  {
a5bd9f6
-    if (pciid == GRUB_CS5536_PCIID)
a5bd9f6
-      {
a5bd9f6
-	*devp = dev;
a5bd9f6
-	found = 1;
a5bd9f6
-	return 1;
a5bd9f6
-      }
a5bd9f6
-    return 0;
a5bd9f6
-  }
a5bd9f6
+  struct grub_cs5536_find_ctx ctx = {
a5bd9f6
+    .devp = devp,
a5bd9f6
+    .found = 0
a5bd9f6
+  };
a5bd9f6
 
a5bd9f6
-  grub_pci_iterate (hook);
a5bd9f6
+  grub_pci_iterate (grub_cs5536_find_iter, &ctx;;
a5bd9f6
 
a5bd9f6
-  return found;
a5bd9f6
+  return ctx.found;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 grub_uint64_t
a5bd9f6
diff --git a/grub-core/bus/emu/pci.c b/grub-core/bus/emu/pci.c
a5bd9f6
index d1beb56..9d32963 100644
a5bd9f6
--- a/grub-core/bus/emu/pci.c
a5bd9f6
+++ b/grub-core/bus/emu/pci.c
a5bd9f6
@@ -32,7 +32,7 @@ grub_pci_make_address (grub_pci_device_t dev, int reg)
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 void
a5bd9f6
-grub_pci_iterate (grub_pci_iteratefunc_t hook)
a5bd9f6
+grub_pci_iterate (grub_pci_iteratefunc_t hook, void *hook_data)
a5bd9f6
 {
a5bd9f6
   struct pci_device_iterator *iter;
a5bd9f6
   struct pci_slot_match slot;
a5bd9f6
@@ -43,7 +43,7 @@ grub_pci_iterate (grub_pci_iteratefunc_t hook)
a5bd9f6
   slot.func = PCI_MATCH_ANY;
a5bd9f6
   iter = pci_slot_match_iterator_create (&slot);
a5bd9f6
   while ((dev = pci_device_next (iter)))
a5bd9f6
-    hook (dev, dev->vendor_id | (dev->device_id << 16));
a5bd9f6
+    hook (dev, dev->vendor_id | (dev->device_id << 16), hook_data);
a5bd9f6
   pci_iterator_destroy (iter);
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
diff --git a/grub-core/bus/pci.c b/grub-core/bus/pci.c
a5bd9f6
index 17dea30..b388ce5 100644
a5bd9f6
--- a/grub-core/bus/pci.c
a5bd9f6
+++ b/grub-core/bus/pci.c
a5bd9f6
@@ -98,7 +98,7 @@ grub_pci_make_address (grub_pci_device_t dev, int reg)
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 void
a5bd9f6
-grub_pci_iterate (grub_pci_iteratefunc_t hook)
a5bd9f6
+grub_pci_iterate (grub_pci_iteratefunc_t hook, void *hook_data)
a5bd9f6
 {
a5bd9f6
   grub_pci_device_t dev;
a5bd9f6
   grub_pci_address_t addr;
a5bd9f6
@@ -125,7 +125,7 @@ grub_pci_iterate (grub_pci_iteratefunc_t hook)
a5bd9f6
 		    continue;
a5bd9f6
 		}
a5bd9f6
 
a5bd9f6
-	      if (hook (dev, id))
a5bd9f6
+	      if (hook (dev, id, hook_data))
a5bd9f6
 		return;
a5bd9f6
 
a5bd9f6
 	      /* Probe only func = 0 if the device if not multifunction */
a5bd9f6
diff --git a/grub-core/bus/usb/ehci.c b/grub-core/bus/usb/ehci.c
a5bd9f6
index dc5bf71..b9872b6 100644
a5bd9f6
--- a/grub-core/bus/usb/ehci.c
a5bd9f6
+++ b/grub-core/bus/usb/ehci.c
a5bd9f6
@@ -454,8 +454,9 @@ grub_ehci_reset (struct grub_ehci *e)
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 /* PCI iteration function... */
a5bd9f6
-static int NESTED_FUNC_ATTR
a5bd9f6
-grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
a5bd9f6
+static int
a5bd9f6
+grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
a5bd9f6
+		    void *data __attribute__ ((unused)))
a5bd9f6
 {
a5bd9f6
   grub_uint8_t release;
a5bd9f6
   grub_uint32_t class_code;
a5bd9f6
@@ -1814,7 +1815,7 @@ grub_ehci_detect_dev (grub_usb_controller_t dev, int port, int *changed)
a5bd9f6
 static void
a5bd9f6
 grub_ehci_inithw (void)
a5bd9f6
 {
a5bd9f6
-  grub_pci_iterate (grub_ehci_pci_iter);
a5bd9f6
+  grub_pci_iterate (grub_ehci_pci_iter, NULL);
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 static grub_err_t
a5bd9f6
diff --git a/grub-core/bus/usb/ohci.c b/grub-core/bus/usb/ohci.c
a5bd9f6
index 6fabb4b..b10a9a3 100644
a5bd9f6
--- a/grub-core/bus/usb/ohci.c
a5bd9f6
+++ b/grub-core/bus/usb/ohci.c
a5bd9f6
@@ -213,9 +213,9 @@ grub_ohci_writereg32 (struct grub_ohci *o,
a5bd9f6
 
a5bd9f6
 /* Iterate over all PCI devices.  Determine if a device is an OHCI
a5bd9f6
    controller.  If this is the case, initialize it.  */
a5bd9f6
-static int NESTED_FUNC_ATTR
a5bd9f6
-grub_ohci_pci_iter (grub_pci_device_t dev,
a5bd9f6
-		    grub_pci_id_t pciid)
a5bd9f6
+static int
a5bd9f6
+grub_ohci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
a5bd9f6
+		    void *data __attribute__ ((unused)))
a5bd9f6
 {
a5bd9f6
   grub_uint32_t interf;
a5bd9f6
   grub_uint32_t base;
a5bd9f6
@@ -477,7 +477,7 @@ grub_ohci_pci_iter (grub_pci_device_t dev,
a5bd9f6
 static void
a5bd9f6
 grub_ohci_inithw (void)
a5bd9f6
 {
a5bd9f6
-  grub_pci_iterate (grub_ohci_pci_iter);
a5bd9f6
+  grub_pci_iterate (grub_ohci_pci_iter, NULL);
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 
a5bd9f6
diff --git a/grub-core/bus/usb/uhci.c b/grub-core/bus/usb/uhci.c
a5bd9f6
index 8f60850..e405b33 100644
a5bd9f6
--- a/grub-core/bus/usb/uhci.c
a5bd9f6
+++ b/grub-core/bus/usb/uhci.c
a5bd9f6
@@ -185,9 +185,10 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
a5bd9f6
 
a5bd9f6
 /* Iterate over all PCI devices.  Determine if a device is an UHCI
a5bd9f6
    controller.  If this is the case, initialize it.  */
a5bd9f6
-static int NESTED_FUNC_ATTR
a5bd9f6
+static int
a5bd9f6
 grub_uhci_pci_iter (grub_pci_device_t dev,
a5bd9f6
-		    grub_pci_id_t pciid __attribute__((unused)))
a5bd9f6
+		    grub_pci_id_t pciid __attribute__((unused)),
a5bd9f6
+		    void *data __attribute__ ((unused)))
a5bd9f6
 {
a5bd9f6
   grub_uint32_t class_code;
a5bd9f6
   grub_uint32_t class;
a5bd9f6
@@ -351,7 +352,7 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
a5bd9f6
 static void
a5bd9f6
 grub_uhci_inithw (void)
a5bd9f6
 {
a5bd9f6
-  grub_pci_iterate (grub_uhci_pci_iter);
a5bd9f6
+  grub_pci_iterate (grub_uhci_pci_iter, NULL);
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 static grub_uhci_td_t
a5bd9f6
diff --git a/grub-core/commands/efi/fixvideo.c b/grub-core/commands/efi/fixvideo.c
a5bd9f6
index 3ed40b3..d9d54a2 100644
a5bd9f6
--- a/grub-core/commands/efi/fixvideo.c
a5bd9f6
+++ b/grub-core/commands/efi/fixvideo.c
a5bd9f6
@@ -23,6 +23,7 @@
a5bd9f6
 #include <grub/pci.h>
a5bd9f6
 #include <grub/command.h>
a5bd9f6
 #include <grub/i18n.h>
a5bd9f6
+#include <grub/mm.h>
a5bd9f6
 
a5bd9f6
 GRUB_MOD_LICENSE ("GPLv3+");
a5bd9f6
 
a5bd9f6
@@ -40,8 +41,9 @@ static struct grub_video_patch
a5bd9f6
     {0, 0, 0, 0, 0}
a5bd9f6
   };
a5bd9f6
 
a5bd9f6
-static int NESTED_FUNC_ATTR
a5bd9f6
-scan_card (grub_pci_device_t dev, grub_pci_id_t pciid)
a5bd9f6
+static int
a5bd9f6
+scan_card (grub_pci_device_t dev, grub_pci_id_t pciid,
a5bd9f6
+	   void *data __attribute__ ((unused)))
a5bd9f6
 {
a5bd9f6
   grub_pci_address_t addr;
a5bd9f6
 
a5bd9f6
@@ -93,7 +95,7 @@ grub_cmd_fixvideo (grub_command_t cmd __attribute__ ((unused)),
a5bd9f6
 		   int argc __attribute__ ((unused)),
a5bd9f6
 		   char *argv[] __attribute__ ((unused)))
a5bd9f6
 {
a5bd9f6
-  grub_pci_iterate (scan_card);
a5bd9f6
+  grub_pci_iterate (scan_card, NULL);
a5bd9f6
   return 0;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
diff --git a/grub-core/commands/lspci.c b/grub-core/commands/lspci.c
a5bd9f6
index 9f83629..65213a3 100644
a5bd9f6
--- a/grub-core/commands/lspci.c
a5bd9f6
+++ b/grub-core/commands/lspci.c
a5bd9f6
@@ -22,6 +22,7 @@
a5bd9f6
 #include <grub/misc.h>
a5bd9f6
 #include <grub/extcmd.h>
a5bd9f6
 #include <grub/i18n.h>
a5bd9f6
+#include <grub/mm.h>
a5bd9f6
 
a5bd9f6
 GRUB_MOD_LICENSE ("GPLv3+");
a5bd9f6
 
a5bd9f6
@@ -126,8 +127,9 @@ static const struct grub_arg_option options[] =
a5bd9f6
 
a5bd9f6
 static int iospace;
a5bd9f6
 
a5bd9f6
-static int NESTED_FUNC_ATTR
a5bd9f6
-grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
a5bd9f6
+static int
a5bd9f6
+grub_lspci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
a5bd9f6
+		 void *data __attribute__ ((unused)))
a5bd9f6
 {
a5bd9f6
   grub_uint32_t class;
a5bd9f6
   const char *sclass;
a5bd9f6
@@ -218,7 +220,7 @@ grub_cmd_lspci (grub_extcmd_context_t ctxt,
a5bd9f6
 		char **args __attribute__ ((unused)))
a5bd9f6
 {
a5bd9f6
   iospace = ctxt->state[0].set;
a5bd9f6
-  grub_pci_iterate (grub_lspci_iter);
a5bd9f6
+  grub_pci_iterate (grub_lspci_iter, NULL);
a5bd9f6
   return GRUB_ERR_NONE;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
diff --git a/grub-core/commands/setpci.c b/grub-core/commands/setpci.c
a5bd9f6
index fcfec40..6fdf0e0 100644
a5bd9f6
--- a/grub-core/commands/setpci.c
a5bd9f6
+++ b/grub-core/commands/setpci.c
a5bd9f6
@@ -83,8 +83,9 @@ static int regsize;
a5bd9f6
 static grub_uint16_t regaddr;
a5bd9f6
 static const char *varname;
a5bd9f6
 
a5bd9f6
-static int NESTED_FUNC_ATTR
a5bd9f6
-grub_setpci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
a5bd9f6
+static int
a5bd9f6
+grub_setpci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
a5bd9f6
+		  void *data __attribute__ ((unused)))
a5bd9f6
 {
a5bd9f6
   grub_uint32_t regval = 0;
a5bd9f6
   grub_pci_address_t addr;
a5bd9f6
@@ -320,7 +321,7 @@ grub_cmd_setpci (grub_extcmd_context_t ctxt, int argc, char **argv)
a5bd9f6
     return grub_error (GRUB_ERR_BAD_ARGUMENT,
a5bd9f6
 		       "option -v isn't valid for writes");
a5bd9f6
 
a5bd9f6
-  grub_pci_iterate (grub_setpci_iter);
a5bd9f6
+  grub_pci_iterate (grub_setpci_iter, NULL);
a5bd9f6
   return GRUB_ERR_NONE;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
diff --git a/grub-core/disk/ahci.c b/grub-core/disk/ahci.c
a5bd9f6
index 4ab2d18..f229ff1 100644
a5bd9f6
--- a/grub-core/disk/ahci.c
a5bd9f6
+++ b/grub-core/disk/ahci.c
a5bd9f6
@@ -254,9 +254,10 @@ init_port (struct grub_ahci_device *dev)
a5bd9f6
   return 1;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
-static int NESTED_FUNC_ATTR
a5bd9f6
+static int
a5bd9f6
 grub_ahci_pciinit (grub_pci_device_t dev,
a5bd9f6
-		   grub_pci_id_t pciid __attribute__ ((unused)))
a5bd9f6
+		   grub_pci_id_t pciid __attribute__ ((unused)),
a5bd9f6
+		   void *data __attribute__ ((unused)))
a5bd9f6
 {
a5bd9f6
   grub_pci_address_t addr;
a5bd9f6
   grub_uint32_t class;
a5bd9f6
@@ -394,7 +395,7 @@ grub_ahci_pciinit (grub_pci_device_t dev,
a5bd9f6
 static grub_err_t
a5bd9f6
 grub_ahci_initialize (void)
a5bd9f6
 {
a5bd9f6
-  grub_pci_iterate (grub_ahci_pciinit);
a5bd9f6
+  grub_pci_iterate (grub_ahci_pciinit, NULL);
a5bd9f6
   return grub_errno;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
diff --git a/grub-core/disk/pata.c b/grub-core/disk/pata.c
a5bd9f6
index 00b04e2..07c3d7f 100644
a5bd9f6
--- a/grub-core/disk/pata.c
a5bd9f6
+++ b/grub-core/disk/pata.c
a5bd9f6
@@ -338,9 +338,10 @@ grub_pata_device_initialize (int port, int device, int addr)
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 #ifndef GRUB_MACHINE_MIPS_QEMU_MIPS
a5bd9f6
-static int NESTED_FUNC_ATTR
a5bd9f6
+static int
a5bd9f6
 grub_pata_pciinit (grub_pci_device_t dev,
a5bd9f6
-		   grub_pci_id_t pciid)
a5bd9f6
+		   grub_pci_id_t pciid,
a5bd9f6
+		   void *data __attribute__ ((unused)))
a5bd9f6
 {
a5bd9f6
   static int compat_use[2] = { 0 };
a5bd9f6
   grub_pci_address_t addr;
a5bd9f6
@@ -446,7 +447,7 @@ grub_pata_pciinit (grub_pci_device_t dev,
a5bd9f6
 static grub_err_t
a5bd9f6
 grub_pata_initialize (void)
a5bd9f6
 {
a5bd9f6
-  grub_pci_iterate (grub_pata_pciinit);
a5bd9f6
+  grub_pci_iterate (grub_pata_pciinit, NULL);
a5bd9f6
   return 0;
a5bd9f6
 }
a5bd9f6
 #else
a5bd9f6
diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c
a5bd9f6
index a2edc84..351317b 100644
a5bd9f6
--- a/grub-core/kern/efi/mm.c
a5bd9f6
+++ b/grub-core/kern/efi/mm.c
a5bd9f6
@@ -109,37 +109,36 @@ grub_efi_free_pages (grub_efi_physical_address_t address,
a5bd9f6
 
a5bd9f6
 #if defined (__i386__) || defined (__x86_64__)
a5bd9f6
 
a5bd9f6
-static void
a5bd9f6
-stop_broadcom (void)
a5bd9f6
+/* Helper for stop_broadcom.  */
a5bd9f6
+static int
a5bd9f6
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid,
a5bd9f6
+	   void *data __attribute__ ((unused)))
a5bd9f6
 {
a5bd9f6
-  auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
a5bd9f6
-				       grub_pci_id_t pciid);
a5bd9f6
-
a5bd9f6
-  int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
a5bd9f6
-				  grub_pci_id_t pciid)
a5bd9f6
-    {
a5bd9f6
-      grub_pci_address_t addr;
a5bd9f6
-      grub_uint8_t cap;
a5bd9f6
-      grub_uint16_t pm_state;
a5bd9f6
+  grub_pci_address_t addr;
a5bd9f6
+  grub_uint8_t cap;
a5bd9f6
+  grub_uint16_t pm_state;
a5bd9f6
 
a5bd9f6
-      if ((pciid & 0xffff) != GRUB_PCI_VENDOR_BROADCOM)
a5bd9f6
-	return 0;
a5bd9f6
+  if ((pciid & 0xffff) != GRUB_PCI_VENDOR_BROADCOM)
a5bd9f6
+    return 0;
a5bd9f6
 
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
-      if (grub_pci_read (addr) >> 24 != GRUB_PCI_CLASS_NETWORK)
a5bd9f6
-	return 0;
a5bd9f6
-      cap = grub_pci_find_capability (dev, GRUB_PCI_CAP_POWER_MANAGEMENT);
a5bd9f6
-      if (!cap)
a5bd9f6
-	return 0;
a5bd9f6
-      addr = grub_pci_make_address (dev, cap + 4);
a5bd9f6
-      pm_state = grub_pci_read_word (addr);
a5bd9f6
-      pm_state = pm_state | 0x03;
a5bd9f6
-      grub_pci_write_word (addr, pm_state);
a5bd9f6
-      grub_pci_read_word (addr);
a5bd9f6
-      return 0;
a5bd9f6
-    }
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
+  if (grub_pci_read (addr) >> 24 != GRUB_PCI_CLASS_NETWORK)
a5bd9f6
+    return 0;
a5bd9f6
+  cap = grub_pci_find_capability (dev, GRUB_PCI_CAP_POWER_MANAGEMENT);
a5bd9f6
+  if (!cap)
a5bd9f6
+    return 0;
a5bd9f6
+  addr = grub_pci_make_address (dev, cap + 4);
a5bd9f6
+  pm_state = grub_pci_read_word (addr);
a5bd9f6
+  pm_state = pm_state | 0x03;
a5bd9f6
+  grub_pci_write_word (addr, pm_state);
a5bd9f6
+  grub_pci_read_word (addr);
a5bd9f6
+  return 0;
a5bd9f6
+}
a5bd9f6
 
a5bd9f6
-  grub_pci_iterate (find_card);
a5bd9f6
+static void
a5bd9f6
+stop_broadcom (void)
a5bd9f6
+{
a5bd9f6
+  grub_pci_iterate (find_card, NULL);
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 #endif
a5bd9f6
diff --git a/grub-core/kern/mips/loongson/init.c b/grub-core/kern/mips/loongson/init.c
a5bd9f6
index 19f2d63..2109a67 100644
a5bd9f6
--- a/grub-core/kern/mips/loongson/init.c
a5bd9f6
+++ b/grub-core/kern/mips/loongson/init.c
a5bd9f6
@@ -49,45 +49,47 @@ grub_machine_mmap_iterate (grub_memory_hook_t hook)
a5bd9f6
   return GRUB_ERR_NONE;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
-static void
a5bd9f6
-init_pci (void)
a5bd9f6
+/* Helper for init_pci.  */
a5bd9f6
+static int
a5bd9f6
+set_card (grub_pci_device_t dev, grub_pci_id_t pciid,
a5bd9f6
+	  void *data __attribute__ ((unused)))
a5bd9f6
 {
a5bd9f6
-  auto int NESTED_FUNC_ATTR set_card (grub_pci_device_t dev, grub_pci_id_t pciid);
a5bd9f6
-  int NESTED_FUNC_ATTR set_card (grub_pci_device_t dev, grub_pci_id_t pciid)
a5bd9f6
-  {
a5bd9f6
-    grub_pci_address_t addr;
a5bd9f6
-    /* FIXME: autoscan for BARs and devices.  */
a5bd9f6
-    switch (pciid)
a5bd9f6
-      {
a5bd9f6
-      case GRUB_LOONGSON_OHCI_PCIID:
a5bd9f6
-	addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
-	grub_pci_write (addr, 0x5025000);
a5bd9f6
-	addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
a5bd9f6
-	grub_pci_write_word (addr, GRUB_PCI_COMMAND_SERR_ENABLE
a5bd9f6
-			     | GRUB_PCI_COMMAND_PARITY_ERROR
a5bd9f6
-			     | GRUB_PCI_COMMAND_BUS_MASTER
a5bd9f6
-			     | GRUB_PCI_COMMAND_MEM_ENABLED);
a5bd9f6
+  grub_pci_address_t addr;
a5bd9f6
+  /* FIXME: autoscan for BARs and devices.  */
a5bd9f6
+  switch (pciid)
a5bd9f6
+    {
a5bd9f6
+    case GRUB_LOONGSON_OHCI_PCIID:
a5bd9f6
+      addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
+      grub_pci_write (addr, 0x5025000);
a5bd9f6
+      addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
a5bd9f6
+      grub_pci_write_word (addr, GRUB_PCI_COMMAND_SERR_ENABLE
a5bd9f6
+			   | GRUB_PCI_COMMAND_PARITY_ERROR
a5bd9f6
+			   | GRUB_PCI_COMMAND_BUS_MASTER
a5bd9f6
+			   | GRUB_PCI_COMMAND_MEM_ENABLED);
a5bd9f6
 
a5bd9f6
-	addr = grub_pci_make_address (dev, GRUB_PCI_REG_STATUS);
a5bd9f6
-	grub_pci_write_word (addr, 0x0200 | GRUB_PCI_STATUS_CAPABILITIES);
a5bd9f6
-	break;
a5bd9f6
-      case GRUB_LOONGSON_EHCI_PCIID:
a5bd9f6
-	addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
-	grub_pci_write (addr, 0x5026000);
a5bd9f6
-	addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
a5bd9f6
-	grub_pci_write_word (addr, GRUB_PCI_COMMAND_SERR_ENABLE
a5bd9f6
-			     | GRUB_PCI_COMMAND_PARITY_ERROR
a5bd9f6
-			     | GRUB_PCI_COMMAND_BUS_MASTER
a5bd9f6
-			     | GRUB_PCI_COMMAND_MEM_ENABLED);
a5bd9f6
+      addr = grub_pci_make_address (dev, GRUB_PCI_REG_STATUS);
a5bd9f6
+      grub_pci_write_word (addr, 0x0200 | GRUB_PCI_STATUS_CAPABILITIES);
a5bd9f6
+      break;
a5bd9f6
+    case GRUB_LOONGSON_EHCI_PCIID:
a5bd9f6
+      addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
+      grub_pci_write (addr, 0x5026000);
a5bd9f6
+      addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
a5bd9f6
+      grub_pci_write_word (addr, GRUB_PCI_COMMAND_SERR_ENABLE
a5bd9f6
+			   | GRUB_PCI_COMMAND_PARITY_ERROR
a5bd9f6
+			   | GRUB_PCI_COMMAND_BUS_MASTER
a5bd9f6
+			   | GRUB_PCI_COMMAND_MEM_ENABLED);
a5bd9f6
 
a5bd9f6
-	addr = grub_pci_make_address (dev, GRUB_PCI_REG_STATUS);
a5bd9f6
-	grub_pci_write_word (addr, (1 << GRUB_PCI_STATUS_DEVSEL_TIMING_SHIFT)
a5bd9f6
-			     | GRUB_PCI_STATUS_CAPABILITIES);
a5bd9f6
-	break;
a5bd9f6
-      }
a5bd9f6
-    return 0;
a5bd9f6
-  }
a5bd9f6
+      addr = grub_pci_make_address (dev, GRUB_PCI_REG_STATUS);
a5bd9f6
+      grub_pci_write_word (addr, (1 << GRUB_PCI_STATUS_DEVSEL_TIMING_SHIFT)
a5bd9f6
+			   | GRUB_PCI_STATUS_CAPABILITIES);
a5bd9f6
+      break;
a5bd9f6
+    }
a5bd9f6
+  return 0;
a5bd9f6
+}
a5bd9f6
 
a5bd9f6
+static void
a5bd9f6
+init_pci (void)
a5bd9f6
+{
a5bd9f6
   *((volatile grub_uint32_t *) GRUB_CPU_LOONGSON_PCI_HIT1_SEL_LO) = 0x8000000c;
a5bd9f6
   *((volatile grub_uint32_t *) GRUB_CPU_LOONGSON_PCI_HIT1_SEL_HI) = 0xffffffff;
a5bd9f6
 
a5bd9f6
@@ -110,7 +112,7 @@ init_pci (void)
a5bd9f6
   *((volatile grub_uint32_t *) (GRUB_MACHINE_PCI_CONTROLLER_HEADER 
a5bd9f6
 				+ GRUB_PCI_REG_ADDRESS_REG1)) = 0;
a5bd9f6
 
a5bd9f6
-  grub_pci_iterate (set_card);
a5bd9f6
+  grub_pci_iterate (set_card, NULL);
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 void
a5bd9f6
diff --git a/grub-core/kern/vga_init.c b/grub-core/kern/vga_init.c
a5bd9f6
index 889d012..1119bb3 100644
a5bd9f6
--- a/grub-core/kern/vga_init.c
a5bd9f6
+++ b/grub-core/kern/vga_init.c
a5bd9f6
@@ -18,6 +18,7 @@
a5bd9f6
 
a5bd9f6
 #ifndef __mips__
a5bd9f6
 #include <grub/pci.h>
a5bd9f6
+#include <grub/mm.h>
a5bd9f6
 #endif
a5bd9f6
 #include <grub/machine/kernel.h>
a5bd9f6
 #include <grub/misc.h>
a5bd9f6
@@ -87,38 +88,42 @@ load_palette (void)
a5bd9f6
     grub_vga_palette_write (i, colors[i].r, colors[i].g, colors[i].b);
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
+#ifndef __mips__
a5bd9f6
+/* Helper for grub_qemu_init_cirrus.  */
a5bd9f6
+static int
a5bd9f6
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid __attribute__ ((unused)),
a5bd9f6
+	   void *data __attribute__ ((unused)))
a5bd9f6
+{
a5bd9f6
+  grub_pci_address_t addr;
a5bd9f6
+  grub_uint32_t class;
a5bd9f6
+
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
+  class = grub_pci_read (addr);
a5bd9f6
+
a5bd9f6
+  if (((class >> 16) & 0xffff) != GRUB_PCI_CLASS_SUBCLASS_VGA)
a5bd9f6
+    return 0;
a5bd9f6
+  
a5bd9f6
+  /* FIXME: chooose addresses dynamically.  */
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
+  grub_pci_write (addr, 0xf0000000 | GRUB_PCI_ADDR_MEM_PREFETCH
a5bd9f6
+		  | GRUB_PCI_ADDR_SPACE_MEMORY | GRUB_PCI_ADDR_MEM_TYPE_32);
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG1);
a5bd9f6
+  grub_pci_write (addr, 0xf2000000
a5bd9f6
+		  | GRUB_PCI_ADDR_SPACE_MEMORY | GRUB_PCI_ADDR_MEM_TYPE_32);
a5bd9f6
+
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
a5bd9f6
+  grub_pci_write (addr, GRUB_PCI_COMMAND_MEM_ENABLED
a5bd9f6
+		  | GRUB_PCI_COMMAND_IO_ENABLED);
a5bd9f6
+  
a5bd9f6
+  return 1;
a5bd9f6
+}
a5bd9f6
+#endif
a5bd9f6
+
a5bd9f6
 void
a5bd9f6
 grub_qemu_init_cirrus (void)
a5bd9f6
 {
a5bd9f6
 #ifndef __mips__
a5bd9f6
-  auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
a5bd9f6
-  int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid __attribute__ ((unused)))
a5bd9f6
-    {
a5bd9f6
-      grub_pci_address_t addr;
a5bd9f6
-      grub_uint32_t class;
a5bd9f6
-
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
-      class = grub_pci_read (addr);
a5bd9f6
-
a5bd9f6
-      if (((class >> 16) & 0xffff) != GRUB_PCI_CLASS_SUBCLASS_VGA)
a5bd9f6
-	return 0;
a5bd9f6
-      
a5bd9f6
-      /* FIXME: chooose addresses dynamically.  */
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
-      grub_pci_write (addr, 0xf0000000 | GRUB_PCI_ADDR_MEM_PREFETCH
a5bd9f6
-		      | GRUB_PCI_ADDR_SPACE_MEMORY | GRUB_PCI_ADDR_MEM_TYPE_32);
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG1);
a5bd9f6
-      grub_pci_write (addr, 0xf2000000
a5bd9f6
-		      | GRUB_PCI_ADDR_SPACE_MEMORY | GRUB_PCI_ADDR_MEM_TYPE_32);
a5bd9f6
- 
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_COMMAND);
a5bd9f6
-      grub_pci_write (addr, GRUB_PCI_COMMAND_MEM_ENABLED
a5bd9f6
-		      | GRUB_PCI_COMMAND_IO_ENABLED);
a5bd9f6
-      
a5bd9f6
-      return 1;
a5bd9f6
-    }
a5bd9f6
-
a5bd9f6
-  grub_pci_iterate (find_card);
a5bd9f6
+  grub_pci_iterate (find_card, NULL);
a5bd9f6
 #endif
a5bd9f6
 
a5bd9f6
   grub_outb (GRUB_VGA_IO_MISC_COLOR,
a5bd9f6
diff --git a/grub-core/video/bochs.c b/grub-core/video/bochs.c
a5bd9f6
index f6db137..aea486c 100644
a5bd9f6
--- a/grub-core/video/bochs.c
a5bd9f6
+++ b/grub-core/video/bochs.c
a5bd9f6
@@ -199,6 +199,29 @@ grub_video_bochs_set_palette (unsigned int start, unsigned int count,
a5bd9f6
   return grub_video_fb_set_palette (start, count, palette_data);
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
+/* Helper for grub_video_bochs_setup.  */
a5bd9f6
+static int
a5bd9f6
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
a5bd9f6
+{
a5bd9f6
+  int *found = data;
a5bd9f6
+  grub_pci_address_t addr;
a5bd9f6
+  grub_uint32_t class;
a5bd9f6
+
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
+  class = grub_pci_read (addr);
a5bd9f6
+
a5bd9f6
+  if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x11111234)
a5bd9f6
+    return 0;
a5bd9f6
+  
a5bd9f6
+  *found = 1;
a5bd9f6
+
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
+  framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
a5bd9f6
+  framebuffer.dev = dev;
a5bd9f6
+
a5bd9f6
+  return 1;
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
 static grub_err_t
a5bd9f6
 grub_video_bochs_setup (unsigned int width, unsigned int height,
a5bd9f6
 			grub_video_mode_type_t mode_type,
a5bd9f6
@@ -210,27 +233,6 @@ grub_video_bochs_setup (unsigned int width, unsigned int height,
a5bd9f6
   int pitch, bytes_per_pixel;
a5bd9f6
   grub_size_t page_size;        /* The size of a page in bytes.  */
a5bd9f6
 
a5bd9f6
-  auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
a5bd9f6
-  int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid)
a5bd9f6
-    {
a5bd9f6
-      grub_pci_address_t addr;
a5bd9f6
-      grub_uint32_t class;
a5bd9f6
-
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
-      class = grub_pci_read (addr);
a5bd9f6
-
a5bd9f6
-      if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x11111234)
a5bd9f6
-	return 0;
a5bd9f6
-      
a5bd9f6
-      found = 1;
a5bd9f6
-
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
-      framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
a5bd9f6
-      framebuffer.dev = dev;
a5bd9f6
-
a5bd9f6
-      return 1;
a5bd9f6
-    }
a5bd9f6
-
a5bd9f6
   /* Decode depth from mode_type.  If it is zero, then autodetect.  */
a5bd9f6
   depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
a5bd9f6
           >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
a5bd9f6
@@ -280,7 +282,7 @@ grub_video_bochs_setup (unsigned int width, unsigned int height,
a5bd9f6
   if (page_size > BOCHS_APERTURE_SIZE)
a5bd9f6
     return grub_error (GRUB_ERR_IO, "Not enough video memory for this mode");
a5bd9f6
 
a5bd9f6
-  grub_pci_iterate (find_card);
a5bd9f6
+  grub_pci_iterate (find_card, &found);
a5bd9f6
   if (!found)
a5bd9f6
     return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
a5bd9f6
 
a5bd9f6
diff --git a/grub-core/video/cirrus.c b/grub-core/video/cirrus.c
a5bd9f6
index e711119..073c54e 100644
a5bd9f6
--- a/grub-core/video/cirrus.c
a5bd9f6
+++ b/grub-core/video/cirrus.c
a5bd9f6
@@ -235,6 +235,29 @@ grub_video_cirrus_set_palette (unsigned int start, unsigned int count,
a5bd9f6
   return grub_video_fb_set_palette (start, count, palette_data);
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
+/* Helper for grub_video_cirrus_setup.  */
a5bd9f6
+static int
a5bd9f6
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
a5bd9f6
+{
a5bd9f6
+  int *found = data;
a5bd9f6
+  grub_pci_address_t addr;
a5bd9f6
+  grub_uint32_t class;
a5bd9f6
+
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
+  class = grub_pci_read (addr);
a5bd9f6
+
a5bd9f6
+  if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x00b81013)
a5bd9f6
+    return 0;
a5bd9f6
+  
a5bd9f6
+  *found = 1;
a5bd9f6
+
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
+  framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
a5bd9f6
+  framebuffer.dev = dev;
a5bd9f6
+
a5bd9f6
+  return 1;
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
 static grub_err_t
a5bd9f6
 grub_video_cirrus_setup (unsigned int width, unsigned int height,
a5bd9f6
 			 grub_video_mode_type_t mode_type,
a5bd9f6
@@ -245,27 +268,6 @@ grub_video_cirrus_setup (unsigned int width, unsigned int height,
a5bd9f6
   int found = 0;
a5bd9f6
   int pitch, bytes_per_pixel;
a5bd9f6
 
a5bd9f6
-  auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
a5bd9f6
-  int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid)
a5bd9f6
-    {
a5bd9f6
-      grub_pci_address_t addr;
a5bd9f6
-      grub_uint32_t class;
a5bd9f6
-
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
-      class = grub_pci_read (addr);
a5bd9f6
-
a5bd9f6
-      if (((class >> 16) & 0xffff) != 0x0300 || pciid != 0x00b81013)
a5bd9f6
-	return 0;
a5bd9f6
-      
a5bd9f6
-      found = 1;
a5bd9f6
-
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
-      framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
a5bd9f6
-      framebuffer.dev = dev;
a5bd9f6
-
a5bd9f6
-      return 1;
a5bd9f6
-    }
a5bd9f6
-
a5bd9f6
   /* Decode depth from mode_type.  If it is zero, then autodetect.  */
a5bd9f6
   depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
a5bd9f6
           >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
a5bd9f6
@@ -314,7 +316,7 @@ grub_video_cirrus_setup (unsigned int width, unsigned int height,
a5bd9f6
   if (framebuffer.page_size > CIRRUS_APERTURE_SIZE)
a5bd9f6
     return grub_error (GRUB_ERR_IO, "Not enough video memory for this mode");
a5bd9f6
 
a5bd9f6
-  grub_pci_iterate (find_card);
a5bd9f6
+  grub_pci_iterate (find_card, &found);
a5bd9f6
   if (!found)
a5bd9f6
     return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
a5bd9f6
 
a5bd9f6
diff --git a/grub-core/video/efi_uga.c b/grub-core/video/efi_uga.c
a5bd9f6
index 016adbb..695f015 100644
a5bd9f6
--- a/grub-core/video/efi_uga.c
a5bd9f6
+++ b/grub-core/video/efi_uga.c
a5bd9f6
@@ -81,77 +81,88 @@ find_line_len (grub_uint32_t *fb_base, grub_uint32_t *line_len)
a5bd9f6
   return 0;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
-static int
a5bd9f6
-find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
a5bd9f6
+/* Context for find_framebuf.  */
a5bd9f6
+struct find_framebuf_ctx
a5bd9f6
 {
a5bd9f6
-  int found = 0;
a5bd9f6
+  grub_uint32_t *fb_base;
a5bd9f6
+  grub_uint32_t *line_len;
a5bd9f6
+  int found;
a5bd9f6
+};
a5bd9f6
 
a5bd9f6
-  auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
a5bd9f6
-				       grub_pci_id_t pciid);
a5bd9f6
+/* Helper for find_framebuf.  */
a5bd9f6
+static int
a5bd9f6
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
a5bd9f6
+{
a5bd9f6
+  struct find_framebuf_ctx *ctx = data;
a5bd9f6
+  grub_pci_address_t addr;
a5bd9f6
 
a5bd9f6
-  int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev,
a5bd9f6
-				  grub_pci_id_t pciid)
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
+  if (grub_pci_read (addr) >> 24 == 0x3)
a5bd9f6
     {
a5bd9f6
-      grub_pci_address_t addr;
a5bd9f6
+      int i;
a5bd9f6
 
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
-      if (grub_pci_read (addr) >> 24 == 0x3)
a5bd9f6
+      grub_dprintf ("fb", "Display controller: %d:%d.%d\nDevice id: %x\n",
a5bd9f6
+		    grub_pci_get_bus (dev), grub_pci_get_device (dev),
a5bd9f6
+		    grub_pci_get_function (dev), pciid);
a5bd9f6
+      addr += 8;
a5bd9f6
+      for (i = 0; i < 6; i++, addr += 4)
a5bd9f6
 	{
a5bd9f6
-	  int i;
a5bd9f6
-
a5bd9f6
-	  grub_dprintf ("fb", "Display controller: %d:%d.%d\nDevice id: %x\n",
a5bd9f6
-			grub_pci_get_bus (dev), grub_pci_get_device (dev),
a5bd9f6
-			grub_pci_get_function (dev), pciid);
a5bd9f6
-	  addr += 8;
a5bd9f6
-	  for (i = 0; i < 6; i++, addr += 4)
a5bd9f6
-	    {
a5bd9f6
-	      grub_uint32_t old_bar1, old_bar2, type;
a5bd9f6
-	      grub_uint64_t base64;
a5bd9f6
+	  grub_uint32_t old_bar1, old_bar2, type;
a5bd9f6
+	  grub_uint64_t base64;
a5bd9f6
 
a5bd9f6
-	      old_bar1 = grub_pci_read (addr);
a5bd9f6
-	      if ((! old_bar1) || (old_bar1 & GRUB_PCI_ADDR_SPACE_IO))
a5bd9f6
-		continue;
a5bd9f6
+	  old_bar1 = grub_pci_read (addr);
a5bd9f6
+	  if ((! old_bar1) || (old_bar1 & GRUB_PCI_ADDR_SPACE_IO))
a5bd9f6
+	    continue;
a5bd9f6
 
a5bd9f6
-	      type = old_bar1 & GRUB_PCI_ADDR_MEM_TYPE_MASK;
a5bd9f6
-	      if (type == GRUB_PCI_ADDR_MEM_TYPE_64)
a5bd9f6
-		{
a5bd9f6
-		  if (i == 5)
a5bd9f6
-		    break;
a5bd9f6
+	  type = old_bar1 & GRUB_PCI_ADDR_MEM_TYPE_MASK;
a5bd9f6
+	  if (type == GRUB_PCI_ADDR_MEM_TYPE_64)
a5bd9f6
+	    {
a5bd9f6
+	      if (i == 5)
a5bd9f6
+		break;
a5bd9f6
 
a5bd9f6
-		  old_bar2 = grub_pci_read (addr + 4);
a5bd9f6
-		}
a5bd9f6
-	      else
a5bd9f6
-		old_bar2 = 0;
a5bd9f6
+	      old_bar2 = grub_pci_read (addr + 4);
a5bd9f6
+	    }
a5bd9f6
+	  else
a5bd9f6
+	    old_bar2 = 0;
a5bd9f6
 
a5bd9f6
-	      base64 = old_bar2;
a5bd9f6
-	      base64 <<= 32;
a5bd9f6
-	      base64 |= (old_bar1 & GRUB_PCI_ADDR_MEM_MASK);
a5bd9f6
+	  base64 = old_bar2;
a5bd9f6
+	  base64 <<= 32;
a5bd9f6
+	  base64 |= (old_bar1 & GRUB_PCI_ADDR_MEM_MASK);
a5bd9f6
 
a5bd9f6
-	      grub_dprintf ("fb", "%s(%d): 0x%llx\n",
a5bd9f6
-			    ((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) ?
a5bd9f6
-			    "VMEM" : "MMIO"), i,
a5bd9f6
-			   (unsigned long long) base64);
a5bd9f6
+	  grub_dprintf ("fb", "%s(%d): 0x%llx\n",
a5bd9f6
+			((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) ?
a5bd9f6
+			"VMEM" : "MMIO"), i,
a5bd9f6
+		       (unsigned long long) base64);
a5bd9f6
 
a5bd9f6
-	      if ((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) && (! found))
a5bd9f6
-		{
a5bd9f6
-		  *fb_base = base64;
a5bd9f6
-		  if (find_line_len (fb_base, line_len))
a5bd9f6
-		    found++;
a5bd9f6
-		}
a5bd9f6
+	  if ((old_bar1 & GRUB_PCI_ADDR_MEM_PREFETCH) && (! ctx->found))
a5bd9f6
+	    {
a5bd9f6
+	      *ctx->fb_base = base64;
a5bd9f6
+	      if (find_line_len (ctx->fb_base, ctx->line_len))
a5bd9f6
+		ctx->found++;
a5bd9f6
+	    }
a5bd9f6
 
a5bd9f6
-	      if (type == GRUB_PCI_ADDR_MEM_TYPE_64)
a5bd9f6
-		{
a5bd9f6
-		  i++;
a5bd9f6
-		  addr += 4;
a5bd9f6
-		}
a5bd9f6
+	  if (type == GRUB_PCI_ADDR_MEM_TYPE_64)
a5bd9f6
+	    {
a5bd9f6
+	      i++;
a5bd9f6
+	      addr += 4;
a5bd9f6
 	    }
a5bd9f6
 	}
a5bd9f6
-
a5bd9f6
-      return found;
a5bd9f6
     }
a5bd9f6
 
a5bd9f6
-  grub_pci_iterate (find_card);
a5bd9f6
-  return found;
a5bd9f6
+  return ctx->found;
a5bd9f6
+}
a5bd9f6
+
a5bd9f6
+static int
a5bd9f6
+find_framebuf (grub_uint32_t *fb_base, grub_uint32_t *line_len)
a5bd9f6
+{
a5bd9f6
+  struct find_framebuf_ctx ctx = {
a5bd9f6
+    .fb_base = fb_base,
a5bd9f6
+    .line_len = line_len,
a5bd9f6
+    .found = 0
a5bd9f6
+  };
a5bd9f6
+
a5bd9f6
+  grub_pci_iterate (find_card, &ctx;;
a5bd9f6
+  return ctx.found;
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
 static int
a5bd9f6
diff --git a/grub-core/video/radeon_fuloong2e.c b/grub-core/video/radeon_fuloong2e.c
a5bd9f6
index 45a68ed..c3d65f1 100644
a5bd9f6
--- a/grub-core/video/radeon_fuloong2e.c
a5bd9f6
+++ b/grub-core/video/radeon_fuloong2e.c
a5bd9f6
@@ -60,6 +60,32 @@ grub_video_radeon_fuloong2e_video_fini (void)
a5bd9f6
   return grub_video_fb_fini ();
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
+#ifndef TEST
a5bd9f6
+/* Helper for grub_video_radeon_fuloong2e_setup.  */
a5bd9f6
+static int
a5bd9f6
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
a5bd9f6
+{
a5bd9f6
+  int *found = data;
a5bd9f6
+  grub_pci_address_t addr;
a5bd9f6
+  grub_uint32_t class;
a5bd9f6
+
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
+  class = grub_pci_read (addr);
a5bd9f6
+
a5bd9f6
+  if (((class >> 16) & 0xffff) != GRUB_PCI_CLASS_SUBCLASS_VGA
a5bd9f6
+      || pciid != 0x515a1002)
a5bd9f6
+    return 0;
a5bd9f6
+  
a5bd9f6
+  *found = 1;
a5bd9f6
+
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
+  framebuffer.base = grub_pci_read (addr);
a5bd9f6
+  framebuffer.dev = dev;
a5bd9f6
+
a5bd9f6
+  return 1;
a5bd9f6
+}
a5bd9f6
+#endif
a5bd9f6
+
a5bd9f6
 static grub_err_t
a5bd9f6
 grub_video_radeon_fuloong2e_setup (unsigned int width, unsigned int height,
a5bd9f6
 			unsigned int mode_type, unsigned int mode_mask __attribute__ ((unused)))
a5bd9f6
@@ -69,28 +95,6 @@ grub_video_radeon_fuloong2e_setup (unsigned int width, unsigned int height,
a5bd9f6
   int found = 0;
a5bd9f6
 
a5bd9f6
 #ifndef TEST
a5bd9f6
-  auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
a5bd9f6
-  int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid)
a5bd9f6
-    {
a5bd9f6
-      grub_pci_address_t addr;
a5bd9f6
-      grub_uint32_t class;
a5bd9f6
-
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
-      class = grub_pci_read (addr);
a5bd9f6
-
a5bd9f6
-      if (((class >> 16) & 0xffff) != GRUB_PCI_CLASS_SUBCLASS_VGA
a5bd9f6
-	  || pciid != 0x515a1002)
a5bd9f6
-	return 0;
a5bd9f6
-      
a5bd9f6
-      found = 1;
a5bd9f6
-
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
-      framebuffer.base = grub_pci_read (addr);
a5bd9f6
-      framebuffer.dev = dev;
a5bd9f6
-
a5bd9f6
-      return 1;
a5bd9f6
-    }
a5bd9f6
-
a5bd9f6
   /* Decode depth from mode_type.  If it is zero, then autodetect.  */
a5bd9f6
   depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
a5bd9f6
           >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
a5bd9f6
@@ -100,7 +104,7 @@ grub_video_radeon_fuloong2e_setup (unsigned int width, unsigned int height,
a5bd9f6
     return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
a5bd9f6
 		       "Only 640x480x16 is supported");
a5bd9f6
 
a5bd9f6
-  grub_pci_iterate (find_card);
a5bd9f6
+  grub_pci_iterate (find_card, &found);
a5bd9f6
   if (!found)
a5bd9f6
     return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
a5bd9f6
 #endif
a5bd9f6
diff --git a/grub-core/video/sis315pro.c b/grub-core/video/sis315pro.c
a5bd9f6
index d213877..a986669 100644
a5bd9f6
--- a/grub-core/video/sis315pro.c
a5bd9f6
+++ b/grub-core/video/sis315pro.c
a5bd9f6
@@ -88,6 +88,37 @@ grub_video_sis315pro_video_fini (void)
a5bd9f6
 
a5bd9f6
 #include "sis315_init.c"
a5bd9f6
 
a5bd9f6
+#ifndef TEST
a5bd9f6
+/* Helper for grub_video_sis315pro_setup.  */
a5bd9f6
+static int
a5bd9f6
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
a5bd9f6
+{
a5bd9f6
+  int *found = data;
a5bd9f6
+  grub_pci_address_t addr;
a5bd9f6
+  grub_uint32_t class;
a5bd9f6
+
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
+  class = grub_pci_read (addr);
a5bd9f6
+
a5bd9f6
+  if (((class >> 16) & 0xffff) != GRUB_PCI_CLASS_SUBCLASS_VGA
a5bd9f6
+      || pciid != GRUB_SIS315PRO_PCIID)
a5bd9f6
+    return 0;
a5bd9f6
+  
a5bd9f6
+  *found = 1;
a5bd9f6
+
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
+  framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG1);
a5bd9f6
+  framebuffer.mmiobase = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG2);
a5bd9f6
+  framebuffer.io = (grub_pci_read (addr) & GRUB_PCI_ADDR_IO_MASK)
a5bd9f6
+    + GRUB_MACHINE_PCI_IO_BASE;
a5bd9f6
+  framebuffer.dev = dev;
a5bd9f6
+
a5bd9f6
+  return 1;
a5bd9f6
+}
a5bd9f6
+#endif
a5bd9f6
+
a5bd9f6
 static grub_err_t
a5bd9f6
 grub_video_sis315pro_setup (unsigned int width, unsigned int height,
a5bd9f6
 			    unsigned int mode_type,
a5bd9f6
@@ -99,33 +130,6 @@ grub_video_sis315pro_setup (unsigned int width, unsigned int height,
a5bd9f6
   unsigned i;
a5bd9f6
 
a5bd9f6
 #ifndef TEST
a5bd9f6
-  auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
a5bd9f6
-  int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid)
a5bd9f6
-    {
a5bd9f6
-      grub_pci_address_t addr;
a5bd9f6
-      grub_uint32_t class;
a5bd9f6
-
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
-      class = grub_pci_read (addr);
a5bd9f6
-
a5bd9f6
-      if (((class >> 16) & 0xffff) != GRUB_PCI_CLASS_SUBCLASS_VGA
a5bd9f6
-	  || pciid != GRUB_SIS315PRO_PCIID)
a5bd9f6
-	return 0;
a5bd9f6
-      
a5bd9f6
-      found = 1;
a5bd9f6
-
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
-      framebuffer.base = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG1);
a5bd9f6
-      framebuffer.mmiobase = grub_pci_read (addr) & GRUB_PCI_ADDR_MEM_MASK;
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG2);
a5bd9f6
-      framebuffer.io = (grub_pci_read (addr) & GRUB_PCI_ADDR_IO_MASK)
a5bd9f6
-	+ GRUB_MACHINE_PCI_IO_BASE;
a5bd9f6
-      framebuffer.dev = dev;
a5bd9f6
-
a5bd9f6
-      return 1;
a5bd9f6
-    }
a5bd9f6
-
a5bd9f6
   /* Decode depth from mode_type.  If it is zero, then autodetect.  */
a5bd9f6
   depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
a5bd9f6
           >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
a5bd9f6
@@ -135,7 +139,7 @@ grub_video_sis315pro_setup (unsigned int width, unsigned int height,
a5bd9f6
     return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
a5bd9f6
 		       "Only 640x480x8 is supported");
a5bd9f6
 
a5bd9f6
-  grub_pci_iterate (find_card);
a5bd9f6
+  grub_pci_iterate (find_card, &found);
a5bd9f6
   if (!found)
a5bd9f6
     return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
a5bd9f6
 #endif
a5bd9f6
diff --git a/grub-core/video/sm712.c b/grub-core/video/sm712.c
a5bd9f6
index d780983..fb40d64 100644
a5bd9f6
--- a/grub-core/video/sm712.c
a5bd9f6
+++ b/grub-core/video/sm712.c
a5bd9f6
@@ -360,6 +360,32 @@ grub_sm712_write_dda_lookup (int idx, grub_uint8_t compare, grub_uint16_t dda,
a5bd9f6
 		       GRUB_SM712_CR_DDA_LOOKUP_REG1_START + idx);
a5bd9f6
 }
a5bd9f6
 
a5bd9f6
+#if !defined (TEST) && !defined(GENINIT)
a5bd9f6
+/* Helper for grub_video_sm712_setup.  */
a5bd9f6
+static int
a5bd9f6
+find_card (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
a5bd9f6
+{
a5bd9f6
+  int *found = data;
a5bd9f6
+  grub_pci_address_t addr;
a5bd9f6
+  grub_uint32_t class;
a5bd9f6
+
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
+  class = grub_pci_read (addr);
a5bd9f6
+
a5bd9f6
+  if (((class >> 16) & 0xffff) != GRUB_PCI_CLASS_SUBCLASS_VGA
a5bd9f6
+      || pciid != GRUB_SM712_PCIID)
a5bd9f6
+    return 0;
a5bd9f6
+  
a5bd9f6
+  *found = 1;
a5bd9f6
+
a5bd9f6
+  addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
+  framebuffer.base = grub_pci_read (addr);
a5bd9f6
+  framebuffer.dev = dev;
a5bd9f6
+
a5bd9f6
+  return 1;
a5bd9f6
+}
a5bd9f6
+#endif
a5bd9f6
+
a5bd9f6
 static grub_err_t
a5bd9f6
 grub_video_sm712_setup (unsigned int width, unsigned int height,
a5bd9f6
 			unsigned int mode_type, unsigned int mode_mask __attribute__ ((unused)))
a5bd9f6
@@ -370,28 +396,6 @@ grub_video_sm712_setup (unsigned int width, unsigned int height,
a5bd9f6
   grub_err_t err;
a5bd9f6
   int found = 0;
a5bd9f6
 
a5bd9f6
-  auto int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid);
a5bd9f6
-  int NESTED_FUNC_ATTR find_card (grub_pci_device_t dev, grub_pci_id_t pciid)
a5bd9f6
-    {
a5bd9f6
-      grub_pci_address_t addr;
a5bd9f6
-      grub_uint32_t class;
a5bd9f6
-
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_CLASS);
a5bd9f6
-      class = grub_pci_read (addr);
a5bd9f6
-
a5bd9f6
-      if (((class >> 16) & 0xffff) != GRUB_PCI_CLASS_SUBCLASS_VGA
a5bd9f6
-	  || pciid != GRUB_SM712_PCIID)
a5bd9f6
-	return 0;
a5bd9f6
-      
a5bd9f6
-      found = 1;
a5bd9f6
-
a5bd9f6
-      addr = grub_pci_make_address (dev, GRUB_PCI_REG_ADDRESS_REG0);
a5bd9f6
-      framebuffer.base = grub_pci_read (addr);
a5bd9f6
-      framebuffer.dev = dev;
a5bd9f6
-
a5bd9f6
-      return 1;
a5bd9f6
-    }
a5bd9f6
-
a5bd9f6
   /* Decode depth from mode_type.  If it is zero, then autodetect.  */
a5bd9f6
   depth = (mode_type & GRUB_VIDEO_MODE_TYPE_DEPTH_MASK)
a5bd9f6
           >> GRUB_VIDEO_MODE_TYPE_DEPTH_POS;
a5bd9f6
@@ -401,7 +405,7 @@ grub_video_sm712_setup (unsigned int width, unsigned int height,
a5bd9f6
     return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
a5bd9f6
 		       "Only 1024x600x16 is supported");
a5bd9f6
 
a5bd9f6
-  grub_pci_iterate (find_card);
a5bd9f6
+  grub_pci_iterate (find_card, &found);
a5bd9f6
   if (!found)
a5bd9f6
     return grub_error (GRUB_ERR_IO, "Couldn't find graphics card");
a5bd9f6
   /* Fill mode info details.  */
a5bd9f6
diff --git a/include/grub/pci.h b/include/grub/pci.h
a5bd9f6
index aaf0101..e163d47 100644
a5bd9f6
--- a/include/grub/pci.h
a5bd9f6
+++ b/include/grub/pci.h
a5bd9f6
@@ -132,13 +132,14 @@ grub_pci_get_function (grub_pci_device_t dev)
a5bd9f6
 #include <grub/cpu/pci.h>
a5bd9f6
 #endif
a5bd9f6
 
a5bd9f6
-typedef int NESTED_FUNC_ATTR (*grub_pci_iteratefunc_t)
a5bd9f6
-     (grub_pci_device_t dev, grub_pci_id_t pciid);
a5bd9f6
+typedef int (*grub_pci_iteratefunc_t)
a5bd9f6
+     (grub_pci_device_t dev, grub_pci_id_t pciid, void *data);
a5bd9f6
 
a5bd9f6
 grub_pci_address_t EXPORT_FUNC(grub_pci_make_address) (grub_pci_device_t dev,
a5bd9f6
 						       int reg);
a5bd9f6
 
a5bd9f6
-void EXPORT_FUNC(grub_pci_iterate) (grub_pci_iteratefunc_t hook);
a5bd9f6
+void EXPORT_FUNC(grub_pci_iterate) (grub_pci_iteratefunc_t hook,
a5bd9f6
+				    void *hook_data);
a5bd9f6
 
a5bd9f6
 struct grub_pci_dma_chunk;
a5bd9f6
 
a5bd9f6
-- 
a5bd9f6
1.8.1.4
a5bd9f6