Remove nested functions from PCI iterators.
* grub-core/bus/pci.c (grub_pci_iterate): Add hook_data argument, passed to hook. Update all callers to pass appropriate hook data. * grub-core/bus/emu/pci.c (grub_pci_iterate): Likewise. * include/grub/pci.h (grub_pci_iteratefunc_t): Add data argument. Remove NESTED_FUNC_ATTR from here and from all users. (grub_pci_iterate): Update prototype. * grub-core/bus/cs5536.c (grub_cs5536_find: hook): Make static instead of nested. Rename to ... (grub_cs5536_find_iter): ... this. * grub-core/kern/efi/mm.c (stop_broadcom: find_card): Likewise. * grub-core/kern/mips/loongson/init.c (init_pci: set_card): Likewise. * grub-core/kern/vga_init.c (grub_qemu_init_cirrus: find_card): Likewise. * grub-core/video/bochs.c (grub_video_bochs_setup: find_card): Likewise. * grub-core/video/cirrus.c (grub_video_cirrus_setup: find_card): Likewise. * grub-core/video/efi_uga.c (find_framebuf: find_card): Likewise. * grub-core/video/radeon_fuloong2e.c (grub_video_radeon_fuloong2e_setup: find_card): Likewise. * grub-core/video/sis315pro.c (grub_video_sis315pro_setup: find_card): Likewise. * grub-core/video/sm712.c (grub_video_sm712_setup: find_card): Likewise.
This commit is contained in:
parent
f8e98fee04
commit
ca3a74469a
22 changed files with 411 additions and 327 deletions
|
@ -29,28 +29,39 @@
|
|||
|
||||
GRUB_MOD_LICENSE ("GPLv3+");
|
||||
|
||||
/* Context for grub_cs5536_find. */
|
||||
struct grub_cs5536_find_ctx
|
||||
{
|
||||
grub_pci_device_t *devp;
|
||||
int found;
|
||||
};
|
||||
|
||||
/* Helper for grub_cs5536_find. */
|
||||
static int
|
||||
grub_cs5536_find_iter (grub_pci_device_t dev, grub_pci_id_t pciid, void *data)
|
||||
{
|
||||
struct grub_cs5536_find_ctx *ctx = data;
|
||||
|
||||
if (pciid == GRUB_CS5536_PCIID)
|
||||
{
|
||||
*ctx->devp = dev;
|
||||
ctx->found = 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
grub_cs5536_find (grub_pci_device_t *devp)
|
||||
{
|
||||
int found = 0;
|
||||
auto int NESTED_FUNC_ATTR hook (grub_pci_device_t dev,
|
||||
grub_pci_id_t pciid);
|
||||
struct grub_cs5536_find_ctx ctx = {
|
||||
.devp = devp,
|
||||
.found = 0
|
||||
};
|
||||
|
||||
int NESTED_FUNC_ATTR hook (grub_pci_device_t dev,
|
||||
grub_pci_id_t pciid)
|
||||
{
|
||||
if (pciid == GRUB_CS5536_PCIID)
|
||||
{
|
||||
*devp = dev;
|
||||
found = 1;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
grub_pci_iterate (grub_cs5536_find_iter, &ctx);
|
||||
|
||||
grub_pci_iterate (hook);
|
||||
|
||||
return found;
|
||||
return ctx.found;
|
||||
}
|
||||
|
||||
grub_uint64_t
|
||||
|
|
|
@ -32,7 +32,7 @@ grub_pci_make_address (grub_pci_device_t dev, int reg)
|
|||
}
|
||||
|
||||
void
|
||||
grub_pci_iterate (grub_pci_iteratefunc_t hook)
|
||||
grub_pci_iterate (grub_pci_iteratefunc_t hook, void *hook_data)
|
||||
{
|
||||
struct pci_device_iterator *iter;
|
||||
struct pci_slot_match slot;
|
||||
|
@ -43,7 +43,7 @@ grub_pci_iterate (grub_pci_iteratefunc_t hook)
|
|||
slot.func = PCI_MATCH_ANY;
|
||||
iter = pci_slot_match_iterator_create (&slot);
|
||||
while ((dev = pci_device_next (iter)))
|
||||
hook (dev, dev->vendor_id | (dev->device_id << 16));
|
||||
hook (dev, dev->vendor_id | (dev->device_id << 16), hook_data);
|
||||
pci_iterator_destroy (iter);
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ grub_pci_make_address (grub_pci_device_t dev, int reg)
|
|||
}
|
||||
|
||||
void
|
||||
grub_pci_iterate (grub_pci_iteratefunc_t hook)
|
||||
grub_pci_iterate (grub_pci_iteratefunc_t hook, void *hook_data)
|
||||
{
|
||||
grub_pci_device_t dev;
|
||||
grub_pci_address_t addr;
|
||||
|
@ -125,7 +125,7 @@ grub_pci_iterate (grub_pci_iteratefunc_t hook)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (hook (dev, id))
|
||||
if (hook (dev, id, hook_data))
|
||||
return;
|
||||
|
||||
/* Probe only func = 0 if the device if not multifunction */
|
||||
|
|
|
@ -454,8 +454,9 @@ grub_ehci_reset (struct grub_ehci *e)
|
|||
}
|
||||
|
||||
/* PCI iteration function... */
|
||||
static int NESTED_FUNC_ATTR
|
||||
grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid)
|
||||
static int
|
||||
grub_ehci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
|
||||
void *data __attribute__ ((unused)))
|
||||
{
|
||||
grub_uint8_t release;
|
||||
grub_uint32_t class_code;
|
||||
|
@ -1814,7 +1815,7 @@ grub_ehci_detect_dev (grub_usb_controller_t dev, int port, int *changed)
|
|||
static void
|
||||
grub_ehci_inithw (void)
|
||||
{
|
||||
grub_pci_iterate (grub_ehci_pci_iter);
|
||||
grub_pci_iterate (grub_ehci_pci_iter, NULL);
|
||||
}
|
||||
|
||||
static grub_err_t
|
||||
|
|
|
@ -213,9 +213,9 @@ grub_ohci_writereg32 (struct grub_ohci *o,
|
|||
|
||||
/* Iterate over all PCI devices. Determine if a device is an OHCI
|
||||
controller. If this is the case, initialize it. */
|
||||
static int NESTED_FUNC_ATTR
|
||||
grub_ohci_pci_iter (grub_pci_device_t dev,
|
||||
grub_pci_id_t pciid)
|
||||
static int
|
||||
grub_ohci_pci_iter (grub_pci_device_t dev, grub_pci_id_t pciid,
|
||||
void *data __attribute__ ((unused)))
|
||||
{
|
||||
grub_uint32_t interf;
|
||||
grub_uint32_t base;
|
||||
|
@ -477,7 +477,7 @@ grub_ohci_pci_iter (grub_pci_device_t dev,
|
|||
static void
|
||||
grub_ohci_inithw (void)
|
||||
{
|
||||
grub_pci_iterate (grub_ohci_pci_iter);
|
||||
grub_pci_iterate (grub_ohci_pci_iter, NULL);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -185,9 +185,10 @@ grub_uhci_portstatus (grub_usb_controller_t dev,
|
|||
|
||||
/* Iterate over all PCI devices. Determine if a device is an UHCI
|
||||
controller. If this is the case, initialize it. */
|
||||
static int NESTED_FUNC_ATTR
|
||||
static int
|
||||
grub_uhci_pci_iter (grub_pci_device_t dev,
|
||||
grub_pci_id_t pciid __attribute__((unused)))
|
||||
grub_pci_id_t pciid __attribute__((unused)),
|
||||
void *data __attribute__ ((unused)))
|
||||
{
|
||||
grub_uint32_t class_code;
|
||||
grub_uint32_t class;
|
||||
|
@ -351,7 +352,7 @@ grub_uhci_pci_iter (grub_pci_device_t dev,
|
|||
static void
|
||||
grub_uhci_inithw (void)
|
||||
{
|
||||
grub_pci_iterate (grub_uhci_pci_iter);
|
||||
grub_pci_iterate (grub_uhci_pci_iter, NULL);
|
||||
}
|
||||
|
||||
static grub_uhci_td_t
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue