[PATCH] serial: vt8500: Use devm_clk_get_enabled()

From: Wentao Liang

Date: Sun Nov 08 2026 - 06:41:30 EST


vt8500_serial_probe() gets the clock with of_clk_get() and enables it
with clk_prepare_enable(), so the reference has to be dropped by hand on
the error path, and the clock is never disabled or released afterwards,
even though the rest of the probe is devm-managed.

Use devm_clk_get_enabled() instead, which gets and enables the clock in
one call and registers the teardown with devm. The manual error handling
and the clk_put() can then go, and probe returns the actual error code
from the clock lookup rather than a hard-coded -EINVAL.

The clock still stays enabled as long as the port is in use, so the
success path is unchanged.
---
drivers/tty/serial/vt8500_serial.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c
index fc6fdc751b16..73922523dff6 100644
--- a/drivers/tty/serial/vt8500_serial.c
+++ b/drivers/tty/serial/vt8500_serial.c
@@ -603,7 +603,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;

@@ -647,17 +646,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);
+ vt8500_port->clk = devm_clk_get_enabled(&pdev->dev, NULL);
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;
+ return PTR_ERR(vt8500_port->clk);
}

vt8500_port->vt8500_uart_flags = *flags;
--
2.34.1