efi/libstub: Drop protocol argument from efi_call_proto() macro
authorArd Biesheuvel <ardb@kernel.org>
Tue, 24 Dec 2019 15:10:21 +0000 (16:10 +0100)
committerIngo Molnar <mingo@kernel.org>
Wed, 25 Dec 2019 09:49:24 +0000 (10:49 +0100)
After refactoring the mixed mode support code, efi_call_proto()
no longer uses its protocol argument in any of its implementation,
so let's remove it altogether.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Cc: Arvind Sankar <nivedita@alum.mit.edu>
Cc: Borislav Petkov <bp@alien8.de>
Cc: James Morse <james.morse@arm.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: https://lkml.kernel.org/r/20191224151025.32482-22-ardb@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/arm/include/asm/efi.h
arch/arm64/include/asm/efi.h
arch/x86/boot/compressed/eboot.c
arch/x86/include/asm/efi.h
drivers/firmware/efi/libstub/efi-stub-helper.c
drivers/firmware/efi/libstub/random.c
drivers/firmware/efi/libstub/tpm.c

index 58e5acc424a07858feef8fa04c95160710111b4c..bdc5288cc643fd028e2d532e307d7b8cf3880c3f 100644 (file)
@@ -57,8 +57,7 @@ void efi_virtmap_unload(void);
 #define efi_table_attr(table, attr, instance)                          \
        instance->attr
 
-#define efi_call_proto(protocol, f, instance, ...)                     \
-       instance->f(instance, ##__VA_ARGS__)
+#define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
 
 struct screen_info *alloc_screen_info(void);
 void free_screen_info(struct screen_info *si);
index d73693177f312ef505d94f599eb1ac5104c68b13..4bc1e89671abb2b6e3b5d8c5c2aed1d7ac0b419e 100644 (file)
@@ -100,8 +100,7 @@ static inline unsigned long efi_get_max_initrd_addr(unsigned long dram_base,
 #define efi_table_attr(table, attr, instance)                          \
        instance->attr
 
-#define efi_call_proto(protocol, f, instance, ...)                     \
-       instance->f(instance, ##__VA_ARGS__)
+#define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
 
 #define alloc_screen_info(x...)                &screen_info
 
index ec92c4decc86817d0e2c6b778cfa95b35bd56618..751fd5fc3367b58821e44997e1c82dc49f4cb8a4 100644 (file)
@@ -69,27 +69,24 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom)
        rom->pcilen     = pci->romsize;
        *__rom = rom;
 
-       status = efi_call_proto(efi_pci_io_protocol, pci.read, pci,
-                               EfiPciIoWidthUint16, PCI_VENDOR_ID, 1,
-                               &rom->vendor);
+       status = efi_call_proto(pci, pci.read, EfiPciIoWidthUint16,
+                               PCI_VENDOR_ID, 1, &rom->vendor);
 
        if (status != EFI_SUCCESS) {
                efi_printk("Failed to read rom->vendor\n");
                goto free_struct;
        }
 
-       status = efi_call_proto(efi_pci_io_protocol, pci.read, pci,
-                               EfiPciIoWidthUint16, PCI_DEVICE_ID, 1,
-                               &rom->devid);
+       status = efi_call_proto(pci, pci.read, EfiPciIoWidthUint16,
+                               PCI_DEVICE_ID, 1, &rom->devid);
 
        if (status != EFI_SUCCESS) {
                efi_printk("Failed to read rom->devid\n");
                goto free_struct;
        }
 
-       status = efi_call_proto(efi_pci_io_protocol, get_location, pci,
-                               &rom->segment, &rom->bus, &rom->device,
-                               &rom->function);
+       status = efi_call_proto(pci, get_location, &rom->segment, &rom->bus,
+                               &rom->device, &rom->function);
 
        if (status != EFI_SUCCESS)
                goto free_struct;
@@ -191,7 +188,7 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params)
                return;
        }
 
-       efi_call_proto(apple_properties_protocol, get_all, p, NULL, &size);
+       efi_call_proto(p, get_all, NULL, &size);
        if (!size)
                return;
 
@@ -204,8 +201,7 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params)
                        return;
                }
 
-               status = efi_call_proto(apple_properties_protocol, get_all, p,
-                                       new->data, &size);
+               status = efi_call_proto(p, get_all, new->data, &size);
 
                if (status == EFI_BUFFER_TOO_SMALL)
                        efi_call_early(free_pool, new);
@@ -280,8 +276,7 @@ setup_uga(struct screen_info *si, efi_guid_t *uga_proto, unsigned long size)
                pciio = NULL;
                efi_call_early(handle_protocol, handle, &pciio_proto, &pciio);
 
-               status = efi_call_proto(efi_uga_draw_protocol, get_mode, uga,
-                                       &w, &h, &depth, &refresh);
+               status = efi_call_proto(uga, get_mode, &w, &h, &depth, &refresh);
                if (status == EFI_SUCCESS && (!first_uga || pciio)) {
                        width = w;
                        height = h;
index 1817f350618e7049f286a982f0e146a6cc2ca382..b7cd14e3a6349a8031b3642c05684141dbcca306 100644 (file)
@@ -227,10 +227,10 @@ static inline bool efi_is_native(void)
        __ret;                                                          \
 })
 
-#define efi_call_proto(protocol, f, instance, ...)                     \
+#define efi_call_proto(inst, func, ...)                                        \
        (efi_is_native()                                                \
-               ? instance->f(instance, ##__VA_ARGS__)                  \
-               : efi64_thunk(instance->mixed_mode.f, instance, ##__VA_ARGS__))
+               ? inst->func(inst, ##__VA_ARGS__)                       \
+               : efi64_thunk(inst->mixed_mode.func, inst, ##__VA_ARGS__))
 
 #define efi_call_early(f, ...)                                         \
        (efi_is_native()                                                \
index b715ac6a0c94b4be60f13ec76de701acdba4c1f9..48eab7b9d0666d1aaf6f5f574a54d13f08c6729d 100644 (file)
@@ -953,9 +953,7 @@ void *get_efi_config_table(efi_guid_t guid)
 
 void efi_char16_printk(efi_char16_t *str)
 {
-       efi_call_proto(efi_simple_text_output_protocol,
-                      output_string,
-                      efi_table_attr(efi_system_table, con_out,
+       efi_call_proto(efi_table_attr(efi_system_table, con_out,
                                      efi_system_table()),
-                      str);
+                      output_string, str);
 }
index 9b30d953d13bd55818e8b197044090cd5740cfc2..fbd5b5724b1976040ebbe27914a81a96258a4a03 100644 (file)
@@ -37,7 +37,7 @@ efi_status_t efi_get_random_bytes(unsigned long size, u8 *out)
        if (status != EFI_SUCCESS)
                return status;
 
-       return efi_call_proto(efi_rng_protocol, get_rng, rng, NULL, size, out);
+       return efi_call_proto(rng, get_rng, NULL, size, out);
 }
 
 /*
@@ -173,7 +173,7 @@ efi_status_t efi_random_get_seed(void)
        if (status != EFI_SUCCESS)
                return status;
 
-       status = efi_call_proto(efi_rng_protocol, get_rng, rng, &rng_algo_raw,
+       status = efi_call_proto(rng, get_rng, &rng_algo_raw,
                                 EFI_RANDOM_SEED_SIZE, seed->bits);
 
        if (status == EFI_UNSUPPORTED)
@@ -181,8 +181,8 @@ efi_status_t efi_random_get_seed(void)
                 * Use whatever algorithm we have available if the raw algorithm
                 * is not implemented.
                 */
-               status = efi_call_proto(efi_rng_protocol, get_rng, rng, NULL,
-                                        EFI_RANDOM_SEED_SIZE, seed->bits);
+               status = efi_call_proto(rng, get_rng, NULL,
+                                       EFI_RANDOM_SEED_SIZE, seed->bits);
 
        if (status != EFI_SUCCESS)
                goto err_freepool;
index f6fa1c9de77cbb67758b8c136ddd22f02dc3d5af..4a0017a181bf8d983a8c96b666be34902bc6d6ac 100644 (file)
@@ -77,15 +77,14 @@ void efi_retrieve_tpm2_eventlog(void)
        if (status != EFI_SUCCESS)
                return;
 
-       status = efi_call_proto(efi_tcg2_protocol, get_event_log,
-                               tcg2_protocol, version, &log_location,
-                               &log_last_entry, &truncated);
+       status = efi_call_proto(tcg2_protocol, get_event_log, version,
+                               &log_location, &log_last_entry, &truncated);
 
        if (status != EFI_SUCCESS || !log_location) {
                version = EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2;
-               status = efi_call_proto(efi_tcg2_protocol, get_event_log,
-                                       tcg2_protocol, version, &log_location,
-                                       &log_last_entry, &truncated);
+               status = efi_call_proto(tcg2_protocol, get_event_log, version,
+                                       &log_location, &log_last_entry,
+                                       &truncated);
                if (status != EFI_SUCCESS || !log_location)
                        return;