[PATCH v1 3/3] serial: tegra-tcu: Make use of devm_mbox_request_channel_byname()

Uwe Kleine-König <[email protected]>
Newsgroups gmane.linux.serial,gmane.linux.kernel,gmane.linux.ports.tegra
Message-ID <f641b6d092d1ed92e27f521e9028b5d1da3f63b4.1786547950.git.u.kleine-koenig@baylibre.com>
Simplify tegra_tcu_probe() a bit by using the devm managed variant of
mbox_request_channel_byname(). For the rx channel the function cannot be
used without confusing the order of resource freeing.

Signed-off-by: Uwe Kleine-König <[email protected]>
---
 drivers/tty/serial/tegra-tcu.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/tty/serial/tegra-tcu.c b/drivers/tty/serial/tegra-tcu.c
index 077023ce1842..a3596ec24d34 100644
--- a/drivers/tty/serial/tegra-tcu.c
+++ b/drivers/tty/serial/tegra-tcu.c
@@ -190,7 +190,7 @@ static int tegra_tcu_probe(struct platform_device *pdev)
 	tcu->rx_client.dev = &pdev->dev;
 	tcu->rx_client.rx_callback = tegra_tcu_receive;
 
-	tcu->tx = mbox_request_channel_byname(&tcu->tx_client, "tx");
+	tcu->tx = devm_mbox_request_channel_byname(dev, &tcu->tx_client, "tx");
 	if (IS_ERR(tcu->tx))
 		return dev_err_probe(dev, PTR_ERR(tcu->tx),
 				     "failed to get tx mailbox\n");
@@ -216,10 +216,9 @@ static int tegra_tcu_probe(struct platform_device *pdev)
 	tcu->driver.nr = 1;
 
 	err = uart_register_driver(&tcu->driver);
-	if (err) {
-		dev_err_probe(dev, err, "failed to register UART driver\n");
-		goto free_tx;
-	}
+	if (err)
+		return dev_err_probe(dev, err,
+				     "failed to register UART driver\n");
 
 	/* setup the port */
 	port = &tcu->port;
@@ -260,8 +259,6 @@ static int tegra_tcu_probe(struct platform_device *pdev)
 	uart_remove_one_port(&tcu->driver, &tcu->port);
 unregister_uart:
 	uart_unregister_driver(&tcu->driver);
-free_tx:
-	mbox_free_channel(tcu->tx);
 
 	return err;
 }
@@ -276,7 +273,6 @@ static void tegra_tcu_remove(struct platform_device *pdev)
 	mbox_free_channel(tcu->rx);
 	uart_remove_one_port(&tcu->driver, &tcu->port);
 	uart_unregister_driver(&tcu->driver);
-	mbox_free_channel(tcu->tx);
 }
 
 static const struct of_device_id tegra_tcu_match[] = {
-- 
2.47.3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.