From c14bca3f7aa94fd8d3f5e621ce5b56535ef2396b Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Thu, 19 Dec 2024 10:53:23 +0100 Subject: efi/libstub: Use C99-style for loop to traverse handle buffer Tweak the for_each_efi_handle() macro in order to avoid the need on the part of the caller to provide a loop counter variable. Also move efi_get_handle_num() to the callers, so that each occurrence can be replaced with the actual number returned by the simplified LocateHandleBuffer API. Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/libstub/pci.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'drivers/firmware/efi/libstub/pci.c') diff --git a/drivers/firmware/efi/libstub/pci.c b/drivers/firmware/efi/libstub/pci.c index 99fb25d2bcf5..b0ba372c26c5 100644 --- a/drivers/firmware/efi/libstub/pci.c +++ b/drivers/firmware/efi/libstub/pci.c @@ -21,7 +21,6 @@ void efi_pci_disable_bridge_busmaster(void) efi_handle_t handle; efi_status_t status; u16 class, command; - int i; status = efi_bs_call(locate_handle, EFI_LOCATE_BY_PROTOCOL, &pci_proto, NULL, &pci_handle_size, NULL); @@ -46,7 +45,7 @@ void efi_pci_disable_bridge_busmaster(void) goto free_handle; } - for_each_efi_handle(handle, pci_handle, pci_handle_size, i) { + for_each_efi_handle(handle, pci_handle, efi_get_handle_num(pci_handle_size)) { efi_pci_io_protocol_t *pci; unsigned long segment_nr, bus_nr, device_nr, func_nr; @@ -82,7 +81,7 @@ void efi_pci_disable_bridge_busmaster(void) efi_bs_call(disconnect_controller, handle, NULL, NULL); } - for_each_efi_handle(handle, pci_handle, pci_handle_size, i) { + for_each_efi_handle(handle, pci_handle, efi_get_handle_num(pci_handle_size)) { efi_pci_io_protocol_t *pci; status = efi_bs_call(handle_protocol, handle, &pci_proto, -- cgit