2023-10-10 12:30:02

by Ma Ke

[permalink] [raw]
Subject: [PATCH v3] ata: sata_mv: aspeed: fix value check in mv_platform_probe()

In mv_platform_probe(), check the return value of clk_prepare_enable()
and return the error code if clk_prepare_enable() returns an
unexpected value.

Signed-off-by: Ma Ke <[email protected]>
---
drivers/ata/sata_mv.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
index 45e48d653c60..e82786c63fbd 100644
--- a/drivers/ata/sata_mv.c
+++ b/drivers/ata/sata_mv.c
@@ -4123,10 +4123,13 @@ 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))
+ if (IS_ERR(hpriv->clk)) {
dev_notice(&pdev->dev, "cannot get optional clkdev\n");
- else
- clk_prepare_enable(hpriv->clk);
+ } else {
+ rc = clk_prepare_enable(hpriv->clk);
+ if (rc)
+ goto err;
+ }

for (port = 0; port < n_ports; port++) {
char port_number[16];
--
2.37.2


2023-10-10 14:01:39

by Niklas Cassel

[permalink] [raw]
Subject: Re: [PATCH v3] ata: sata_mv: aspeed: fix value check in mv_platform_probe()

On Tue, Oct 10, 2023 at 08:29:16PM +0800, Ma Ke wrote:
> In mv_platform_probe(), check the return value of clk_prepare_enable()
> and return the error code if clk_prepare_enable() returns an
> unexpected value.
>
> Signed-off-by: Ma Ke <[email protected]>
> ---
> drivers/ata/sata_mv.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c
> index 45e48d653c60..e82786c63fbd 100644
> --- a/drivers/ata/sata_mv.c
> +++ b/drivers/ata/sata_mv.c
> @@ -4123,10 +4123,13 @@ 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))
> + if (IS_ERR(hpriv->clk)) {
> dev_notice(&pdev->dev, "cannot get optional clkdev\n");
> - else
> - clk_prepare_enable(hpriv->clk);
> + } else {
> + rc = clk_prepare_enable(hpriv->clk);
> + if (rc)
> + goto err;
> + }
>
> for (port = 0; port < n_ports; port++) {
> char port_number[16];
> --
> 2.37.2
>

Reviewed-by: Niklas Cassel <[email protected]>

Nit:
Instead of:
ata: sata_mv: aspeed: fix value check in mv_platform_probe()
something like:
ata: sata_mv: aspeed: check clk_prepare_enable() return code

Might be slightly more descriptive.

Will leave it up to the maintainer though.


Kind regards,
Niklas

2023-10-11 11:10:36

by Damien Le Moal

[permalink] [raw]
Subject: Re: [PATCH v3] ata: sata_mv: aspeed: fix value check in mv_platform_probe()

On 10/10/23 21:29, Ma Ke wrote:
> In mv_platform_probe(), check the return value of clk_prepare_enable()
> and return the error code if clk_prepare_enable() returns an
> unexpected value.
>
> Signed-off-by: Ma Ke <[email protected]>

Applied to for-6.7. Thanks !

--
Damien Le Moal
Western Digital Research