summaryrefslogtreecommitdiff
path: root/drivers/firmware/efi
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2022-12-09 01:12:16 +0300
committerArd Biesheuvel <ardb@kernel.org>2023-01-10 17:16:12 +0300
commitb7a1cd243839cc1459fbc83a7a62e3b57f29f497 (patch)
treef1114c7efab8ecb3c46272eef5affc84bf85dd72 /drivers/firmware/efi
parent1b929c02afd37871d5afb9d498426f83432e71c2 (diff)
downloadlinux-b7a1cd243839cc1459fbc83a7a62e3b57f29f497.tar.xz
efi/earlycon: Replace open coded strnchrnul()
strnchrnul() can be called in the early stages. Replace open coded variant in the EFI early console driver. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'drivers/firmware/efi')
-rw-r--r--drivers/firmware/efi/earlycon.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/drivers/firmware/efi/earlycon.c b/drivers/firmware/efi/earlycon.c
index 4d6c5327471a..be7c83b6cd10 100644
--- a/drivers/firmware/efi/earlycon.c
+++ b/drivers/firmware/efi/earlycon.c
@@ -10,6 +10,7 @@
#include <linux/kernel.h>
#include <linux/serial_core.h>
#include <linux/screen_info.h>
+#include <linux/string.h>
#include <asm/early_ioremap.h>
@@ -143,16 +144,10 @@ efi_earlycon_write(struct console *con, const char *str, unsigned int num)
len = si->lfb_linelength;
while (num) {
- unsigned int linemax;
- unsigned int h, count = 0;
+ unsigned int linemax = (si->lfb_width - efi_x) / font->width;
+ unsigned int h, count;
- for (s = str; *s && *s != '\n'; s++) {
- if (count == num)
- break;
- count++;
- }
-
- linemax = (si->lfb_width - efi_x) / font->width;
+ count = strnchrnul(str, num, '\n') - str;
if (count > linemax)
count = linemax;