2022-11-24 10:19:00

by Ricardo Ribalda

[permalink] [raw]
Subject: [PATCH v2 0/2] earlycon: Let users set the clock frequency

Some platforms, namely AMD Picasso, use non standard uart clocks (48M),
witch makes it impossible to use with earlycon.

Let the user select its own frequency.

To: Jonathan Corbet <[email protected]>
To: Greg Kroah-Hartman <[email protected]>
To: Jiri Slaby <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Ricardo Ribalda <[email protected]>

---
Changes in v2:
- Add a patch to fix handling of baudrate
- Use kstrtouint instead of simple_strtoul
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Ricardo Ribalda (2):
earlycon: Replace simple_strtoul with kstrtouint
earlycon: Let users set the clock frequency

Documentation/admin-guide/kernel-parameters.txt | 12 +++++++-----
drivers/tty/serial/earlycon.c | 17 ++++++++++++++---
2 files changed, 21 insertions(+), 8 deletions(-)
---
base-commit: 4312098baf37ee17a8350725e6e0d0e8590252d4
change-id: 20221123-serial-clk-85db701ada57

Best regards,
--
Ricardo Ribalda <[email protected]>


2022-11-24 10:30:18

by Ricardo Ribalda

[permalink] [raw]
Subject: [PATCH v2 1/2] earlycon: Replace simple_strtoul with kstrtouint

Baud rate is declared as unsigned integer. Use the right function.

Signed-off-by: Ricardo Ribalda <[email protected]>

diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index a5f380584cda..5b73da9487b1 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -120,7 +120,9 @@ static int __init parse_options(struct earlycon_device *device, char *options)
}

if (options) {
- device->baud = simple_strtoul(options, NULL, 0);
+ if (kstrtouint(options, 0, &device->baud) < 0)
+ pr_warn("[%s] unsupported earlycon baud rate option\n",
+ options);
length = min(strcspn(options, " ") + 1,
(size_t)(sizeof(device->options)));
strscpy(device->options, options, length);
@@ -303,7 +305,9 @@ int __init of_setup_earlycon(const struct earlycon_id *match,
port->uartclk = be32_to_cpu(*val);

if (options) {
- early_console_dev.baud = simple_strtoul(options, NULL, 0);
+ if (kstrtouint(options, 0, &early_console_dev.baud) < 0)
+ pr_warn("[%s] unsupported earlycon baud rate options\n",
+ options);
strscpy(early_console_dev.options, options,
sizeof(early_console_dev.options));
}

--
b4 0.11.0-dev-d93f8