public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/2] efi/earlycon: Replace open coded strnchrnul()
@ 2022-12-08 22:12 Andy Shevchenko
  2022-12-08 22:12 ` [PATCH v1 2/2] efi/earlycon: Speed up scrolling by skiping moving empty space Andy Shevchenko
  2023-01-10 13:58 ` [PATCH v1 1/2] efi/earlycon: Replace open coded strnchrnul() Andy Shevchenko
  0 siblings, 2 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-12-08 22:12 UTC (permalink / raw)
  To: Andy Shevchenko, linux-efi, linux-kernel
  Cc: Ard Biesheuvel, Hans de Goede, platform-driver-x86

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>
---
 drivers/firmware/efi/earlycon.c | 13 ++++---------
 1 file 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;
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-10 14:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-08 22:12 [PATCH v1 1/2] efi/earlycon: Replace open coded strnchrnul() Andy Shevchenko
2022-12-08 22:12 ` [PATCH v1 2/2] efi/earlycon: Speed up scrolling by skiping moving empty space Andy Shevchenko
2023-01-10 13:58 ` [PATCH v1 1/2] efi/earlycon: Replace open coded strnchrnul() Andy Shevchenko
2023-01-10 14:15   ` Ard Biesheuvel
2023-01-10 14:56     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox