public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: linux-efi@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>
Cc: Ard Biesheuvel <ardb@kernel.org>,
	linux-kernel@vger.kernel.org,
	Arvind Sankar <nivedita@alum.mit.edu>
Subject: [PATCH 22/25] efi/libstub: drop 'table' argument from efi_table_attr() macro
Date: Tue, 24 Dec 2019 16:10:22 +0100	[thread overview]
Message-ID: <20191224151025.32482-23-ardb@kernel.org> (raw)
In-Reply-To: <20191224151025.32482-1-ardb@kernel.org>

None of the definitions of the efi_table_attr() still refer to
their 'table' argument so let's get rid of it entirely.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/arm/include/asm/efi.h                    |  3 +--
 arch/arm64/include/asm/efi.h                  |  3 +--
 arch/x86/boot/compressed/eboot.c              |  8 +++---
 arch/x86/include/asm/efi.h                    | 25 +++++++------------
 .../firmware/efi/libstub/efi-stub-helper.c    | 11 +++-----
 drivers/firmware/efi/libstub/gop.c            |  9 +++----
 6 files changed, 22 insertions(+), 37 deletions(-)

diff --git a/arch/arm/include/asm/efi.h b/arch/arm/include/asm/efi.h
index bdc5288cc643..bc720024a260 100644
--- a/arch/arm/include/asm/efi.h
+++ b/arch/arm/include/asm/efi.h
@@ -54,8 +54,7 @@ void efi_virtmap_unload(void);
 #define efi_call_runtime(f, ...)	efi_system_table()->runtime->f(__VA_ARGS__)
 #define efi_is_native()			(true)
 
-#define efi_table_attr(table, attr, instance)				\
-	instance->attr
+#define efi_table_attr(inst, attr)	(inst->attr)
 
 #define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
 
diff --git a/arch/arm64/include/asm/efi.h b/arch/arm64/include/asm/efi.h
index 4bc1e89671ab..6f041ae446d2 100644
--- a/arch/arm64/include/asm/efi.h
+++ b/arch/arm64/include/asm/efi.h
@@ -97,8 +97,7 @@ static inline unsigned long efi_get_max_initrd_addr(unsigned long dram_base,
 #define efi_call_runtime(f, ...)	efi_system_table()->runtime->f(__VA_ARGS__)
 #define efi_is_native()			(true)
 
-#define efi_table_attr(table, attr, instance)				\
-	instance->attr
+#define efi_table_attr(inst, attr)	(inst->attr)
 
 #define efi_call_proto(inst, func, ...) inst->func(inst, ##__VA_ARGS__)
 
diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
index 751fd5fc3367..cccd9e16b329 100644
--- a/arch/x86/boot/compressed/eboot.c
+++ b/arch/x86/boot/compressed/eboot.c
@@ -47,8 +47,8 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom)
 	 * large romsize. The UEFI spec limits the size of option ROMs to 16
 	 * MiB so we reject any ROMs over 16 MiB in size to catch this.
 	 */
-	romimage = efi_table_attr(efi_pci_io_protocol, romimage, pci);
-	romsize = efi_table_attr(efi_pci_io_protocol, romsize, pci);
+	romimage = efi_table_attr(pci, romimage);
+	romsize = efi_table_attr(pci, romsize);
 	if (!romimage || !romsize || romsize > SZ_16M)
 		return EFI_INVALID_PARAMETER;
 
@@ -183,7 +183,7 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params)
 	if (status != EFI_SUCCESS)
 		return;
 
-	if (efi_table_attr(apple_properties_protocol, version, p) != 0x10000) {
+	if (efi_table_attr(p, version) != 0x10000) {
 		efi_printk("Unsupported properties proto version\n");
 		return;
 	}
@@ -226,7 +226,7 @@ static const efi_char16_t apple[] = L"Apple";
 static void setup_quirks(struct boot_params *boot_params)
 {
 	efi_char16_t *fw_vendor = (efi_char16_t *)(unsigned long)
-		efi_table_attr(efi_system_table, fw_vendor, sys_table);
+		efi_table_attr(efi_system_table(), fw_vendor);
 
 	if (!memcmp(fw_vendor, apple, sizeof(apple))) {
 		if (IS_ENABLED(CONFIG_APPLE_PROPERTIES))
diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h
index b7cd14e3a634..39814a0a92f7 100644
--- a/arch/x86/include/asm/efi.h
+++ b/arch/x86/include/asm/efi.h
@@ -216,16 +216,11 @@ static inline bool efi_is_native(void)
 		__builtin_types_compatible_p(u32, __typeof__(attr)),	\
 			(unsigned long)(attr), (attr))
 
-#define efi_table_attr(table, attr, instance) ({			\
-	__typeof__(instance->attr) __ret;				\
-	if (efi_is_native()) {						\
-		__ret = instance->attr;					\
-	} else {							\
-		__ret = (__typeof__(__ret))				\
-			efi_mixed_mode_cast(instance->mixed_mode.attr);	\
-	}								\
-	__ret;								\
-})
+#define efi_table_attr(inst, attr)					\
+	(efi_is_native()						\
+		? inst->attr						\
+		: (__typeof__(inst->attr))				\
+			efi_mixed_mode_cast(inst->mixed_mode.attr))
 
 #define efi_call_proto(inst, func, ...)					\
 	(efi_is_native()						\
@@ -235,16 +230,14 @@ static inline bool efi_is_native(void)
 #define efi_call_early(f, ...)						\
 	(efi_is_native()						\
 		? efi_system_table()->boottime->f(__VA_ARGS__)		\
-		: efi64_thunk(efi_table_attr(efi_boot_services,		\
-			boottime, efi_system_table())->mixed_mode.f,	\
-			__VA_ARGS__))
+		: efi64_thunk(efi_table_attr(efi_system_table(),	\
+				boottime)->mixed_mode.f, __VA_ARGS__))
 
 #define efi_call_runtime(f, ...)					\
 	(efi_is_native()						\
 		? efi_system_table()->runtime->f(__VA_ARGS__)		\
-		: efi64_thunk(efi_table_attr(efi_runtime_services,	\
-			runtime, efi_system_table())->mixed_mode.f,	\
-			__VA_ARGS__))
+		: efi64_thunk(efi_table_attr(efi_system_table(),	\
+				runtime)->mixed_mode.f, __VA_ARGS__))
 
 extern bool efi_reboot_required(void);
 extern bool efi_is_table_address(unsigned long phys_addr);
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index 48eab7b9d066..8754ec04788b 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -933,17 +933,15 @@ efi_status_t efi_exit_boot_services(void *handle,
 
 void *get_efi_config_table(efi_guid_t guid)
 {
-	unsigned long tables = efi_table_attr(efi_system_table, tables,
-					      efi_system_table());
-	int nr_tables = efi_table_attr(efi_system_table, nr_tables,
-				       efi_system_table());
+	unsigned long tables = efi_table_attr(efi_system_table(), tables);
+	int nr_tables = efi_table_attr(efi_system_table(), nr_tables);
 	int i;
 
 	for (i = 0; i < nr_tables; i++) {
 		efi_config_table_t *t = (void *)tables;
 
 		if (efi_guidcmp(t->guid, guid) == 0)
-			return efi_table_attr(efi_config_table, table, t);
+			return efi_table_attr(t, table);
 
 		tables += efi_is_native() ? sizeof(efi_config_table_t)
 					  : sizeof(efi_config_table_32_t);
@@ -953,7 +951,6 @@ void *get_efi_config_table(efi_guid_t guid)
 
 void efi_char16_printk(efi_char16_t *str)
 {
-	efi_call_proto(efi_table_attr(efi_system_table, con_out,
-				      efi_system_table()),
+	efi_call_proto(efi_table_attr(efi_system_table(), con_out),
 		       output_string, str);
 }
diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c
index c3afe8d4a688..8f746282c219 100644
--- a/drivers/firmware/efi/libstub/gop.c
+++ b/drivers/firmware/efi/libstub/gop.c
@@ -85,9 +85,6 @@ setup_pixel_info(struct screen_info *si, u32 pixels_per_scan_line,
 	}
 }
 
-#define efi_gop_attr(table, attr, instance) \
-	(efi_table_attr(efi_graphics_output_protocol##table, attr, instance))
-
 static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto,
 			      unsigned long size, void **handles)
 {
@@ -123,9 +120,9 @@ static efi_status_t setup_gop(struct screen_info *si, efi_guid_t *proto,
 		if (status == EFI_SUCCESS)
 			conout_found = true;
 
-		mode = (void *)(unsigned long)efi_gop_attr(, mode, gop);
-		info = (void *)(unsigned long)efi_gop_attr(_mode, info, mode);
-		current_fb_base = efi_gop_attr(_mode, frame_buffer_base, mode);
+		mode = efi_table_attr(gop, mode);
+		info = efi_table_attr(mode, info);
+		current_fb_base = efi_table_attr(mode, frame_buffer_base);
 
 		if ((!first_gop || conout_found) &&
 		    info->pixel_format != PIXEL_BLT_ONLY) {
-- 
2.20.1


  parent reply	other threads:[~2019-12-24 15:11 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-24 15:10 [GIT PULL 00/25] EFI updates for v5.6 Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 01/25] efi/gop: Remove bogus packed attribute from GOP structures Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 02/25] efi/gop: Remove unused typedef Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 03/25] efi/gop: Convert GOP structures to typedef and cleanup some types Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 04/25] efi/gop: Unify 32/64-bit functions Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 05/25] efi/libstub: remove unused __efi_call_early() macro Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 06/25] efi/x86: rename efi_is_native() to efi_is_mixed() Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 07/25] efi/libstub: use a helper to iterate over a EFI handle array Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 08/25] efi/libstub: extend native protocol definitions with mixed_mode aliases Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 09/25] efi/libstub: distinguish between native/mixed not 32/64 bit Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 10/25] efi/libstub: drop explicit 32/64-bit protocol definitions Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 11/25] efi/libstub: use stricter typing for firmware function pointers Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 12/25] efi/libstub: annotate firmware routines as __efiapi Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 13/25] efi/libstub/x86: avoid thunking for native firmware calls Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 14/25] efi/libstub: avoid protocol wrapper for file I/O routines Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 15/25] efi/libstub: get rid of 'sys_table_arg' macro parameter Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 16/25] efi/libstub: unify the efi_char16_printk implementations Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 17/25] efi/libstub/x86: drop __efi_early() export and efi_config struct Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 18/25] efi/libstub: drop sys_table_arg from printk routines Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 19/25] efi/libstub: remove 'sys_table_arg' from all function prototypes Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 20/25] efi/libstub/x86: work around page freeing issue in mixed mode Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 21/25] efi/libstub: drop protocol argument from efi_call_proto() macro Ard Biesheuvel
2019-12-24 15:10 ` Ard Biesheuvel [this message]
2019-12-24 15:10 ` [PATCH 23/25] efi/libstub: rename efi_call_early/_runtime macros to be more intuitive Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 24/25] efi/libstub: tidy up types and names of global cmdline variables Ard Biesheuvel
2019-12-24 15:10 ` [PATCH 25/25] efi/libstub/x86: avoid globals to store context during mixed mode calls Ard Biesheuvel
2019-12-25  9:50 ` [GIT PULL 00/25] EFI updates for v5.6 Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191224151025.32482-23-ardb@kernel.org \
    --to=ardb@kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=nivedita@alum.mit.edu \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox