[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f1926d434cdeb091405ef8c01a90c0140d296bed.camel@perches.com>
Date: Mon, 04 May 2020 11:29:39 -0700
From: Joe Perches <joe@...ches.com>
To: Ard Biesheuvel <ardb@...nel.org>
Cc: Arvind Sankar <nivedita@...m.mit.edu>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-efi <linux-efi@...r.kernel.org>, X86 ML <x86@...nel.org>
Subject: [trivial PATCH] efi/libstub: Reduce efi_printk object size
Use a few more common kernel styles.
Trivially reduce efi_printk object size by using a dereference to
a temporary instead of multiple dereferences of the same object.
Use efi_printk(const char *str) and static or static const for its
internal variables.
Use the more common form of while instead of a for loop.
Change efi_char16_printk argument to const.
Signed-off-by: Joe Perches <joe@...ches.com>
---
drivers/firmware/efi/libstub/efi-stub-helper.c | 16 ++++++++--------
drivers/firmware/efi/libstub/efistub.h | 6 +++---
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c
index 1c92ac231f94..dfd72a4360ac 100644
--- a/drivers/firmware/efi/libstub/efi-stub-helper.c
+++ b/drivers/firmware/efi/libstub/efi-stub-helper.c
@@ -26,19 +26,19 @@ bool __pure __efi_soft_reserve_enabled(void)
return !efi_nosoftreserve;
}
-void efi_printk(char *str)
+void efi_printk(const char *str)
{
- char *s8;
+ char s8;
- for (s8 = str; *s8; s8++) {
- efi_char16_t ch[2] = { 0 };
+ while ((s8 = *str++)) {
+ static efi_char16_t ch[2] = {0, 0};
- ch[0] = *s8;
- if (*s8 == '\n') {
- efi_char16_t nl[2] = { '\r', 0 };
+ if (s8 == '\n') {
+ static const efi_char16_t nl[2] = { '\r', 0 };
efi_char16_printk(nl);
}
+ ch[0] = s8;
efi_char16_printk(ch);
}
}
@@ -284,7 +284,7 @@ void *get_efi_config_table(efi_guid_t guid)
return NULL;
}
-void efi_char16_printk(efi_char16_t *str)
+void efi_char16_printk(const efi_char16_t *str)
{
efi_call_proto(efi_table_attr(efi_system_table, con_out),
output_string, str);
diff --git a/drivers/firmware/efi/libstub/efistub.h b/drivers/firmware/efi/libstub/efistub.h
index 5ff63230a1f1..a03a92c665f0 100644
--- a/drivers/firmware/efi/libstub/efistub.h
+++ b/drivers/firmware/efi/libstub/efistub.h
@@ -251,7 +251,7 @@ union efi_simple_text_output_protocol {
struct {
void *reset;
efi_status_t (__efiapi *output_string)(efi_simple_text_output_protocol_t *,
- efi_char16_t *);
+ const efi_char16_t *);
void *test_string;
};
struct {
@@ -599,7 +599,7 @@ efi_status_t efi_exit_boot_services(void *handle,
void *priv,
efi_exit_boot_map_processing priv_func);
-void efi_char16_printk(efi_char16_t *);
+void efi_char16_printk(const efi_char16_t *str);
efi_status_t allocate_new_fdt_and_exit_boot(void *handle,
unsigned long *new_fdt_addr,
@@ -624,7 +624,7 @@ efi_status_t check_platform_features(void);
void *get_efi_config_table(efi_guid_t guid);
-void efi_printk(char *str);
+void efi_printk(const char *str);
void efi_free(unsigned long size, unsigned long addr);
Powered by blists - more mailing lists