[PATCH v1 2/3] serial: tegra-tcu: Make use of dev_err_probe() in .probe()
From: Uwe Kleine-König
Date: Wed Aug 12 2026 - 11:26:53 EST
Usage of dev_err_probe() is (sometimes) a bit more compact than
dev_err(), it properly handles ENOMEM and EPROBE_DEFER and emits the
error code symbolically.
Also introduce a variable to hold &pdev->dev to reduce line length a
bit.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxx>
---
drivers/tty/serial/tegra-tcu.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/drivers/tty/serial/tegra-tcu.c b/drivers/tty/serial/tegra-tcu.c
index 7033dbfe8ba1..077023ce1842 100644
--- a/drivers/tty/serial/tegra-tcu.c
+++ b/drivers/tty/serial/tegra-tcu.c
@@ -179,9 +179,10 @@ static int tegra_tcu_probe(struct platform_device *pdev)
{
struct uart_port *port;
struct tegra_tcu *tcu;
+ struct device *dev = &pdev->dev;
int err;
- tcu = devm_kzalloc(&pdev->dev, sizeof(*tcu), GFP_KERNEL);
+ tcu = devm_kzalloc(dev, sizeof(*tcu), GFP_KERNEL);
if (!tcu)
return -ENOMEM;
@@ -190,11 +191,9 @@ static int tegra_tcu_probe(struct platform_device *pdev)
tcu->rx_client.rx_callback = tegra_tcu_receive;
tcu->tx = mbox_request_channel_byname(&tcu->tx_client, "tx");
- if (IS_ERR(tcu->tx)) {
- err = PTR_ERR(tcu->tx);
- dev_err(&pdev->dev, "failed to get tx mailbox: %d\n", err);
- return err;
- }
+ if (IS_ERR(tcu->tx))
+ return dev_err_probe(dev, PTR_ERR(tcu->tx),
+ "failed to get tx mailbox\n");
#if IS_ENABLED(CONFIG_SERIAL_TEGRA_TCU_CONSOLE)
/* setup the console */
@@ -218,15 +217,14 @@ static int tegra_tcu_probe(struct platform_device *pdev)
err = uart_register_driver(&tcu->driver);
if (err) {
- dev_err(&pdev->dev, "failed to register UART driver: %d\n",
- err);
+ dev_err_probe(dev, err, "failed to register UART driver\n");
goto free_tx;
}
/* setup the port */
port = &tcu->port;
spin_lock_init(&port->lock);
- port->dev = &pdev->dev;
+ port->dev = dev;
port->type = PORT_TEGRA_TCU;
port->ops = &tegra_tcu_uart_ops;
port->fifosize = 1;
@@ -236,7 +234,7 @@ static int tegra_tcu_probe(struct platform_device *pdev)
err = uart_add_one_port(&tcu->driver, port);
if (err) {
- dev_err(&pdev->dev, "failed to add UART port: %d\n", err);
+ dev_err_probe(dev, err, "failed to add UART port\n");
goto unregister_uart;
}
@@ -246,8 +244,8 @@ static int tegra_tcu_probe(struct platform_device *pdev)
*/
tcu->rx = mbox_request_channel_byname(&tcu->rx_client, "rx");
if (IS_ERR(tcu->rx)) {
- err = PTR_ERR(tcu->rx);
- dev_err(&pdev->dev, "failed to get rx mailbox: %d\n", err);
+ err = dev_err_probe(dev, PTR_ERR(tcu->rx),
+ "failed to get rx mailbox\n");
goto remove_uart_port;
}
--
2.47.3