* [PATCHv2] ata: sata_mv: use devm clock helpers
@ 2026-07-12 22:37 Rosen Penev
2026-07-18 3:01 ` Damien Le Moal
0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2026-07-12 22:37 UTC (permalink / raw)
To: linux-ide; +Cc: Damien Le Moal, Niklas Cassel, open list
Replace clk_get/clk_prepare_enable/clk_put with
devm_clk_get_optional_enabled for both the main clock and
per-port clocks. This eliminates the need for manual clock
cleanup in probe error and remove paths.
The err label is retained for phy_power_off cleanup, since
devm_phy_optional_get does not manage phy power state.
Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
v2: sashiko: use goto instead of return.
drivers/ata/sata_mv.c | 46 ++++++++++++-------------------------------
1 file changed, 13 insertions(+), 33 deletions(-)
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 145ba6880c82..d260f04e6384 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -4088,21 +4088,19 @@ static int mv_platform_probe(struct platform_device *pdev)
hpriv->base -= SATAHC0_REG_BASE;
- hpriv->clk = clk_get(&pdev->dev, NULL);
- if (IS_ERR(hpriv->clk)) {
- dev_notice(&pdev->dev, "cannot get optional clkdev\n");
- } else {
- rc = clk_prepare_enable(hpriv->clk);
- if (rc)
- goto err;
- }
+ hpriv->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL);
+ if (IS_ERR(hpriv->clk))
+ return PTR_ERR(hpriv->clk);
for (port = 0; port < n_ports; port++) {
char port_number[16];
sprintf(port_number, "%d", port);
- hpriv->port_clks[port] = clk_get(&pdev->dev, port_number);
- if (!IS_ERR(hpriv->port_clks[port]))
- clk_prepare_enable(hpriv->port_clks[port]);
+ hpriv->port_clks[port] = devm_clk_get_optional_enabled(&pdev->dev, port_number);
+ if (IS_ERR(hpriv->port_clks[port])) {
+ rc = PTR_ERR(hpriv->port_clks[port]);
+ hpriv->n_ports = port;
+ goto err;
+ }
sprintf(port_number, "port%d", port);
hpriv->port_phys[port] = devm_phy_optional_get(&pdev->dev,
@@ -4116,8 +4114,8 @@ static int mv_platform_probe(struct platform_device *pdev)
/* Cleanup only the initialized ports */
hpriv->n_ports = port;
goto err;
- } else
- phy_power_on(hpriv->port_phys[port]);
+ }
+ phy_power_on(hpriv->port_phys[port]);
}
/* All the ports have been initialized */
@@ -4156,17 +4154,8 @@ static int mv_platform_probe(struct platform_device *pdev)
return 0;
err:
- if (!IS_ERR(hpriv->clk)) {
- clk_disable_unprepare(hpriv->clk);
- clk_put(hpriv->clk);
- }
- for (port = 0; port < hpriv->n_ports; port++) {
- if (!IS_ERR(hpriv->port_clks[port])) {
- clk_disable_unprepare(hpriv->port_clks[port]);
- clk_put(hpriv->port_clks[port]);
- }
+ for (port = 0; port < hpriv->n_ports; port++)
phy_power_off(hpriv->port_phys[port]);
- }
return rc;
}
@@ -4186,17 +4175,8 @@ static void mv_platform_remove(struct platform_device *pdev)
int port;
ata_host_detach(host);
- if (!IS_ERR(hpriv->clk)) {
- clk_disable_unprepare(hpriv->clk);
- clk_put(hpriv->clk);
- }
- for (port = 0; port < host->n_ports; port++) {
- if (!IS_ERR(hpriv->port_clks[port])) {
- clk_disable_unprepare(hpriv->port_clks[port]);
- clk_put(hpriv->port_clks[port]);
- }
+ for (port = 0; port < host->n_ports; port++)
phy_power_off(hpriv->port_phys[port]);
- }
}
#ifdef CONFIG_PM_SLEEP
--
2.55.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCHv2] ata: sata_mv: use devm clock helpers
2026-07-12 22:37 [PATCHv2] ata: sata_mv: use devm clock helpers Rosen Penev
@ 2026-07-18 3:01 ` Damien Le Moal
0 siblings, 0 replies; 2+ messages in thread
From: Damien Le Moal @ 2026-07-18 3:01 UTC (permalink / raw)
To: Rosen Penev, linux-ide; +Cc: Niklas Cassel, open list
On 7/13/26 07:37, Rosen Penev wrote:
> Replace clk_get/clk_prepare_enable/clk_put with
> devm_clk_get_optional_enabled for both the main clock and
> per-port clocks. This eliminates the need for manual clock
> cleanup in probe error and remove paths.
>
> The err label is retained for phy_power_off cleanup, since
> devm_phy_optional_get does not manage phy power state.
>
> Assisted-by: opencode:big-pickle
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
Applied to for-7.3. Thanks!
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-18 3:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-12 22:37 [PATCHv2] ata: sata_mv: use devm clock helpers Rosen Penev
2026-07-18 3:01 ` Damien Le Moal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome