[PATCH v2 5/6] serial: vt8500: Use devm_clk_get_enabled()
From: Alexey Charkov
Date: Thu Nov 12 2026 - 11:34:14 EST
Let devres own the UART clock, so that no probe error path, present or
future, has to remember to disable and put it.
Pass the clock lookup error up through dev_err_probe() instead of
replacing it with -EINVAL, so that a clock provider that is not ready
yet defers the probe rather than failing it for good.
Signed-off-by: Alexey Charkov <alchark@xxxxxxxxx>
---
drivers/tty/serial/vt8500_serial.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c
index 0c8ddd55f94d..cd5188282f64 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -586,7 +586,6 @@ static int vt8500_serial_probe(struct platform_device *pdev)
struct resource *mmres;
struct device_node *np = pdev->dev.of_node;
const unsigned int *flags;
- int ret;
int port;
int irq;
@@ -606,18 +605,10 @@ static int vt8500_serial_probe(struct platform_device *pdev)
if (IS_ERR(vt8500_port->uart.membase))
return PTR_ERR(vt8500_port->uart.membase);
- vt8500_port->clk = of_clk_get(pdev->dev.of_node, 0);
- if (IS_ERR(vt8500_port->clk)) {
- dev_err(&pdev->dev, "failed to get clock\n");
- return -EINVAL;
- }
-
- ret = clk_prepare_enable(vt8500_port->clk);
- if (ret) {
- dev_err(&pdev->dev, "failed to enable clock\n");
- clk_put(vt8500_port->clk);
- return ret;
- }
+ vt8500_port->clk = devm_clk_get_enabled(&pdev->dev, NULL);
+ if (IS_ERR(vt8500_port->clk))
+ return dev_err_probe(&pdev->dev, PTR_ERR(vt8500_port->clk),
+ "failed to get and enable clock\n");
vt8500_port->vt8500_uart_flags = *flags;
vt8500_port->clk_predivisor = DIV_ROUND_CLOSEST(
--
2.56.0