* [PATCH 0/8] tty serial drivers use devm_clk_get_enabled() helpers
@ 2024-08-22 3:39 Lei Liu
2024-08-22 3:39 ` [PATCH 1/8] tty: 8250_ingenic: Use " Lei Liu
` (7 more replies)
0 siblings, 8 replies; 20+ messages in thread
From: Lei Liu @ 2024-08-22 3:39 UTC (permalink / raw)
To: Paul Cercueil, Greg Kroah-Hartman, Jiri Slaby, Thierry Reding,
Jonathan Hunter, Kunihiko Hayashi, Masami Hiramatsu,
Richard Genoud, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi, Andreas Färber,
Manivannan Sadhasivam, Patrice Chotard, Maxime Coquelin,
Alexandre Torgue, Andi Shyti, Andy Shevchenko,
AngeloGioacchino Del Regno, Uwe Kleine-König, Lei Liu,
John Ogness, Thomas Gleixner, Jeff Johnson,
Sebastian Andrzej Siewior, Valentin Caron, Lino Sanfilippo,
Erwan Le Ray, linux-mips, linux-kernel, linux-serial, linux-tegra,
linux-arm-kernel, linux-actions, linux-stm32
Cc: opensource.kernel
The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code and avoids calls to clk_disable_unprepare().
Lei Liu (8):
tty: 8250_ingenic: Use devm_clk_get_enabled() helpers
tty: 8250_tegra: Use devm_clk_get_enabled() helpers
tty: 8250_uniphier: Use devm_clk_get_enabled() helpers
tty: atmel_serial: Use devm_clk_get_enabled() helpers
tty: mps2-uart: Use devm_clk_get_enabled() helpers
tty: owl-uart: Use devm_clk_get_enabled() helpers
tty: st-asc: Use devm_clk_get_enabled() helpers
tty: stm32-usart: Use devm_clk_get_enabled() helpers
drivers/tty/serial/8250/8250_ingenic.c | 26 +++----------------------
drivers/tty/serial/8250/8250_tegra.c | 8 +-------
drivers/tty/serial/8250/8250_uniphier.c | 8 +-------
drivers/tty/serial/atmel_serial.c | 8 +-------
drivers/tty/serial/mps2-uart.c | 9 +--------
drivers/tty/serial/owl-uart.c | 10 +---------
drivers/tty/serial/st-asc.c | 8 ++------
drivers/tty/serial/stm32-usart.c | 16 +--------------
8 files changed, 11 insertions(+), 82 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 1/8] tty: 8250_ingenic: Use devm_clk_get_enabled() helpers
2024-08-22 3:39 [PATCH 0/8] tty serial drivers use devm_clk_get_enabled() helpers Lei Liu
@ 2024-08-22 3:39 ` Lei Liu
2024-08-22 9:40 ` Paul Cercueil
2024-08-22 13:09 ` Andy Shevchenko
2024-08-22 3:39 ` [PATCH 2/8] tty: 8250_tegra: " Lei Liu
` (6 subsequent siblings)
7 siblings, 2 replies; 20+ messages in thread
From: Lei Liu @ 2024-08-22 3:39 UTC (permalink / raw)
To: Paul Cercueil, Greg Kroah-Hartman, Jiri Slaby, Thierry Reding,
Jonathan Hunter, Kunihiko Hayashi, Masami Hiramatsu,
Richard Genoud, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi, Andreas Färber,
Manivannan Sadhasivam, Patrice Chotard, Maxime Coquelin,
Alexandre Torgue, Geert Uytterhoeven, Andy Shevchenko,
Florian Fainelli, Lei Liu, Uwe Kleine-König, Thomas Gleixner,
John Ogness, Jeff Johnson, Sebastian Andrzej Siewior,
Valentin Caron, Lino Sanfilippo, linux-mips, linux-kernel,
linux-serial, linux-tegra, linux-arm-kernel, linux-actions,
linux-stm32
Cc: opensource.kernel
The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code and avoids calls to clk_disable_unprepare().
Signed-off-by: Lei Liu <liulei.rjpt@vivo.com>
---
drivers/tty/serial/8250/8250_ingenic.c | 26 +++-----------------------
1 file changed, 3 insertions(+), 23 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_ingenic.c b/drivers/tty/serial/8250/8250_ingenic.c
index a2783e38a2e3..5f8787309064 100644
--- a/drivers/tty/serial/8250/8250_ingenic.c
+++ b/drivers/tty/serial/8250/8250_ingenic.c
@@ -274,44 +274,26 @@ static int ingenic_uart_probe(struct platform_device *pdev)
if (!uart.port.membase)
return -ENOMEM;
- data->clk_module = devm_clk_get(&pdev->dev, "module");
+ data->clk_module = devm_clk_get_enabled(&pdev->dev, "module");
if (IS_ERR(data->clk_module))
return dev_err_probe(&pdev->dev, PTR_ERR(data->clk_module),
"unable to get module clock\n");
- data->clk_baud = devm_clk_get(&pdev->dev, "baud");
+ data->clk_baud = devm_clk_get_enabled(&pdev->dev, "baud");
if (IS_ERR(data->clk_baud))
return dev_err_probe(&pdev->dev, PTR_ERR(data->clk_baud),
"unable to get baud clock\n");
- err = clk_prepare_enable(data->clk_module);
- if (err) {
- dev_err(&pdev->dev, "could not enable module clock: %d\n", err);
- goto out;
- }
-
- err = clk_prepare_enable(data->clk_baud);
- if (err) {
- dev_err(&pdev->dev, "could not enable baud clock: %d\n", err);
- goto out_disable_moduleclk;
- }
uart.port.uartclk = clk_get_rate(data->clk_baud);
data->line = serial8250_register_8250_port(&uart);
if (data->line < 0) {
err = data->line;
- goto out_disable_baudclk;
+ return err;
}
platform_set_drvdata(pdev, data);
return 0;
-
-out_disable_baudclk:
- clk_disable_unprepare(data->clk_baud);
-out_disable_moduleclk:
- clk_disable_unprepare(data->clk_module);
-out:
- return err;
}
static void ingenic_uart_remove(struct platform_device *pdev)
@@ -319,8 +301,6 @@ static void ingenic_uart_remove(struct platform_device *pdev)
struct ingenic_uart_data *data = platform_get_drvdata(pdev);
serial8250_unregister_port(data->line);
- clk_disable_unprepare(data->clk_module);
- clk_disable_unprepare(data->clk_baud);
}
static const struct ingenic_uart_config jz4740_uart_config = {
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 2/8] tty: 8250_tegra: Use devm_clk_get_enabled() helpers
2024-08-22 3:39 [PATCH 0/8] tty serial drivers use devm_clk_get_enabled() helpers Lei Liu
2024-08-22 3:39 ` [PATCH 1/8] tty: 8250_ingenic: Use " Lei Liu
@ 2024-08-22 3:39 ` Lei Liu
2024-08-22 13:10 ` Andy Shevchenko
2024-08-22 3:39 ` [PATCH 3/8] tty: 8250_uniphier: " Lei Liu
` (5 subsequent siblings)
7 siblings, 1 reply; 20+ messages in thread
From: Lei Liu @ 2024-08-22 3:39 UTC (permalink / raw)
To: Paul Cercueil, Greg Kroah-Hartman, Jiri Slaby, Thierry Reding,
Jonathan Hunter, Kunihiko Hayashi, Masami Hiramatsu,
Richard Genoud, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi, Andreas Färber,
Manivannan Sadhasivam, Patrice Chotard, Maxime Coquelin,
Alexandre Torgue, AngeloGioacchino Del Regno, Florian Fainelli,
Andy Shevchenko, Uwe Kleine-König, Lei Liu, Thomas Gleixner,
John Ogness, Sebastian Andrzej Siewior, Jeff Johnson,
Valentin Caron, Lino Sanfilippo, Amelie Delaunay, linux-mips,
linux-kernel, linux-serial, linux-tegra, linux-arm-kernel,
linux-actions, linux-stm32
Cc: opensource.kernel
The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code and avoids calls to clk_disable_unprepare().
Signed-off-by: Lei Liu <liulei.rjpt@vivo.com>
---
drivers/tty/serial/8250/8250_tegra.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_tegra.c b/drivers/tty/serial/8250/8250_tegra.c
index 60a80d00d251..a38a4eb3235b 100644
--- a/drivers/tty/serial/8250/8250_tegra.c
+++ b/drivers/tty/serial/8250/8250_tegra.c
@@ -86,16 +86,12 @@ static int tegra_uart_probe(struct platform_device *pdev)
return PTR_ERR(uart->rst);
if (!port->uartclk) {
- uart->clk = devm_clk_get(&pdev->dev, NULL);
+ uart->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(uart->clk)) {
dev_err(&pdev->dev, "failed to get clock!\n");
return -ENODEV;
}
- ret = clk_prepare_enable(uart->clk);
- if (ret < 0)
- return ret;
-
port->uartclk = clk_get_rate(uart->clk);
}
@@ -115,7 +111,6 @@ static int tegra_uart_probe(struct platform_device *pdev)
err_ctrl_assert:
reset_control_assert(uart->rst);
err_clkdisable:
- clk_disable_unprepare(uart->clk);
return ret;
}
@@ -126,7 +121,6 @@ static void tegra_uart_remove(struct platform_device *pdev)
serial8250_unregister_port(uart->line);
reset_control_assert(uart->rst);
- clk_disable_unprepare(uart->clk);
}
#ifdef CONFIG_PM_SLEEP
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 3/8] tty: 8250_uniphier: Use devm_clk_get_enabled() helpers
2024-08-22 3:39 [PATCH 0/8] tty serial drivers use devm_clk_get_enabled() helpers Lei Liu
2024-08-22 3:39 ` [PATCH 1/8] tty: 8250_ingenic: Use " Lei Liu
2024-08-22 3:39 ` [PATCH 2/8] tty: 8250_tegra: " Lei Liu
@ 2024-08-22 3:39 ` Lei Liu
2024-08-22 3:39 ` [PATCH 4/8] tty: atmel_serial: " Lei Liu
` (4 subsequent siblings)
7 siblings, 0 replies; 20+ messages in thread
From: Lei Liu @ 2024-08-22 3:39 UTC (permalink / raw)
To: Paul Cercueil, Greg Kroah-Hartman, Jiri Slaby, Thierry Reding,
Jonathan Hunter, Kunihiko Hayashi, Masami Hiramatsu,
Richard Genoud, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi, Andreas Färber,
Manivannan Sadhasivam, Patrice Chotard, Maxime Coquelin,
Alexandre Torgue, Uwe Kleine-König,
AngeloGioacchino Del Regno, Andi Shyti, Florian Fainelli,
Andy Shevchenko, Lei Liu, Thomas Gleixner, John Ogness,
Sebastian Andrzej Siewior, Jeff Johnson, Valentin Caron,
Lino Sanfilippo, linux-mips, linux-kernel, linux-serial,
linux-tegra, linux-arm-kernel, linux-actions, linux-stm32
Cc: opensource.kernel
The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code and avoids calls to clk_disable_unprepare().
Signed-off-by: Lei Liu <liulei.rjpt@vivo.com>
---
drivers/tty/serial/8250/8250_uniphier.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_uniphier.c b/drivers/tty/serial/8250/8250_uniphier.c
index 670d2ca0f757..6ddc4262d22b 100644
--- a/drivers/tty/serial/8250/8250_uniphier.c
+++ b/drivers/tty/serial/8250/8250_uniphier.c
@@ -180,16 +180,12 @@ static int uniphier_uart_probe(struct platform_device *pdev)
memset(&up, 0, sizeof(up));
- priv->clk = devm_clk_get(dev, NULL);
+ priv->clk = devm_clk_get_enabled(dev, NULL);
if (IS_ERR(priv->clk)) {
dev_err(dev, "failed to get clock\n");
return PTR_ERR(priv->clk);
}
- ret = clk_prepare_enable(priv->clk);
- if (ret)
- return ret;
-
up.port.uartclk = clk_get_rate(priv->clk);
spin_lock_init(&priv->atomic_write_lock);
@@ -222,7 +218,6 @@ static int uniphier_uart_probe(struct platform_device *pdev)
ret = serial8250_register_8250_port(&up);
if (ret < 0) {
dev_err(dev, "failed to register 8250 port\n");
- clk_disable_unprepare(priv->clk);
return ret;
}
priv->line = ret;
@@ -237,7 +232,6 @@ static void uniphier_uart_remove(struct platform_device *pdev)
struct uniphier8250_priv *priv = platform_get_drvdata(pdev);
serial8250_unregister_port(priv->line);
- clk_disable_unprepare(priv->clk);
}
static int __maybe_unused uniphier_uart_suspend(struct device *dev)
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 4/8] tty: atmel_serial: Use devm_clk_get_enabled() helpers
2024-08-22 3:39 [PATCH 0/8] tty serial drivers use devm_clk_get_enabled() helpers Lei Liu
` (2 preceding siblings ...)
2024-08-22 3:39 ` [PATCH 3/8] tty: 8250_uniphier: " Lei Liu
@ 2024-08-22 3:39 ` Lei Liu
2024-08-22 13:28 ` Richard GENOUD
2024-08-22 3:39 ` [PATCH 5/8] tty: mps2-uart: " Lei Liu
` (3 subsequent siblings)
7 siblings, 1 reply; 20+ messages in thread
From: Lei Liu @ 2024-08-22 3:39 UTC (permalink / raw)
To: Paul Cercueil, Greg Kroah-Hartman, Jiri Slaby, Thierry Reding,
Jonathan Hunter, Kunihiko Hayashi, Masami Hiramatsu,
Richard Genoud, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi, Andreas Färber,
Manivannan Sadhasivam, Patrice Chotard, Maxime Coquelin,
Alexandre Torgue, Andy Shevchenko, Andi Shyti, Florian Fainelli,
Lei Liu, Uwe Kleine-König, John Ogness, Thomas Gleixner,
Jeff Johnson, Sebastian Andrzej Siewior, Valentin Caron,
Lino Sanfilippo, Erwan Le Ray, linux-mips, linux-kernel,
linux-serial, linux-tegra, linux-arm-kernel, linux-actions,
linux-stm32
Cc: opensource.kernel
The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code and avoids calls to clk_disable_unprepare().
Signed-off-by: Lei Liu <liulei.rjpt@vivo.com>
---
drivers/tty/serial/atmel_serial.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 09b246c9e389..209f3d41a17c 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -2910,14 +2910,11 @@ static int atmel_serial_probe(struct platform_device *pdev)
atomic_set(&atmel_port->tasklet_shutdown, 0);
spin_lock_init(&atmel_port->lock_suspended);
- atmel_port->clk = devm_clk_get(&pdev->dev, "usart");
+ atmel_port->clk = devm_clk_get_enabled(&pdev->dev, "usart");
if (IS_ERR(atmel_port->clk)) {
ret = PTR_ERR(atmel_port->clk);
goto err;
}
- ret = clk_prepare_enable(atmel_port->clk);
- if (ret)
- goto err;
atmel_port->gclk = devm_clk_get_optional(&pdev->dev, "gclk");
if (IS_ERR(atmel_port->gclk)) {
@@ -2968,15 +2965,12 @@ static int atmel_serial_probe(struct platform_device *pdev)
* The peripheral clock can now safely be disabled till the port
* is used
*/
- clk_disable_unprepare(atmel_port->clk);
-
return 0;
err_add_port:
kfree(atmel_port->rx_ring.buf);
atmel_port->rx_ring.buf = NULL;
err_clk_disable_unprepare:
- clk_disable_unprepare(atmel_port->clk);
clear_bit(atmel_port->uart.line, atmel_ports_in_use);
err:
return ret;
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 5/8] tty: mps2-uart: Use devm_clk_get_enabled() helpers
2024-08-22 3:39 [PATCH 0/8] tty serial drivers use devm_clk_get_enabled() helpers Lei Liu
` (3 preceding siblings ...)
2024-08-22 3:39 ` [PATCH 4/8] tty: atmel_serial: " Lei Liu
@ 2024-08-22 3:39 ` Lei Liu
2024-08-22 13:19 ` Andy Shevchenko
2024-08-22 3:39 ` [PATCH 6/8] tty: owl-uart: " Lei Liu
` (2 subsequent siblings)
7 siblings, 1 reply; 20+ messages in thread
From: Lei Liu @ 2024-08-22 3:39 UTC (permalink / raw)
To: Paul Cercueil, Greg Kroah-Hartman, Jiri Slaby, Thierry Reding,
Jonathan Hunter, Kunihiko Hayashi, Masami Hiramatsu,
Richard Genoud, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi, Andreas Färber,
Manivannan Sadhasivam, Patrice Chotard, Maxime Coquelin,
Alexandre Torgue, Lei Liu, AngeloGioacchino Del Regno,
Andy Shevchenko, Geert Uytterhoeven, Uwe Kleine-König,
John Ogness, Thomas Gleixner, Sebastian Andrzej Siewior,
Jeff Johnson, Valentin Caron, Lino Sanfilippo, Amelie Delaunay,
linux-mips, linux-kernel, linux-serial, linux-tegra,
linux-arm-kernel, linux-actions, linux-stm32
Cc: opensource.kernel
The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code and avoids calls to clk_disable_unprepare().
Signed-off-by: Lei Liu <liulei.rjpt@vivo.com>
---
drivers/tty/serial/mps2-uart.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c
index 2a4c09f3a834..e582fd6c4632 100644
--- a/drivers/tty/serial/mps2-uart.c
+++ b/drivers/tty/serial/mps2-uart.c
@@ -550,19 +550,12 @@ static int mps2_init_port(struct platform_device *pdev,
mps_port->port.ops = &mps2_uart_pops;
mps_port->port.dev = &pdev->dev;
- mps_port->clk = devm_clk_get(&pdev->dev, NULL);
+ mps_port->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(mps_port->clk))
return PTR_ERR(mps_port->clk);
- ret = clk_prepare_enable(mps_port->clk);
- if (ret)
- return ret;
-
mps_port->port.uartclk = clk_get_rate(mps_port->clk);
- clk_disable_unprepare(mps_port->clk);
-
-
if (mps_port->flags & UART_PORT_COMBINED_IRQ) {
mps_port->port.irq = platform_get_irq(pdev, 0);
} else {
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 6/8] tty: owl-uart: Use devm_clk_get_enabled() helpers
2024-08-22 3:39 [PATCH 0/8] tty serial drivers use devm_clk_get_enabled() helpers Lei Liu
` (4 preceding siblings ...)
2024-08-22 3:39 ` [PATCH 5/8] tty: mps2-uart: " Lei Liu
@ 2024-08-22 3:39 ` Lei Liu
2024-08-22 3:39 ` [PATCH 7/8] tty: st-asc: " Lei Liu
2024-08-22 3:39 ` [PATCH 8/8] tty: stm32-usart: " Lei Liu
7 siblings, 0 replies; 20+ messages in thread
From: Lei Liu @ 2024-08-22 3:39 UTC (permalink / raw)
To: Paul Cercueil, Greg Kroah-Hartman, Jiri Slaby, Thierry Reding,
Jonathan Hunter, Kunihiko Hayashi, Masami Hiramatsu,
Richard Genoud, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi, Andreas Färber,
Manivannan Sadhasivam, Patrice Chotard, Maxime Coquelin,
Alexandre Torgue, Andi Shyti, Andy Shevchenko, Florian Fainelli,
Uwe Kleine-König, Lei Liu, John Ogness, Thomas Gleixner,
Jeff Johnson, Sebastian Andrzej Siewior, Valentin Caron,
Lino Sanfilippo, Amelie Delaunay, linux-mips, linux-kernel,
linux-serial, linux-tegra, linux-arm-kernel, linux-actions,
linux-stm32
Cc: opensource.kernel
The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code and avoids calls to clk_disable_unprepare().
Signed-off-by: Lei Liu <liulei.rjpt@vivo.com>
---
drivers/tty/serial/owl-uart.c | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c
index ecec483d4d59..28c33cea6b41 100644
--- a/drivers/tty/serial/owl-uart.c
+++ b/drivers/tty/serial/owl-uart.c
@@ -680,18 +680,12 @@ static int owl_uart_probe(struct platform_device *pdev)
if (!owl_port)
return -ENOMEM;
- owl_port->clk = devm_clk_get(&pdev->dev, NULL);
+ owl_port->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(owl_port->clk)) {
dev_err(&pdev->dev, "could not get clk\n");
return PTR_ERR(owl_port->clk);
}
- ret = clk_prepare_enable(owl_port->clk);
- if (ret) {
- dev_err(&pdev->dev, "could not enable clk\n");
- return ret;
- }
-
owl_port->port.dev = &pdev->dev;
owl_port->port.line = pdev->id;
owl_port->port.type = PORT_OWL;
@@ -701,7 +695,6 @@ static int owl_uart_probe(struct platform_device *pdev)
owl_port->port.uartclk = clk_get_rate(owl_port->clk);
if (owl_port->port.uartclk == 0) {
dev_err(&pdev->dev, "clock rate is zero\n");
- clk_disable_unprepare(owl_port->clk);
return -EINVAL;
}
owl_port->port.flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_LOW_LATENCY;
@@ -725,7 +718,6 @@ static void owl_uart_remove(struct platform_device *pdev)
uart_remove_one_port(&owl_uart_driver, &owl_port->port);
owl_uart_ports[pdev->id] = NULL;
- clk_disable_unprepare(owl_port->clk);
}
static struct platform_driver owl_uart_platform_driver = {
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 7/8] tty: st-asc: Use devm_clk_get_enabled() helpers
2024-08-22 3:39 [PATCH 0/8] tty serial drivers use devm_clk_get_enabled() helpers Lei Liu
` (5 preceding siblings ...)
2024-08-22 3:39 ` [PATCH 6/8] tty: owl-uart: " Lei Liu
@ 2024-08-22 3:39 ` Lei Liu
2024-08-22 13:21 ` Andy Shevchenko
2024-08-22 3:39 ` [PATCH 8/8] tty: stm32-usart: " Lei Liu
7 siblings, 1 reply; 20+ messages in thread
From: Lei Liu @ 2024-08-22 3:39 UTC (permalink / raw)
To: Paul Cercueil, Greg Kroah-Hartman, Jiri Slaby, Thierry Reding,
Jonathan Hunter, Kunihiko Hayashi, Masami Hiramatsu,
Richard Genoud, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi, Andreas Färber,
Manivannan Sadhasivam, Patrice Chotard, Maxime Coquelin,
Alexandre Torgue, Uwe Kleine-König, Lei Liu,
Geert Uytterhoeven, Andi Shyti, Andy Shevchenko, John Ogness,
Thomas Gleixner, Sebastian Andrzej Siewior, Jeff Johnson,
Valentin Caron, Lino Sanfilippo, Erwan Le Ray, linux-mips,
linux-kernel, linux-serial, linux-tegra, linux-arm-kernel,
linux-actions, linux-stm32
Cc: opensource.kernel
The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code and avoids calls to clk_disable_unprepare().
Signed-off-by: Lei Liu <liulei.rjpt@vivo.com>
---
drivers/tty/serial/st-asc.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c
index f91753a40a69..df666766d50e 100644
--- a/drivers/tty/serial/st-asc.c
+++ b/drivers/tty/serial/st-asc.c
@@ -706,17 +706,13 @@ static int asc_init_port(struct asc_port *ascport,
spin_lock_init(&port->lock);
- ascport->clk = devm_clk_get(&pdev->dev, NULL);
+ ascport->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (WARN_ON(IS_ERR(ascport->clk)))
return -EINVAL;
- /* ensure that clk rate is correct by enabling the clk */
- ret = clk_prepare_enable(ascport->clk);
- if (ret)
- return ret;
+
ascport->port.uartclk = clk_get_rate(ascport->clk);
WARN_ON(ascport->port.uartclk == 0);
- clk_disable_unprepare(ascport->clk);
ascport->pinctrl = devm_pinctrl_get(&pdev->dev);
if (IS_ERR(ascport->pinctrl)) {
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 8/8] tty: stm32-usart: Use devm_clk_get_enabled() helpers
2024-08-22 3:39 [PATCH 0/8] tty serial drivers use devm_clk_get_enabled() helpers Lei Liu
` (6 preceding siblings ...)
2024-08-22 3:39 ` [PATCH 7/8] tty: st-asc: " Lei Liu
@ 2024-08-22 3:39 ` Lei Liu
2024-08-22 13:23 ` Andy Shevchenko
7 siblings, 1 reply; 20+ messages in thread
From: Lei Liu @ 2024-08-22 3:39 UTC (permalink / raw)
To: Paul Cercueil, Greg Kroah-Hartman, Jiri Slaby, Thierry Reding,
Jonathan Hunter, Kunihiko Hayashi, Masami Hiramatsu,
Richard Genoud, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi, Andreas Färber,
Manivannan Sadhasivam, Patrice Chotard, Maxime Coquelin,
Alexandre Torgue, Lei Liu, Uwe Kleine-König, Andi Shyti,
Geert Uytterhoeven, Andy Shevchenko, Thomas Gleixner, John Ogness,
Jeff Johnson, Sebastian Andrzej Siewior, Valentin Caron,
Lino Sanfilippo, Amelie Delaunay, linux-mips, linux-kernel,
linux-serial, linux-tegra, linux-arm-kernel, linux-actions,
linux-stm32
Cc: opensource.kernel
The devm_clk_get_enabled() helpers:
- call devm_clk_get()
- call clk_prepare_enable() and register what is needed in order to
call clk_disable_unprepare() when needed, as a managed resource.
This simplifies the code and avoids calls to clk_disable_unprepare().
Signed-off-by: Lei Liu <liulei.rjpt@vivo.com>
---
drivers/tty/serial/stm32-usart.c | 16 +---------------
1 file changed, 1 insertion(+), 15 deletions(-)
diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c
index e1e7bc04c579..9bce3159165a 100644
--- a/drivers/tty/serial/stm32-usart.c
+++ b/drivers/tty/serial/stm32-usart.c
@@ -1550,11 +1550,6 @@ static int stm32_usart_get_ftcfg(struct platform_device *pdev, struct stm32_port
return fifo_size;
}
-static void stm32_usart_deinit_port(struct stm32_port *stm32port)
-{
- clk_disable_unprepare(stm32port->clk);
-}
-
static const struct serial_rs485 stm32_rs485_supported = {
.flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND |
SER_RS485_RX_DURING_TX,
@@ -1599,15 +1594,10 @@ static int stm32_usart_init_port(struct stm32_port *stm32port,
spin_lock_init(&port->lock);
- stm32port->clk = devm_clk_get(&pdev->dev, NULL);
+ stm32port->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(stm32port->clk))
return PTR_ERR(stm32port->clk);
- /* Ensure that clk rate is correct by enabling the clk */
- ret = clk_prepare_enable(stm32port->clk);
- if (ret)
- return ret;
-
stm32port->port.uartclk = clk_get_rate(stm32port->clk);
if (!stm32port->port.uartclk) {
ret = -EINVAL;
@@ -1645,7 +1635,6 @@ static int stm32_usart_init_port(struct stm32_port *stm32port,
return ret;
err_clk:
- clk_disable_unprepare(stm32port->clk);
return ret;
}
@@ -1853,8 +1842,6 @@ static int stm32_usart_serial_probe(struct platform_device *pdev)
if (stm32port->wakeup_src)
device_set_wakeup_capable(&pdev->dev, false);
- stm32_usart_deinit_port(stm32port);
-
err_dma_tx:
if (stm32port->tx_ch)
dma_release_channel(stm32port->tx_ch);
@@ -1904,7 +1891,6 @@ static void stm32_usart_serial_remove(struct platform_device *pdev)
device_init_wakeup(&pdev->dev, false);
}
- stm32_usart_deinit_port(stm32_port);
}
static void __maybe_unused stm32_usart_console_putchar(struct uart_port *port, unsigned char ch)
--
2.34.1
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 1/8] tty: 8250_ingenic: Use devm_clk_get_enabled() helpers
2024-08-22 3:39 ` [PATCH 1/8] tty: 8250_ingenic: Use " Lei Liu
@ 2024-08-22 9:40 ` Paul Cercueil
2024-08-22 13:24 ` Andy Shevchenko
2024-08-22 13:09 ` Andy Shevchenko
1 sibling, 1 reply; 20+ messages in thread
From: Paul Cercueil @ 2024-08-22 9:40 UTC (permalink / raw)
To: Lei Liu, Greg Kroah-Hartman, Jiri Slaby, Thierry Reding,
Jonathan Hunter, Kunihiko Hayashi, Masami Hiramatsu,
Richard Genoud, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Liviu Dudau, Sudeep Holla, Lorenzo Pieralisi, Andreas Färber,
Manivannan Sadhasivam, Patrice Chotard, Maxime Coquelin,
Alexandre Torgue, Geert Uytterhoeven, Andy Shevchenko,
Florian Fainelli, Uwe Kleine-König, Thomas Gleixner,
John Ogness, Jeff Johnson, Sebastian Andrzej Siewior,
Valentin Caron, Lino Sanfilippo, linux-mips, linux-kernel,
linux-serial, linux-tegra, linux-arm-kernel, linux-actions,
linux-stm32
Cc: opensource.kernel
Hi Lei Liu,
Le jeudi 22 août 2024 à 11:39 +0800, Lei Liu a écrit :
> The devm_clk_get_enabled() helpers:
> - call devm_clk_get()
> - call clk_prepare_enable() and register what is needed in order
> to
> call clk_disable_unprepare() when needed, as a managed resource.
>
> This simplifies the code and avoids calls to clk_disable_unprepare().
>
> Signed-off-by: Lei Liu <liulei.rjpt@vivo.com>
> ---
> drivers/tty/serial/8250/8250_ingenic.c | 26 +++---------------------
> --
> 1 file changed, 3 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_ingenic.c
> b/drivers/tty/serial/8250/8250_ingenic.c
> index a2783e38a2e3..5f8787309064 100644
> --- a/drivers/tty/serial/8250/8250_ingenic.c
> +++ b/drivers/tty/serial/8250/8250_ingenic.c
> @@ -274,44 +274,26 @@ static int ingenic_uart_probe(struct
> platform_device *pdev)
> if (!uart.port.membase)
> return -ENOMEM;
>
> - data->clk_module = devm_clk_get(&pdev->dev, "module");
> + data->clk_module = devm_clk_get_enabled(&pdev->dev,
> "module");
> if (IS_ERR(data->clk_module))
> return dev_err_probe(&pdev->dev, PTR_ERR(data-
> >clk_module),
> "unable to get module
> clock\n");
>
> - data->clk_baud = devm_clk_get(&pdev->dev, "baud");
> + data->clk_baud = devm_clk_get_enabled(&pdev->dev, "baud");
> if (IS_ERR(data->clk_baud))
> return dev_err_probe(&pdev->dev, PTR_ERR(data-
> >clk_baud),
> "unable to get baud clock\n");
>
> - err = clk_prepare_enable(data->clk_module);
> - if (err) {
> - dev_err(&pdev->dev, "could not enable module clock:
> %d\n", err);
> - goto out;
> - }
> -
> - err = clk_prepare_enable(data->clk_baud);
> - if (err) {
> - dev_err(&pdev->dev, "could not enable baud clock:
> %d\n", err);
> - goto out_disable_moduleclk;
> - }
> uart.port.uartclk = clk_get_rate(data->clk_baud);
>
> data->line = serial8250_register_8250_port(&uart);
> if (data->line < 0) {
> err = data->line;
> - goto out_disable_baudclk;
> + return err;
Not really worth a V2, but if you make a V2, please "return data-
>line;" directly.
Acked-by: Paul Cercueil <paul@crapouillou.net>
Cheers,
-Paul
> }
>
> platform_set_drvdata(pdev, data);
> return 0;
> -
> -out_disable_baudclk:
> - clk_disable_unprepare(data->clk_baud);
> -out_disable_moduleclk:
> - clk_disable_unprepare(data->clk_module);
> -out:
> - return err;
> }
>
> static void ingenic_uart_remove(struct platform_device *pdev)
> @@ -319,8 +301,6 @@ static void ingenic_uart_remove(struct
> platform_device *pdev)
> struct ingenic_uart_data *data = platform_get_drvdata(pdev);
>
> serial8250_unregister_port(data->line);
> - clk_disable_unprepare(data->clk_module);
> - clk_disable_unprepare(data->clk_baud);
> }
>
> static const struct ingenic_uart_config jz4740_uart_config = {
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/8] tty: 8250_ingenic: Use devm_clk_get_enabled() helpers
2024-08-22 3:39 ` [PATCH 1/8] tty: 8250_ingenic: Use " Lei Liu
2024-08-22 9:40 ` Paul Cercueil
@ 2024-08-22 13:09 ` Andy Shevchenko
1 sibling, 0 replies; 20+ messages in thread
From: Andy Shevchenko @ 2024-08-22 13:09 UTC (permalink / raw)
To: Lei Liu
Cc: Alexandre Belloni, Valentin Caron, Geert Uytterhoeven,
Lorenzo Pieralisi, Liviu Dudau, Alexandre Torgue, Claudiu Beznea,
Paul Cercueil, Thierry Reding, Manivannan Sadhasivam, Jiri Slaby,
linux-stm32, opensource.kernel, Kunihiko Hayashi,
Florian Fainelli, Jonathan Hunter, linux-arm-kernel, linux-serial,
Uwe Kleine-König, linux-mips, Patrice Chotard, John Ogness,
linux-kernel, linux-actions, linux-tegra, Thomas Gleixner,
Richard Genoud, Sebastian Andrzej Siewior, Greg Kroah-Hartman,
Lino Sanfilippo, Masami Hiramatsu, Maxime Coquelin, Sudeep Holla,
Jeff Johnson, Andreas Färber
On Thu, Aug 22, 2024 at 11:39:05AM +0800, Lei Liu wrote:
> The devm_clk_get_enabled() helpers:
> - call devm_clk_get()
> - call clk_prepare_enable() and register what is needed in order to
> call clk_disable_unprepare() when needed, as a managed resource.
>
> This simplifies the code and avoids calls to clk_disable_unprepare().
...
> data->line = serial8250_register_8250_port(&uart);
> if (data->line < 0) {
> err = data->line;
> - goto out_disable_baudclk;
> + return err;
> }
data->line = serial8250_register_8250_port(&uart);
if (data->line < 0)
return data->line;
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/8] tty: 8250_tegra: Use devm_clk_get_enabled() helpers
2024-08-22 3:39 ` [PATCH 2/8] tty: 8250_tegra: " Lei Liu
@ 2024-08-22 13:10 ` Andy Shevchenko
0 siblings, 0 replies; 20+ messages in thread
From: Andy Shevchenko @ 2024-08-22 13:10 UTC (permalink / raw)
To: Lei Liu
Cc: Alexandre Belloni, Valentin Caron, Kunihiko Hayashi,
Lorenzo Pieralisi, Liviu Dudau, Alexandre Torgue, Claudiu Beznea,
Paul Cercueil, Thierry Reding, Manivannan Sadhasivam, Jiri Slaby,
linux-stm32, opensource.kernel, Florian Fainelli, Jonathan Hunter,
linux-arm-kernel, linux-serial, Uwe Kleine-König, linux-mips,
Patrice Chotard, John Ogness, linux-kernel, linux-actions,
Amelie Delaunay, linux-tegra, Thomas Gleixner, Richard Genoud,
Sebastian Andrzej Siewior, AngeloGioacchino Del Regno,
Greg Kroah-Hartman, Lino Sanfilippo, Masami Hiramatsu,
Maxime Coquelin, Sudeep Holla, Jeff Johnson, Andreas Färber
On Thu, Aug 22, 2024 at 11:39:06AM +0800, Lei Liu wrote:
> The devm_clk_get_enabled() helpers:
> - call devm_clk_get()
> - call clk_prepare_enable() and register what is needed in order to
> call clk_disable_unprepare() when needed, as a managed resource.
>
> This simplifies the code and avoids calls to clk_disable_unprepare().
...
> err_clkdisable:
> - clk_disable_unprepare(uart->clk);
>
> return ret;
Now this label (err_clkdisable) becomes redundant and code may use return ret
in-line.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 5/8] tty: mps2-uart: Use devm_clk_get_enabled() helpers
2024-08-22 3:39 ` [PATCH 5/8] tty: mps2-uart: " Lei Liu
@ 2024-08-22 13:19 ` Andy Shevchenko
2024-08-22 13:29 ` Lei Liu
0 siblings, 1 reply; 20+ messages in thread
From: Andy Shevchenko @ 2024-08-22 13:19 UTC (permalink / raw)
To: Lei Liu
Cc: Alexandre Belloni, Valentin Caron, Geert Uytterhoeven,
Lorenzo Pieralisi, Liviu Dudau, Alexandre Torgue, Claudiu Beznea,
Paul Cercueil, Thierry Reding, Manivannan Sadhasivam, Jiri Slaby,
linux-stm32, opensource.kernel, Kunihiko Hayashi, Jonathan Hunter,
linux-arm-kernel, linux-serial, Uwe Kleine-König, linux-mips,
Patrice Chotard, John Ogness, linux-kernel, linux-actions,
Amelie Delaunay, linux-tegra, Thomas Gleixner, Richard Genoud,
Sebastian Andrzej Siewior, AngeloGioacchino Del Regno,
Greg Kroah-Hartman, Lino Sanfilippo, Masami Hiramatsu,
Maxime Coquelin, Sudeep Holla, Jeff Johnson, Andreas Färber
On Thu, Aug 22, 2024 at 11:39:09AM +0800, Lei Liu wrote:
> The devm_clk_get_enabled() helpers:
> - call devm_clk_get()
> - call clk_prepare_enable() and register what is needed in order to
> call clk_disable_unprepare() when needed, as a managed resource.
>
> This simplifies the code and avoids calls to clk_disable_unprepare().
...
> - mps_port->clk = devm_clk_get(&pdev->dev, NULL);
> + mps_port->clk = devm_clk_get_enabled(&pdev->dev, NULL);
> if (IS_ERR(mps_port->clk))
> return PTR_ERR(mps_port->clk);
>
> - ret = clk_prepare_enable(mps_port->clk);
> - if (ret)
> - return ret;
> -
> mps_port->port.uartclk = clk_get_rate(mps_port->clk);
>
> - clk_disable_unprepare(mps_port->clk);
Your change is not equivalent. In case this clock is shared this may lead to
run-time issues. Hence I don't think this patch is needed in this case.
Instead, you may add a comment on top of devm_clk_get() to explain that we only
need it be enabled to get clock rate in the probe.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 7/8] tty: st-asc: Use devm_clk_get_enabled() helpers
2024-08-22 3:39 ` [PATCH 7/8] tty: st-asc: " Lei Liu
@ 2024-08-22 13:21 ` Andy Shevchenko
0 siblings, 0 replies; 20+ messages in thread
From: Andy Shevchenko @ 2024-08-22 13:21 UTC (permalink / raw)
To: Lei Liu
Cc: Alexandre Belloni, Valentin Caron, Erwan Le Ray,
Geert Uytterhoeven, Lorenzo Pieralisi, Liviu Dudau,
Alexandre Torgue, Claudiu Beznea, Paul Cercueil, Thierry Reding,
Manivannan Sadhasivam, Jiri Slaby, linux-stm32, opensource.kernel,
Kunihiko Hayashi, Jonathan Hunter, linux-arm-kernel, Andi Shyti,
Uwe Kleine-König, linux-mips, Patrice Chotard, linux-serial,
John Ogness, linux-kernel, linux-actions, linux-tegra,
Thomas Gleixner, Richard Genoud, Sebastian Andrzej Siewior,
Greg Kroah-Hartman, Lino Sanfilippo, Masami Hiramatsu,
Maxime Coquelin, Sudeep Holla, Jeff Johnson, Andreas Färber
On Thu, Aug 22, 2024 at 11:39:11AM +0800, Lei Liu wrote:
> The devm_clk_get_enabled() helpers:
> - call devm_clk_get()
> - call clk_prepare_enable() and register what is needed in order to
> call clk_disable_unprepare() when needed, as a managed resource.
>
> This simplifies the code and avoids calls to clk_disable_unprepare().
...
Same caveat as in another patch comment.
> - ascport->clk = devm_clk_get(&pdev->dev, NULL);
> + ascport->clk = devm_clk_get_enabled(&pdev->dev, NULL);
>
> if (WARN_ON(IS_ERR(ascport->clk)))
> return -EINVAL;
> - /* ensure that clk rate is correct by enabling the clk */
> - ret = clk_prepare_enable(ascport->clk);
> - if (ret)
> - return ret;
> +
> ascport->port.uartclk = clk_get_rate(ascport->clk);
> WARN_ON(ascport->port.uartclk == 0);
Btw, not related to this series, you may try to get rid of these 0 checks as
the serial core has this and it will fail anyway. Perhaps you want to expand
serial core to issue an error message (if it's not done yet).
> - clk_disable_unprepare(ascport->clk);
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 8/8] tty: stm32-usart: Use devm_clk_get_enabled() helpers
2024-08-22 3:39 ` [PATCH 8/8] tty: stm32-usart: " Lei Liu
@ 2024-08-22 13:23 ` Andy Shevchenko
0 siblings, 0 replies; 20+ messages in thread
From: Andy Shevchenko @ 2024-08-22 13:23 UTC (permalink / raw)
To: Lei Liu
Cc: Alexandre Belloni, Valentin Caron, Kunihiko Hayashi,
Lorenzo Pieralisi, Liviu Dudau, Alexandre Torgue, Claudiu Beznea,
Paul Cercueil, Thierry Reding, Manivannan Sadhasivam, Jiri Slaby,
linux-stm32, opensource.kernel, Geert Uytterhoeven,
Jonathan Hunter, linux-arm-kernel, Andi Shyti,
Uwe Kleine-König, linux-mips, Patrice Chotard, linux-serial,
John Ogness, linux-kernel, linux-actions, Amelie Delaunay,
linux-tegra, Thomas Gleixner, Richard Genoud,
Sebastian Andrzej Siewior, Greg Kroah-Hartman, Lino Sanfilippo,
Masami Hiramatsu, Maxime Coquelin, Sudeep Holla, Jeff Johnson,
Andreas Färber
On Thu, Aug 22, 2024 at 11:39:12AM +0800, Lei Liu wrote:
> The devm_clk_get_enabled() helpers:
> - call devm_clk_get()
> - call clk_prepare_enable() and register what is needed in order to
> call clk_disable_unprepare() when needed, as a managed resource.
>
> This simplifies the code and avoids calls to clk_disable_unprepare().
...
> err_clk:
> - clk_disable_unprepare(stm32port->clk);
>
> return ret;
No unneeded label, please drop it as well and return directly.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 1/8] tty: 8250_ingenic: Use devm_clk_get_enabled() helpers
2024-08-22 9:40 ` Paul Cercueil
@ 2024-08-22 13:24 ` Andy Shevchenko
0 siblings, 0 replies; 20+ messages in thread
From: Andy Shevchenko @ 2024-08-22 13:24 UTC (permalink / raw)
To: Paul Cercueil
Cc: Alexandre Belloni, Valentin Caron, Kunihiko Hayashi,
Lorenzo Pieralisi, Liviu Dudau, Alexandre Torgue, Claudiu Beznea,
Thierry Reding, Manivannan Sadhasivam, Jiri Slaby, linux-stm32,
opensource.kernel, Geert Uytterhoeven, Florian Fainelli,
Jonathan Hunter, linux-arm-kernel, linux-serial,
Uwe Kleine-König, linux-mips, Patrice Chotard, Lei Liu,
John Ogness, linux-kernel, linux-actions, linux-tegra,
Thomas Gleixner, Richard Genoud, Sebastian Andrzej Siewior,
Greg Kroah-Hartman, Lino Sanfilippo, Masami Hiramatsu,
Maxime Coquelin, Sudeep Holla, Jeff Johnson, Andreas Färber
On Thu, Aug 22, 2024 at 11:40:46AM +0200, Paul Cercueil wrote:
> Le jeudi 22 août 2024 à 11:39 +0800, Lei Liu a écrit :
...
> Not really worth a V2, but if you make a V2, please "return data-
> >line;" directly.
> Acked-by: Paul Cercueil <paul@crapouillou.net>
Despite of this, the series has other small issues that needs to be addressed,
so I would wait for v2.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/8] tty: atmel_serial: Use devm_clk_get_enabled() helpers
2024-08-22 3:39 ` [PATCH 4/8] tty: atmel_serial: " Lei Liu
@ 2024-08-22 13:28 ` Richard GENOUD
2024-08-22 13:34 ` Andy Shevchenko
0 siblings, 1 reply; 20+ messages in thread
From: Richard GENOUD @ 2024-08-22 13:28 UTC (permalink / raw)
To: Lei Liu
Cc: Alexandre Belloni, Valentin Caron, Erwan Le Ray, Kunihiko Hayashi,
Lorenzo Pieralisi, Liviu Dudau, Alexandre Torgue, Claudiu Beznea,
Paul Cercueil, Thierry Reding, Manivannan Sadhasivam, Jiri Slaby,
linux-stm32, opensource.kernel, Florian Fainelli, Jonathan Hunter,
linux-arm-kernel, Andi Shyti, Uwe Kleine-König, linux-mips,
Patrice Chotard, linux-serial, John Ogness, linux-kernel,
linux-actions, linux-tegra, Thomas Gleixner, Andy Shevchenko,
Sebastian Andrzej Siewior, Greg Kroah-Hartman, Lino Sanfilippo,
Masami Hiramatsu, Maxime Coquelin, Sudeep Holla, Jeff Johnson,
Andreas Färber
Le 22/08/2024 à 05:39, Lei Liu a écrit :
> The devm_clk_get_enabled() helpers:
> - call devm_clk_get()
> - call clk_prepare_enable() and register what is needed in order to
> call clk_disable_unprepare() when needed, as a managed resource.
>
> This simplifies the code and avoids calls to clk_disable_unprepare().
>
> Signed-off-by: Lei Liu <liulei.rjpt@vivo.com>
> ---
> drivers/tty/serial/atmel_serial.c | 8 +-------
> 1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index 09b246c9e389..209f3d41a17c 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -2910,14 +2910,11 @@ static int atmel_serial_probe(struct platform_device *pdev)
> atomic_set(&atmel_port->tasklet_shutdown, 0);
> spin_lock_init(&atmel_port->lock_suspended);
>
> - atmel_port->clk = devm_clk_get(&pdev->dev, "usart");
> + atmel_port->clk = devm_clk_get_enabled(&pdev->dev, "usart");
> if (IS_ERR(atmel_port->clk)) {
> ret = PTR_ERR(atmel_port->clk);
> goto err;
> }
> - ret = clk_prepare_enable(atmel_port->clk);
> - if (ret)
> - goto err;
>
> atmel_port->gclk = devm_clk_get_optional(&pdev->dev, "gclk");
> if (IS_ERR(atmel_port->gclk)) {
> @@ -2968,15 +2965,12 @@ static int atmel_serial_probe(struct platform_device *pdev)
> * The peripheral clock can now safely be disabled till the port
> * is used
> */
> - clk_disable_unprepare(atmel_port->clk);
> -
Why removing this ?
This is not an error path.
> return 0;
>
> err_add_port:
> kfree(atmel_port->rx_ring.buf);
> atmel_port->rx_ring.buf = NULL;
> err_clk_disable_unprepare:
> - clk_disable_unprepare(atmel_port->clk);
> clear_bit(atmel_port->uart.line, atmel_ports_in_use);
> err:
> return ret;
Thanks,
Richard.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 5/8] tty: mps2-uart: Use devm_clk_get_enabled() helpers
2024-08-22 13:19 ` Andy Shevchenko
@ 2024-08-22 13:29 ` Lei Liu
0 siblings, 0 replies; 20+ messages in thread
From: Lei Liu @ 2024-08-22 13:29 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Alexandre Belloni, Valentin Caron, Geert Uytterhoeven,
Lorenzo Pieralisi, Liviu Dudau, Alexandre Torgue, Claudiu Beznea,
Paul Cercueil, Thierry Reding, Manivannan Sadhasivam, Jiri Slaby,
linux-stm32, opensource.kernel, Kunihiko Hayashi, Jonathan Hunter,
linux-arm-kernel, linux-serial, Uwe Kleine-König, linux-mips,
Patrice Chotard, John Ogness, linux-kernel, linux-actions,
Amelie Delaunay, linux-tegra, Thomas Gleixner, Richard Genoud,
Sebastian Andrzej Siewior, AngeloGioacchino Del Regno,
Greg Kroah-Hartman, Lino Sanfilippo, Masami Hiramatsu,
Maxime Coquelin, Sudeep Holla, Jeff Johnson, Andreas Färber
on 2024/8/22 21:19, Andy Shevchenko wrote:
> On Thu, Aug 22, 2024 at 11:39:09AM +0800, Lei Liu wrote:
>> The devm_clk_get_enabled() helpers:
>> - call devm_clk_get()
>> - call clk_prepare_enable() and register what is needed in order to
>> call clk_disable_unprepare() when needed, as a managed resource.
>>
>> This simplifies the code and avoids calls to clk_disable_unprepare().
> ...
>
>> - mps_port->clk = devm_clk_get(&pdev->dev, NULL);
>> + mps_port->clk = devm_clk_get_enabled(&pdev->dev, NULL);
>> if (IS_ERR(mps_port->clk))
>> return PTR_ERR(mps_port->clk);
>>
>> - ret = clk_prepare_enable(mps_port->clk);
>> - if (ret)
>> - return ret;
>> -
>> mps_port->port.uartclk = clk_get_rate(mps_port->clk);
>>
>> - clk_disable_unprepare(mps_port->clk);
> Your change is not equivalent. In case this clock is shared this may lead to
> run-time issues. Hence I don't think this patch is needed in this case.
> Instead, you may add a comment on top of devm_clk_get() to explain that we only
> need it be enabled to get clock rate in the probe.
Thank you for your suggestion. I will adopt your advice in the second
version of the patch and make no changes.
---
With Best Regards,
Lei Liu
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/8] tty: atmel_serial: Use devm_clk_get_enabled() helpers
2024-08-22 13:28 ` Richard GENOUD
@ 2024-08-22 13:34 ` Andy Shevchenko
2024-08-22 14:33 ` Alexandre Belloni
0 siblings, 1 reply; 20+ messages in thread
From: Andy Shevchenko @ 2024-08-22 13:34 UTC (permalink / raw)
To: Richard GENOUD
Cc: Alexandre Belloni, Valentin Caron, Erwan Le Ray, Kunihiko Hayashi,
Lorenzo Pieralisi, Liviu Dudau, Alexandre Torgue, Claudiu Beznea,
Paul Cercueil, Thierry Reding, Manivannan Sadhasivam, Jiri Slaby,
linux-stm32, opensource.kernel, Florian Fainelli, Jonathan Hunter,
linux-arm-kernel, Andi Shyti, Uwe Kleine-König, linux-mips,
Patrice Chotard, Lei Liu, John Ogness, linux-kernel,
linux-actions, linux-serial, linux-tegra, Thomas Gleixner,
Sebastian Andrzej Siewior, Greg Kroah-Hartman, Lino Sanfilippo,
Masami Hiramatsu, Maxime Coquelin, Sudeep Holla, Jeff Johnson,
Andreas Färber
On Thu, Aug 22, 2024 at 03:28:40PM +0200, Richard GENOUD wrote:
> Le 22/08/2024 à 05:39, Lei Liu a écrit :
> > The devm_clk_get_enabled() helpers:
> > - call devm_clk_get()
> > - call clk_prepare_enable() and register what is needed in order to
> > call clk_disable_unprepare() when needed, as a managed resource.
> >
> > This simplifies the code and avoids calls to clk_disable_unprepare().
...
> > * The peripheral clock can now safely be disabled till the port
> > * is used
> > */
> > - clk_disable_unprepare(atmel_port->clk);
> > -
> Why removing this ?
> This is not an error path.
Good point, I wouldn't apply this patch as well as a few others in this series
due to this reason.
Instead it might make sense to add a comment on top of devm_clk_get() to
explain why _enabled() variant is *not* used.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 4/8] tty: atmel_serial: Use devm_clk_get_enabled() helpers
2024-08-22 13:34 ` Andy Shevchenko
@ 2024-08-22 14:33 ` Alexandre Belloni
0 siblings, 0 replies; 20+ messages in thread
From: Alexandre Belloni @ 2024-08-22 14:33 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Valentin Caron, Erwan Le Ray, Kunihiko Hayashi, Lorenzo Pieralisi,
Liviu Dudau, Alexandre Torgue, Claudiu Beznea, Paul Cercueil,
Thierry Reding, Manivannan Sadhasivam, Jiri Slaby, linux-stm32,
opensource.kernel, Florian Fainelli, Jonathan Hunter,
linux-arm-kernel, Andi Shyti, Uwe Kleine-König, linux-mips,
Patrice Chotard, Lei Liu, John Ogness, linux-kernel,
linux-actions, linux-serial, linux-tegra, Thomas Gleixner,
Richard GENOUD, Sebastian Andrzej Siewior, Greg Kroah-Hartman,
Lino Sanfilippo, Masami Hiramatsu, Maxime Coquelin, Sudeep Holla,
Jeff Johnson, Andreas Färber
On 22/08/2024 16:34:28+0300, Andy Shevchenko wrote:
> On Thu, Aug 22, 2024 at 03:28:40PM +0200, Richard GENOUD wrote:
> > Le 22/08/2024 à 05:39, Lei Liu a écrit :
> > > The devm_clk_get_enabled() helpers:
> > > - call devm_clk_get()
> > > - call clk_prepare_enable() and register what is needed in order to
> > > call clk_disable_unprepare() when needed, as a managed resource.
> > >
> > > This simplifies the code and avoids calls to clk_disable_unprepare().
>
> ...
>
> > > * The peripheral clock can now safely be disabled till the port
> > > * is used
> > > */
> > > - clk_disable_unprepare(atmel_port->clk);
> > > -
> > Why removing this ?
> > This is not an error path.
>
> Good point, I wouldn't apply this patch as well as a few others in this series
> due to this reason.
>
> Instead it might make sense to add a comment on top of devm_clk_get() to
> explain why _enabled() variant is *not* used.
Or maybe stop doing brainded conversions to new APIs.
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2024-08-22 14:35 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-22 3:39 [PATCH 0/8] tty serial drivers use devm_clk_get_enabled() helpers Lei Liu
2024-08-22 3:39 ` [PATCH 1/8] tty: 8250_ingenic: Use " Lei Liu
2024-08-22 9:40 ` Paul Cercueil
2024-08-22 13:24 ` Andy Shevchenko
2024-08-22 13:09 ` Andy Shevchenko
2024-08-22 3:39 ` [PATCH 2/8] tty: 8250_tegra: " Lei Liu
2024-08-22 13:10 ` Andy Shevchenko
2024-08-22 3:39 ` [PATCH 3/8] tty: 8250_uniphier: " Lei Liu
2024-08-22 3:39 ` [PATCH 4/8] tty: atmel_serial: " Lei Liu
2024-08-22 13:28 ` Richard GENOUD
2024-08-22 13:34 ` Andy Shevchenko
2024-08-22 14:33 ` Alexandre Belloni
2024-08-22 3:39 ` [PATCH 5/8] tty: mps2-uart: " Lei Liu
2024-08-22 13:19 ` Andy Shevchenko
2024-08-22 13:29 ` Lei Liu
2024-08-22 3:39 ` [PATCH 6/8] tty: owl-uart: " Lei Liu
2024-08-22 3:39 ` [PATCH 7/8] tty: st-asc: " Lei Liu
2024-08-22 13:21 ` Andy Shevchenko
2024-08-22 3:39 ` [PATCH 8/8] tty: stm32-usart: " Lei Liu
2024-08-22 13:23 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).