diff mbox series

[v1,1/2] efi/earlycon: Replace open coded strnchrnul()

Message ID 20221208221217.56354-1-andriy.shevchenko@linux.intel.com
State Accepted
Commit b7a1cd243839cc1459fbc83a7a62e3b57f29f497
Headers show
Series [v1,1/2] efi/earlycon: Replace open coded strnchrnul() | expand

Commit Message

Andy Shevchenko Dec. 8, 2022, 10:12 p.m. UTC
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(-)

Comments

Andy Shevchenko Jan. 10, 2023, 1:58 p.m. UTC | #1
On Fri, Dec 09, 2022 at 12:12:16AM +0200, Andy Shevchenko wrote:
> strnchrnul() can be called in the early stages. Replace
> open coded variant in the EFI early console driver.

Any comments on the series?
Ard Biesheuvel Jan. 10, 2023, 2:15 p.m. UTC | #2
On Tue, 10 Jan 2023 at 14:58, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Fri, Dec 09, 2022 at 12:12:16AM +0200, Andy Shevchenko wrote:
> > strnchrnul() can be called in the early stages. Replace
> > open coded variant in the EFI early console driver.
>
> Any comments on the series?
>

Looks fine to me. Queued up in efi/next now.
Andy Shevchenko Jan. 10, 2023, 2:56 p.m. UTC | #3
On Tue, Jan 10, 2023 at 03:15:28PM +0100, Ard Biesheuvel wrote:
> On Tue, 10 Jan 2023 at 14:58, Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > On Fri, Dec 09, 2022 at 12:12:16AM +0200, Andy Shevchenko wrote:
> > > strnchrnul() can be called in the early stages. Replace
> > > open coded variant in the EFI early console driver.
> >
> > Any comments on the series?
> 
> Looks fine to me. Queued up in efi/next now.

Thank you and HNY!
diff mbox series

Patch

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;