[v3,62/62] mmc: f-sdh30: fix order of function calls in sdhci_f_sdh30_remove

Message ID 20230727070051.17778-62-frank.li@vivo.com
State New
Headers
Series [v3,01/62] mmc: sunxi: Convert to platform remove callback returning void |

Commit Message

李扬韬 July 27, 2023, 7 a.m. UTC
  The order of function calls in sdhci_f_sdh30_remove is wrong,
let's call sdhci_pltfm_unregister first.

Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fixes: 5def5c1c15bf ("mmc: sdhci-f-sdh30: Replace with sdhci_pltfm")
Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 drivers/mmc/host/sdhci_f_sdh30.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Uwe Kleine-König July 27, 2023, 7:36 a.m. UTC | #1
On Thu, Jul 27, 2023 at 03:00:51PM +0800, Yangtao Li wrote:
> The order of function calls in sdhci_f_sdh30_remove is wrong,
> let's call sdhci_pltfm_unregister first.
> 
> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Fixes: 5def5c1c15bf ("mmc: sdhci-f-sdh30: Replace with sdhci_pltfm")
> Signed-off-by: Yangtao Li <frank.li@vivo.com>

Reported-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

A cover letter summarizing the changes in this v3 compared to v2 would
be nice. Also mentioning the base for this patch set would simplify
things a bit.

Best regards
Uwe
  
Adrian Hunter July 27, 2023, 1:55 p.m. UTC | #2
On 27/07/23 10:00, Yangtao Li wrote:
> The order of function calls in sdhci_f_sdh30_remove is wrong,
> let's call sdhci_pltfm_unregister first.
> 
> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Fixes: 5def5c1c15bf ("mmc: sdhci-f-sdh30: Replace with sdhci_pltfm")
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>  drivers/mmc/host/sdhci_f_sdh30.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/mmc/host/sdhci_f_sdh30.c b/drivers/mmc/host/sdhci_f_sdh30.c
> index 840084ee72e6..964fa18a61a4 100644
> --- a/drivers/mmc/host/sdhci_f_sdh30.c
> +++ b/drivers/mmc/host/sdhci_f_sdh30.c
> @@ -211,11 +211,11 @@ static void sdhci_f_sdh30_remove(struct platform_device *pdev)
>  	struct sdhci_host *host = platform_get_drvdata(pdev);
>  	struct f_sdhost_priv *priv = sdhci_f_sdhost_priv(host);
>  
> +	sdhci_pltfm_unregister(pdev);

That also frees priv

> +
>  	reset_control_assert(priv->rst);
>  	clk_disable_unprepare(priv->clk);
>  	clk_disable_unprepare(priv->clk_iface);
> -
> -	sdhci_pltfm_unregister(pdev);
>  }
>  
>  #ifdef CONFIG_OF
  
Adrian Hunter Aug. 3, 2023, 5:46 a.m. UTC | #3
On 27/07/23 16:55, Adrian Hunter wrote:
> On 27/07/23 10:00, Yangtao Li wrote:
>> The order of function calls in sdhci_f_sdh30_remove is wrong,
>> let's call sdhci_pltfm_unregister first.
>>
>> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
>> Fixes: 5def5c1c15bf ("mmc: sdhci-f-sdh30: Replace with sdhci_pltfm")
>> Signed-off-by: Yangtao Li <frank.li@vivo.com>
>> ---
>>  drivers/mmc/host/sdhci_f_sdh30.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mmc/host/sdhci_f_sdh30.c b/drivers/mmc/host/sdhci_f_sdh30.c
>> index 840084ee72e6..964fa18a61a4 100644
>> --- a/drivers/mmc/host/sdhci_f_sdh30.c
>> +++ b/drivers/mmc/host/sdhci_f_sdh30.c
>> @@ -211,11 +211,11 @@ static void sdhci_f_sdh30_remove(struct platform_device *pdev)
>>  	struct sdhci_host *host = platform_get_drvdata(pdev);
>>  	struct f_sdhost_priv *priv = sdhci_f_sdhost_priv(host);
>>  
>> +	sdhci_pltfm_unregister(pdev);
> 
> That also frees priv
> 
>> +
>>  	reset_control_assert(priv->rst);
>>  	clk_disable_unprepare(priv->clk);
>>  	clk_disable_unprepare(priv->clk_iface);
>> -
>> -	sdhci_pltfm_unregister(pdev);
>>  }
>>  
>>  #ifdef CONFIG_OF
> 

So it needs to end up looking something like below, right?

diff --git a/drivers/mmc/host/sdhci_f_sdh30.c b/drivers/mmc/host/sdhci_f_sdh30.c
index 840084ee72e6..47ae853f51aa 100644
--- a/drivers/mmc/host/sdhci_f_sdh30.c
+++ b/drivers/mmc/host/sdhci_f_sdh30.c
@@ -210,12 +210,15 @@ static void sdhci_f_sdh30_remove(struct platform_device *pdev)
 {
 	struct sdhci_host *host = platform_get_drvdata(pdev);
 	struct f_sdhost_priv *priv = sdhci_f_sdhost_priv(host);
-
-	reset_control_assert(priv->rst);
-	clk_disable_unprepare(priv->clk);
-	clk_disable_unprepare(priv->clk_iface);
+	struct clk *clk_iface = priv->clk_iface;
+	struct reset_control *rst = priv->rst;
+	struct clk *clk = priv->clk;
 
 	sdhci_pltfm_unregister(pdev);
+
+	reset_control_assert(rst);
+	clk_disable_unprepare(clk);
+	clk_disable_unprepare(clk_iface);
 }
 
 #ifdef CONFIG_OF
  
Uwe Kleine-König Aug. 3, 2023, 9:52 a.m. UTC | #4
Hello,

On Thu, Aug 03, 2023 at 08:46:08AM +0300, Adrian Hunter wrote:
> On 27/07/23 16:55, Adrian Hunter wrote:
> >> diff --git a/drivers/mmc/host/sdhci_f_sdh30.c b/drivers/mmc/host/sdhci_f_sdh30.c
> >> index 840084ee72e6..964fa18a61a4 100644
> >> --- a/drivers/mmc/host/sdhci_f_sdh30.c
> >> +++ b/drivers/mmc/host/sdhci_f_sdh30.c
> >> @@ -211,11 +211,11 @@ static void sdhci_f_sdh30_remove(struct platform_device *pdev)
> >>  	struct sdhci_host *host = platform_get_drvdata(pdev);
> >>  	struct f_sdhost_priv *priv = sdhci_f_sdhost_priv(host);
> >>  
> >> +	sdhci_pltfm_unregister(pdev);
> > 
> > That also frees priv
> > 
> >> +
> >>  	reset_control_assert(priv->rst);
> >>  	clk_disable_unprepare(priv->clk);
> >>  	clk_disable_unprepare(priv->clk_iface);
> >> -
> >> -	sdhci_pltfm_unregister(pdev);
> >>  }
> >>  
> >>  #ifdef CONFIG_OF
> > 
> 
> So it needs to end up looking something like below, right?
> 
> diff --git a/drivers/mmc/host/sdhci_f_sdh30.c b/drivers/mmc/host/sdhci_f_sdh30.c
> index 840084ee72e6..47ae853f51aa 100644
> --- a/drivers/mmc/host/sdhci_f_sdh30.c
> +++ b/drivers/mmc/host/sdhci_f_sdh30.c
> @@ -210,12 +210,15 @@ static void sdhci_f_sdh30_remove(struct platform_device *pdev)
>  {
>  	struct sdhci_host *host = platform_get_drvdata(pdev);
>  	struct f_sdhost_priv *priv = sdhci_f_sdhost_priv(host);
> -
> -	reset_control_assert(priv->rst);
> -	clk_disable_unprepare(priv->clk);
> -	clk_disable_unprepare(priv->clk_iface);
> +	struct clk *clk_iface = priv->clk_iface;
> +	struct reset_control *rst = priv->rst;
> +	struct clk *clk = priv->clk;
>  
>  	sdhci_pltfm_unregister(pdev);
> +
> +	reset_control_assert(rst);
> +	clk_disable_unprepare(clk);
> +	clk_disable_unprepare(clk_iface);
>  }

Looks right to me.

Best regards
Uwe
  

Patch

diff --git a/drivers/mmc/host/sdhci_f_sdh30.c b/drivers/mmc/host/sdhci_f_sdh30.c
index 840084ee72e6..964fa18a61a4 100644
--- a/drivers/mmc/host/sdhci_f_sdh30.c
+++ b/drivers/mmc/host/sdhci_f_sdh30.c
@@ -211,11 +211,11 @@  static void sdhci_f_sdh30_remove(struct platform_device *pdev)
 	struct sdhci_host *host = platform_get_drvdata(pdev);
 	struct f_sdhost_priv *priv = sdhci_f_sdhost_priv(host);
 
+	sdhci_pltfm_unregister(pdev);
+
 	reset_control_assert(priv->rst);
 	clk_disable_unprepare(priv->clk);
 	clk_disable_unprepare(priv->clk_iface);
-
-	sdhci_pltfm_unregister(pdev);
 }
 
 #ifdef CONFIG_OF