mmc: sdhci-pltfm: Minor clean up
Subsystems (12)
Adrian Hunter
maintainercover mmc: sdhci-pltfm: Minor clean up
Hi
sdhci_pltfm_unregister() does:
clk_disable_unprepare(pltfm_host->clk)
which prevents drivers from using devm_clk_get_enabled() or similar.
Move it out, and where drivers are doing devm_clk_get*() immediately followed by clk_prepare_enable(), combine them into devm_clk_get_*enabled().
sdhci_pltfm_register() and sdhci_pltfm_unregister() are not paired functions. That are just helpers and effectively get renamed:
sdhci_pltfm_register() -> sdhci_pltfm_init_and_add_host() sdhci_pltfm_unregister() -> sdhci_pltfm_remove()
Please note, the patches are based on top of some "Convert to platform remove callback returning void" patches by Yangtao Li, which were posted here:
https://lore.kernel.org/linux-mmc/[email protected]/
Patches can also be found here:
https://github.com/ahunter6/linux/commits/sdhci-pltfm-cleanup-1
Adrian Hunter (16):
mmc: sdhci-pltfm: Add sdhci_pltfm_remove()
mmc: sdhci-bcm-kona: Use sdhci_pltfm_remove()
mmc: sdhci-brcmstb: Use sdhci_pltfm_remove()
mmc: sdhci-cadence: Use sdhci_pltfm_remove()
mmc: sdhci-dove: Use sdhci_pltfm_remove()
mmc: sdhci_f_sdh30: Use sdhci_pltfm_remove()
mmc: sdhci-iproc: Use sdhci_pltfm_remove()
mmc: sdhci-of-arasan: Use sdhci_pltfm_remove()
mmc: sdhci-of-at91: Use sdhci_pltfm_remove()
mmc: sdhci-of-esdhc: Use sdhci_pltfm_remove()
mmc: sdhci-of-hlwd: Use sdhci_pltfm_remove()
mmc: sdhci-of-sparx5: Use sdhci_pltfm_remove()
mmc: sdhci-pxav2: Use sdhci_pltfm_remove()
mmc: sdhci-st: Use sdhci_pltfm_remove()
mmc: sdhci-pltfm: Remove sdhci_pltfm_unregister()
mmc: sdhci-pltfm: Rename sdhci_pltfm_register()
drivers/mmc/host/sdhci-bcm-kona.c | 12 +++++++++++- drivers/mmc/host/sdhci-brcmstb.c | 18 +++++------------- drivers/mmc/host/sdhci-cadence.c | 17 ++++------------- drivers/mmc/host/sdhci-dove.c | 8 ++------ drivers/mmc/host/sdhci-iproc.c | 14 +++----------- drivers/mmc/host/sdhci-of-arasan.c | 4 +++- drivers/mmc/host/sdhci-of-at91.c | 2 +- drivers/mmc/host/sdhci-of-esdhc.c | 2 +- drivers/mmc/host/sdhci-of-hlwd.c | 4 ++-- drivers/mmc/host/sdhci-of-sparx5.c | 17 ++++++----------- drivers/mmc/host/sdhci-pltfm.c | 14 ++++++-------- drivers/mmc/host/sdhci-pltfm.h | 8 ++++---- drivers/mmc/host/sdhci-pxav2.c | 19 ++++++------------- drivers/mmc/host/sdhci-st.c | 4 +++- drivers/mmc/host/sdhci_f_sdh30.c | 2 +- 15 files changed, 58 insertions(+), 87 deletions(-)
Regards
Adrian
Adrian Hunter
maintainerPATCH 1/16 mmc: sdhci-pltfm: Add sdhci_pltfm_remove()
Add sdhci_pltfm_remove() to replace sdhci_pltfm_unregister(). The difference is that sdhci_pltfm_remove() does not do:
clk_disable_unprepare(pltfm_host->clk);
which allows drivers to choose to use devm_clk_get_enabled() or similar, for pltfm_host->clk.
Once all drivers using sdhci_pltfm_unregister() have been amended to use sdhci_pltfm_remove() instead, sdhci_pltfm_unregister() will be removed.
--- drivers/mmc/host/sdhci-pltfm.c | 10 ++++++++++ drivers/mmc/host/sdhci-pltfm.h | 1 + 2 files changed, 11 insertions(+)
drivers/mmc/host/sdhci-pltfm.c +10 -0
@@ -199,6 +199,16 @@ void sdhci_pltfm_unregister(struct platform_device *pdev) }EXPORT_SYMBOL_GPL (sdhci_pltfm_unregister); +void sdhci_pltfm_remove (struct platform_device *pdev) +{ +struct sdhci_host *host =platform_get_drvdata (pdev); +int dead = (readl (host->ioaddr +SDHCI_INT_STATUS ) ==0xffffffff ); + +sdhci_remove_host (host, dead); +sdhci_pltfm_free (pdev); +} +EXPORT_SYMBOL_GPL (sdhci_pltfm_remove); +#ifdef CONFIG_PM_SLEEP int sdhci_pltfm_suspend (struct device *dev) {
drivers/mmc/host/sdhci-pltfm.h +1 -0
@@ -103,6 +103,7 @@ extern int sdhci_pltfm_register(struct platform_device *pdev,const struct sdhci_pltfm_data *pdata, size_t priv_size);extern void sdhci_pltfm_unregister (struct platform_device *pdev); +extern void sdhci_pltfm_remove (struct platform_device *pdev);extern unsigned int sdhci_pltfm_clk_get_max_clock (struct sdhci_host *host);
Signature · 1 line
2.34.1
Adrian Hunter
maintainerPATCH 2/16 mmc: sdhci-bcm-kona: Use sdhci_pltfm_remove()
In reply to Adrian HunterUse sdhci_pltfm_remove() instead of sdhci_pltfm_unregister() because sdhci_pltfm_unregister() is going to be removed.
--- drivers/mmc/host/sdhci-bcm-kona.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-bcm-kona.c +11 -1
@@ -310,6 +310,16 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)return ret; } +static void sdhci_bcm_kona_remove (struct platform_device *pdev) +{ +struct sdhci_host *host =platform_get_drvdata (pdev); +struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); +struct clk *clk = pltfm_host->clk; + +sdhci_pltfm_remove (pdev); +clk_disable_unprepare (clk); +} +static struct platform_driver sdhci_bcm_kona_driver = { .driver = { .name ="sdhci-kona" ,
@@ -318,7 +328,7 @@ static struct platform_driver sdhci_bcm_kona_driver = { .of_match_table = sdhci_bcm_kona_of_match, }, .probe = sdhci_bcm_kona_probe, - .remove_new = sdhci_pltfm_unregister, + .remove_new = sdhci_bcm_kona_remove, };module_platform_driver (sdhci_bcm_kona_driver);
Signature · 1 line
2.34.1
Adrian Hunter
maintainerPATCH 3/16 mmc: sdhci-brcmstb: Use sdhci_pltfm_remove()
In reply to Adrian HunterUse sdhci_pltfm_remove() instead of sdhci_pltfm_unregister() so that devm_clk_get_optional_enabled() can be used for pltfm_host->clk.
This has the side effect that the order of operations on the error path and remove path is not the same as it was before, but should be safe nevertheless.
--- drivers/mmc/host/sdhci-brcmstb.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
drivers/mmc/host/sdhci-brcmstb.c +5 -13
@@ -264,23 +264,17 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)dev_dbg (&pdev->dev,"Probe found match for %s\n" , match->compatible); - clk =devm_clk_get_optional (&pdev->dev,NULL ); + clk =devm_clk_get_optional_enabled (&pdev->dev,NULL );if (IS_ERR (clk))return dev_err_probe (&pdev->dev,PTR_ERR (clk), -"Failed to get clock from Device Tree\n" ); - - res =clk_prepare_enable (clk); -if (res) -return res; +"Failed to get and enable clock from Device Tree\n" );memset (&brcmstb_pdata,0 ,sizeof (brcmstb_pdata)); brcmstb_pdata.ops = match_priv->ops; host =sdhci_pltfm_init (pdev, &brcmstb_pdata,sizeof (struct sdhci_brcmstb_priv )); -if (IS_ERR (host)) { - res =PTR_ERR (host); - goto err_clk; - } +if (IS_ERR (host)) +return PTR_ERR (host); pltfm_host =sdhci_priv (host); priv =sdhci_pltfm_priv (pltfm_host);
@@ -369,9 +363,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) err:sdhci_pltfm_free (pdev); -err_clk:clk_disable_unprepare (base_clk); -clk_disable_unprepare (clk);return res; }
@@ -430,7 +422,7 @@ static struct platform_driver sdhci_brcmstb_driver = { .of_match_table = of_match_ptr(sdhci_brcm_of_match), }, .probe = sdhci_brcmstb_probe, - .remove_new = sdhci_pltfm_unregister, + .remove_new = sdhci_pltfm_remove, .shutdown = sdhci_brcmstb_shutdown, };
Signature · 7 lines
2.34.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH 03/16] mmc: sdhci-brcmstb: Use sdhci_pltfm_remove()
Quoted 9 lines · Adrian Hunter
Use
sdhci_pltfm_remove()instead ofsdhci_pltfm_unregister()so thatdevm_clk_get_optional_enabled()can be used forpltfm_host->clk.This has the side effect that the order of operations on the error path and remove path is not the same as it was before, but should be safe nevertheless.
Signed-off-by Adrian Hunter <[email protected]>
Quoted 56 lines
--- drivers/mmc/host/sdhci-brcmstb.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)drivers/mmc/host/sdhci-brcmstb.c +5
-14@@ -264,23 +264,17 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev)dev_dbg (&pdev->dev,"Probe found match for %s\n" , match->compatible); - clk =devm_clk_get_optional (&pdev->dev,NULL ); + clk =devm_clk_get_optional_enabled (&pdev->dev,NULL );if (IS_ERR (clk))return dev_err_probe (&pdev->dev,PTR_ERR (clk), -"Failed to get clock from Device Tree\n" ); - - res =clk_prepare_enable (clk); -if (res) -return res; +"Failed to get and enable clock from Device Tree\n" );memset (&brcmstb_pdata,0 ,sizeof (brcmstb_pdata)); brcmstb_pdata.ops = match_priv->ops; host =sdhci_pltfm_init (pdev, &brcmstb_pdata,sizeof (struct sdhci_brcmstb_priv )); -if (IS_ERR (host)) { - res =PTR_ERR (host); - goto err_clk; - } +if (IS_ERR (host)) +return PTR_ERR (host); pltfm_host =sdhci_priv (host); priv =sdhci_pltfm_priv (pltfm_host);@@ -369,9 +363,7 @@ static int sdhci_brcmstb_probe(struct platform_device *pdev) err:sdhci_pltfm_free (pdev); -err_clk:clk_disable_unprepare (base_clk); -clk_disable_unprepare (clk);return res; }@@ -430,7 +422,7 @@ static struct platform_driver sdhci_brcmstb_driver = { .of_match_table = of_match_ptr(sdhci_brcm_of_match), }, .probe = sdhci_brcmstb_probe, - .remove_new = sdhci_pltfm_unregister, + .remove_new = sdhci_pltfm_remove, .shutdown = sdhci_brcmstb_shutdown, }; --
Quoted 2 lines
2.34.1
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Adrian Hunter
maintainerPATCH 4/16 mmc: sdhci-cadence: Use sdhci_pltfm_remove()
In reply to Adrian HunterUse sdhci_pltfm_remove() instead of sdhci_pltfm_unregister() so that devm_clk_get_enabled() can be used for pltfm_host->clk.
This has the side effect that the order of operations on the error path and remove path is not the same as it was before, but should be safe nevertheless.
--- drivers/mmc/host/sdhci-cadence.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
drivers/mmc/host/sdhci-cadence.c +4 -13
@@ -487,14 +487,10 @@ static int sdhci_cdns_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;static const u16 version =SDHCI_SPEC_400 <<SDHCI_SPEC_VER_SHIFT ; - clk =devm_clk_get (dev,NULL ); + clk =devm_clk_get_enabled (dev,NULL );if (IS_ERR (clk))return PTR_ERR (clk); - ret =clk_prepare_enable (clk); -if (ret) -return ret; - data =of_device_get_match_data (dev);if (!data) data = &sdhci_cdns_drv_data;
@@ -502,10 +498,8 @@ static int sdhci_cdns_probe(struct platform_device *pdev) nr_phy_params =sdhci_cdns_phy_param_count (dev->of_node); host =sdhci_pltfm_init (pdev, &data->pltfm_data,struct_size (priv, phy_params, nr_phy_params)); -if (IS_ERR (host)) { - ret =PTR_ERR (host); - goto disable_clk; - } +if (IS_ERR (host)) +return PTR_ERR (host); pltfm_host =sdhci_priv (host); pltfm_host->clk = clk;
@@ -556,9 +550,6 @@ static int sdhci_cdns_probe(struct platform_device *pdev)return 0 ; free:sdhci_pltfm_free (pdev); -disable_clk: -clk_disable_unprepare (clk); -return ret; }
@@ -617,7 +608,7 @@ static struct platform_driver sdhci_cdns_driver = { .of_match_table = sdhci_cdns_match, }, .probe = sdhci_cdns_probe, - .remove_new = sdhci_pltfm_unregister, + .remove_new = sdhci_pltfm_remove, };module_platform_driver (sdhci_cdns_driver);
Signature · 7 lines
2.34.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Adrian Hunter
maintainerPATCH 5/16 mmc: sdhci-dove: Use sdhci_pltfm_remove()
In reply to Adrian HunterUse sdhci_pltfm_remove() instead of sdhci_pltfm_unregister() so that devm_clk_get_enabled() can be used for pltfm_host->clk.
This has the side effect that the order of operations on the error path and remove path is not the same as it was before, but should be safe nevertheless.
--- drivers/mmc/host/sdhci-dove.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/mmc/host/sdhci-dove.c +2 -6
@@ -75,10 +75,7 @@ static int sdhci_dove_probe(struct platform_device *pdev)return PTR_ERR (host); pltfm_host =sdhci_priv (host); - pltfm_host->clk =devm_clk_get (&pdev->dev,NULL ); - -if (!IS_ERR (pltfm_host->clk)) -clk_prepare_enable (pltfm_host->clk); + pltfm_host->clk =devm_clk_get_enabled (&pdev->dev,NULL ); ret =mmc_of_parse (host->mmc);if (ret)
@@ -91,7 +88,6 @@ static int sdhci_dove_probe(struct platform_device *pdev)return 0 ; err_sdhci_add: -clk_disable_unprepare (pltfm_host->clk);sdhci_pltfm_free (pdev);return ret; }
@@ -110,7 +106,7 @@ static struct platform_driver sdhci_dove_driver = { .of_match_table = sdhci_dove_of_match_table, }, .probe = sdhci_dove_probe, - .remove_new = sdhci_pltfm_unregister, + .remove_new = sdhci_pltfm_remove, };module_platform_driver (sdhci_dove_driver);
Signature · 7 lines
2.34.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Adrian Hunter
maintainerPATCH 6/16 mmc: sdhci_f_sdh30: Use sdhci_pltfm_remove()
In reply to Adrian HunterUse sdhci_pltfm_remove() instead of sdhci_pltfm_unregister() because sdhci_pltfm_unregister() is going to be removed.
--- drivers/mmc/host/sdhci_f_sdh30.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci_f_sdh30.c +1 -1
@@ -214,7 +214,7 @@ static void sdhci_f_sdh30_remove(struct platform_device *pdev)struct reset_control *rst = priv->rst;struct clk *clk = priv->clk; -sdhci_pltfm_unregister (pdev); +sdhci_pltfm_remove (pdev);reset_control_assert (rst);clk_disable_unprepare (clk);
Signature · 7 lines
2.34.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Adrian Hunter
maintainerPATCH 7/16 mmc: sdhci-iproc: Use sdhci_pltfm_remove()
In reply to Adrian HunterUse sdhci_pltfm_remove() instead of sdhci_pltfm_unregister() so that devm_clk_get_enabled() can be used for pltfm_host->clk.
This has the side effect that the order of operations on the error path and remove path is not the same as it was before, but should be safe nevertheless.
--- drivers/mmc/host/sdhci-iproc.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
drivers/mmc/host/sdhci-iproc.c +3 -11
@@ -386,16 +386,11 @@ static int sdhci_iproc_probe(struct platform_device *pdev) host->mmc->caps |= iproc_host->data->mmc_caps;if (dev->of_node) { - pltfm_host->clk =devm_clk_get (dev,NULL ); + pltfm_host->clk =devm_clk_get_enabled (dev,NULL );if (IS_ERR (pltfm_host->clk)) { ret =PTR_ERR (pltfm_host->clk); goto err; } - ret =clk_prepare_enable (pltfm_host->clk); -if (ret) { -dev_err (dev,"failed to enable host clk\n" ); - goto err; - } }if (iproc_host->data->missing_caps) {
@@ -406,13 +401,10 @@ static int sdhci_iproc_probe(struct platform_device *pdev) ret =sdhci_add_host (host);if (ret) - goto err_clk; + goto err;return 0 ; -err_clk: -if (dev->of_node) -clk_disable_unprepare (pltfm_host->clk); err:sdhci_pltfm_free (pdev);return ret;
@@ -432,7 +424,7 @@ static struct platform_driver sdhci_iproc_driver = { .pm = &sdhci_pltfm_pmops, }, .probe = sdhci_iproc_probe, - .remove_new = sdhci_pltfm_unregister, + .remove_new = sdhci_pltfm_remove, .shutdown = sdhci_iproc_shutdown, };module_platform_driver (sdhci_iproc_driver);
Signature · 7 lines
2.34.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Adrian Hunter
maintainerPATCH 8/16 mmc: sdhci-of-arasan: Use sdhci_pltfm_remove()
In reply to Adrian HunterUse sdhci_pltfm_remove() instead of sdhci_pltfm_unregister() because sdhci_pltfm_unregister() is going to be removed.
--- drivers/mmc/host/sdhci-of-arasan.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-of-arasan.c +3 -1
@@ -2022,6 +2022,7 @@ static void sdhci_arasan_remove(struct platform_device *pdev)struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct sdhci_arasan_data *sdhci_arasan =sdhci_pltfm_priv (pltfm_host);struct clk *clk_ahb = sdhci_arasan->clk_ahb; +struct clk *clk_xin = pltfm_host->clk;if (!IS_ERR (sdhci_arasan->phy)) {if (sdhci_arasan->is_phy_on)
@@ -2031,8 +2032,9 @@ static void sdhci_arasan_remove(struct platform_device *pdev)sdhci_arasan_unregister_sdclk (&pdev->dev); -sdhci_pltfm_unregister (pdev); +sdhci_pltfm_remove (pdev); +clk_disable_unprepare (clk_xin);clk_disable_unprepare (clk_ahb); }
Signature · 7 lines
2.34.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Adrian Hunter
maintainerPATCH 9/16 mmc: sdhci-of-at91: Use sdhci_pltfm_remove()
In reply to Adrian HunterUse sdhci_pltfm_remove() instead of sdhci_pltfm_unregister() because sdhci_pltfm_unregister() is going to be removed.
--- drivers/mmc/host/sdhci-of-at91.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-of-at91.c +1 -1
@@ -456,7 +456,7 @@ static void sdhci_at91_remove(struct platform_device *pdev)pm_runtime_disable (&pdev->dev);pm_runtime_put_noidle (&pdev->dev); -sdhci_pltfm_unregister (pdev); +sdhci_pltfm_remove (pdev);clk_disable_unprepare (gck);clk_disable_unprepare (hclock);
Signature · 7 lines
2.34.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Adrian Hunter
maintainerPATCH 10/16 mmc: sdhci-of-esdhc: Use sdhci_pltfm_remove()
In reply to Adrian HunterUse sdhci_pltfm_remove() instead of sdhci_pltfm_unregister() because sdhci_pltfm_unregister() is going to be removed.
--- drivers/mmc/host/sdhci-of-esdhc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-of-esdhc.c +1 -1
@@ -1521,7 +1521,7 @@ static struct platform_driver sdhci_esdhc_driver = { .pm = &esdhc_of_dev_pm_ops, }, .probe = sdhci_esdhc_probe, - .remove_new = sdhci_pltfm_unregister, + .remove_new = sdhci_pltfm_remove, };module_platform_driver (sdhci_esdhc_driver);
Signature · 7 lines
2.34.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Adrian Hunter
maintainerPATCH 11/16 mmc: sdhci-of-hlwd: Use sdhci_pltfm_remove()
In reply to Adrian HunterUse sdhci_pltfm_remove() instead of sdhci_pltfm_unregister() because sdhci_pltfm_unregister() is going to be removed.
--- drivers/mmc/host/sdhci-of-hlwd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/sdhci-of-hlwd.c +1 -1
@@ -85,7 +85,7 @@ static struct platform_driver sdhci_hlwd_driver = { .pm = &sdhci_pltfm_pmops, }, .probe = sdhci_hlwd_probe, - .remove_new = sdhci_pltfm_unregister, + .remove_new = sdhci_pltfm_remove, };module_platform_driver (sdhci_hlwd_driver);
Signature · 7 lines
2.34.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Adrian Hunter
maintainerPATCH 12/16 mmc: sdhci-of-sparx5: Use sdhci_pltfm_remove()
In reply to Adrian HunterUse sdhci_pltfm_remove() instead of sdhci_pltfm_unregister() so that devm_clk_get_enabled() can be used for pltfm_host->clk.
This has the side effect that the order of operations on the error path and remove path is not the same as it was before, but should be safe nevertheless.
--- drivers/mmc/host/sdhci-of-sparx5.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
drivers/mmc/host/sdhci-of-sparx5.c +6 -11
@@ -184,15 +184,12 @@ static int sdhci_sparx5_probe(struct platform_device *pdev) sdhci_sparx5 =sdhci_pltfm_priv (pltfm_host); sdhci_sparx5->host = host; - pltfm_host->clk =devm_clk_get (&pdev->dev,"core" ); + pltfm_host->clk =devm_clk_get_enabled (&pdev->dev,"core" );if (IS_ERR (pltfm_host->clk)) { ret =PTR_ERR (pltfm_host->clk); -dev_err (&pdev->dev,"failed to get core clk: %d\n" , ret); +dev_err (&pdev->dev,"failed to get and enable core clk: %d\n" , ret); goto free_pltfm; } - ret =clk_prepare_enable (pltfm_host->clk); -if (ret) - goto free_pltfm;if (!of_property_read_u32 (np,"microchip,clock-delay" , &value) && (value >0 && value <=MSHC_DLY_CC_MAX ))
@@ -202,13 +199,13 @@ static int sdhci_sparx5_probe(struct platform_device *pdev) ret =mmc_of_parse (host->mmc);if (ret) - goto err_clk; + goto free_pltfm; sdhci_sparx5->cpu_ctrl =syscon_regmap_lookup_by_compatible (syscon);if (IS_ERR (sdhci_sparx5->cpu_ctrl)) {dev_err (&pdev->dev,"No CPU syscon regmap !\n" ); ret =PTR_ERR (sdhci_sparx5->cpu_ctrl); - goto err_clk; + goto free_pltfm; }if (sdhci_sparx5->delay_clock >=0 )
@@ -225,7 +222,7 @@ static int sdhci_sparx5_probe(struct platform_device *pdev) ret =sdhci_add_host (host);if (ret) - goto err_clk; + goto free_pltfm;/* Set AXI bus master to use un-cached access (for DMA) */ if (host->flags & (SDHCI_USE_SDMA | SDHCI_USE_ADMA) &&
@@ -239,8 +236,6 @@ static int sdhci_sparx5_probe(struct platform_device *pdev)return ret; -err_clk: -clk_disable_unprepare (pltfm_host->clk); free_pltfm:sdhci_pltfm_free (pdev);return ret;
@@ -260,7 +255,7 @@ static struct platform_driver sdhci_sparx5_driver = { .pm = &sdhci_pltfm_pmops, }, .probe = sdhci_sparx5_probe, - .remove_new = sdhci_pltfm_unregister, + .remove_new = sdhci_pltfm_remove, };module_platform_driver (sdhci_sparx5_driver);
Signature · 7 lines
2.34.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Adrian Hunter
maintainerPATCH 13/16 mmc: sdhci-pxav2: Use sdhci_pltfm_remove()
In reply to Adrian HunterUse sdhci_pltfm_remove() instead of sdhci_pltfm_unregister() so that devm_clk_get_enabled() can be used for pltfm_host->clk.
This has the side effect that the order of operations on the error path and remove path is not the same as it was before, but should be safe nevertheless.
--- drivers/mmc/host/sdhci-pxav2.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-)
drivers/mmc/host/sdhci-pxav2.c +6 -13
@@ -268,26 +268,21 @@ static int sdhci_pxav2_probe(struct platform_device *pdev) pltfm_host =sdhci_priv (host); pxav2_host =sdhci_pltfm_priv (pltfm_host); - clk =devm_clk_get (dev,"io" ); -if (IS_ERR (clk) &&PTR_ERR (clk) != -EPROBE_DEFER ) - clk =devm_clk_get (dev,NULL ); + clk =devm_clk_get_optional_enabled (dev,"io" ); +if (!clk) + clk =devm_clk_get_enabled (dev,NULL );if (IS_ERR (clk)) { ret =PTR_ERR (clk);dev_err_probe (dev, ret,"failed to get io clock\n" ); goto free; } pltfm_host->clk = clk; - ret =clk_prepare_enable (clk); -if (ret) { -dev_err (dev,"failed to enable io clock\n" ); - goto free; - } clk_core =devm_clk_get_optional_enabled (dev,"core" );if (IS_ERR (clk_core)) { ret =PTR_ERR (clk_core);dev_err_probe (dev, ret,"failed to enable core clock\n" ); - goto disable_clk; + goto free; } host->quirks =SDHCI_QUIRK_BROKEN_ADMA
@@ -339,12 +334,10 @@ static int sdhci_pxav2_probe(struct platform_device *pdev) ret =sdhci_add_host (host);if (ret) - goto disable_clk; + goto free;return 0 ; -disable_clk: -clk_disable_unprepare (clk); free:sdhci_pltfm_free (pdev);return ret;
@@ -358,7 +351,7 @@ static struct platform_driver sdhci_pxav2_driver = { .pm = &sdhci_pltfm_pmops, }, .probe = sdhci_pxav2_probe, - .remove_new = sdhci_pltfm_unregister, + .remove_new = sdhci_pltfm_remove, };module_platform_driver (sdhci_pxav2_driver);
Signature · 7 lines
2.34.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Adrian Hunter
maintainerPATCH 14/16 mmc: sdhci-st: Use sdhci_pltfm_remove()
In reply to Adrian HunterUse sdhci_pltfm_remove() instead of sdhci_pltfm_unregister() because sdhci_pltfm_unregister() is going to be removed.
--- drivers/mmc/host/sdhci-st.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci-st.c +3 -1
@@ -437,10 +437,12 @@ static void sdhci_st_remove(struct platform_device *pdev)struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host);struct st_mmc_platform_data *pdata =sdhci_pltfm_priv (pltfm_host);struct reset_control *rstc = pdata->rstc; +struct clk *clk = pltfm_host->clk; -sdhci_pltfm_unregister (pdev); +sdhci_pltfm_remove (pdev);clk_disable_unprepare (pdata->icnclk); +clk_disable_unprepare (clk);reset_control_assert (rstc); }
Signature · 7 lines
2.34.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Adrian Hunter
maintainerPATCH 15/16 mmc: sdhci-pltfm: Remove sdhci_pltfm_unregister()
In reply to Adrian HunterNow that sdhci_pltfm_unregister() is unused, remove it.
--- drivers/mmc/host/sdhci-pltfm.c | 12 ------------ drivers/mmc/host/sdhci-pltfm.h | 1 - 2 files changed, 13 deletions(-)
drivers/mmc/host/sdhci-pltfm.c +0 -12
@@ -187,18 +187,6 @@ int sdhci_pltfm_register(struct platform_device *pdev, }EXPORT_SYMBOL_GPL (sdhci_pltfm_register); -void sdhci_pltfm_unregister (struct platform_device *pdev) -{ -struct sdhci_host *host =platform_get_drvdata (pdev); -struct sdhci_pltfm_host *pltfm_host =sdhci_priv (host); -int dead = (readl (host->ioaddr +SDHCI_INT_STATUS ) ==0xffffffff ); - -sdhci_remove_host (host, dead); -clk_disable_unprepare (pltfm_host->clk); -sdhci_pltfm_free (pdev); -} -EXPORT_SYMBOL_GPL (sdhci_pltfm_unregister); -void sdhci_pltfm_remove (struct platform_device *pdev) {struct sdhci_host *host =platform_get_drvdata (pdev);
drivers/mmc/host/sdhci-pltfm.h +0 -1
@@ -102,7 +102,6 @@ extern void sdhci_pltfm_free(struct platform_device *pdev);extern int sdhci_pltfm_register (struct platform_device *pdev,const struct sdhci_pltfm_data *pdata,size_t priv_size); -extern void sdhci_pltfm_unregister (struct platform_device *pdev);extern void sdhci_pltfm_remove (struct platform_device *pdev);extern unsigned int sdhci_pltfm_clk_get_max_clock (struct sdhci_host *host);
Signature · 7 lines
2.34.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Adrian Hunter
maintainerPATCH 16/16 mmc: sdhci-pltfm: Rename sdhci_pltfm_register()
In reply to Adrian HunterNow that sdhci_pltfm_unregister() has been removed, rename sdhci_pltfm_register() to sdhci_pltfm_init_and_add_host() to better reflect what it does.
--- drivers/mmc/host/sdhci-of-hlwd.c | 2 +- drivers/mmc/host/sdhci-pltfm.c | 8 ++++---- drivers/mmc/host/sdhci-pltfm.h | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-)
drivers/mmc/host/sdhci-of-hlwd.c +1 -1
@@ -68,7 +68,7 @@ static const struct sdhci_pltfm_data sdhci_hlwd_pdata = {static int sdhci_hlwd_probe (struct platform_device *pdev) { -return sdhci_pltfm_register (pdev, &sdhci_hlwd_pdata,0 ); +return sdhci_pltfm_init_and_add_host (pdev, &sdhci_hlwd_pdata,0 ); }static const struct of_device_id sdhci_hlwd_of_match[] = {
drivers/mmc/host/sdhci-pltfm.c +4 -4
@@ -166,9 +166,9 @@ void sdhci_pltfm_free(struct platform_device *pdev) }EXPORT_SYMBOL_GPL (sdhci_pltfm_free); -int sdhci_pltfm_register (struct platform_device *pdev, -const struct sdhci_pltfm_data *pdata, -size_t priv_size) +int sdhci_pltfm_init_and_add_host (struct platform_device *pdev, +const struct sdhci_pltfm_data *pdata, +size_t priv_size) {struct sdhci_host *host;int ret =0 ;
@@ -185,7 +185,7 @@ int sdhci_pltfm_register(struct platform_device *pdev,return ret; } -EXPORT_SYMBOL_GPL (sdhci_pltfm_register); +EXPORT_SYMBOL_GPL (sdhci_pltfm_init_and_add_host);void sdhci_pltfm_remove (struct platform_device *pdev) {
drivers/mmc/host/sdhci-pltfm.h +3 -3
@@ -99,9 +99,9 @@ extern struct sdhci_host *sdhci_pltfm_init(struct platform_device *pdev, size_t priv_size);extern void sdhci_pltfm_free (struct platform_device *pdev); -extern int sdhci_pltfm_register (struct platform_device *pdev, -const struct sdhci_pltfm_data *pdata, -size_t priv_size); +extern int sdhci_pltfm_init_and_add_host (struct platform_device *pdev, +const struct sdhci_pltfm_data *pdata, +size_t priv_size);extern void sdhci_pltfm_remove (struct platform_device *pdev);extern unsigned int sdhci_pltfm_clk_get_max_clock (struct sdhci_host *host);
Signature · 7 lines
2.34.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 21 lines · Adrian Hunter
Hi
sdhci_pltfm_unregister()does:clk_disable_unprepare(pltfm_host->clk)which prevents drivers from using
devm_clk_get_enabled()or similar.Move it out, and where drivers are doing devm_clk_get*() immediately followed by
clk_prepare_enable(), combine them into devm_clk_get_*enabled().
sdhci_pltfm_register()andsdhci_pltfm_unregister()are not paired functions. That are just helpers and effectively get renamed:sdhci_pltfm_register() -> sdhci_pltfm_init_and_add_host() sdhci_pltfm_unregister() -> sdhci_pltfm_remove()Please note, the patches are based on top of some "Convert to platform remove callback returning void" patches by Yangtao Li, which were posted here:
Quoted 5 lines
https://lore.kernel.org/linux-mmc/[email protected]/Patches can also be found here:
https://github.com/ahunter6/linux/commits/sdhci-pltfm-cleanup-1
All look good to me, thanks!
Quoted 38 lines
Adrian Hunter (16):
mmc: sdhci-pltfm: Addsdhci_pltfm_remove()
mmc: sdhci-bcm-kona: Usesdhci_pltfm_remove()
mmc: sdhci-brcmstb: Usesdhci_pltfm_remove()
mmc: sdhci-cadence: Usesdhci_pltfm_remove()
mmc: sdhci-dove: Usesdhci_pltfm_remove()
mmc:sdhci_f_sdh30: Usesdhci_pltfm_remove()
mmc: sdhci-iproc: Usesdhci_pltfm_remove()
mmc: sdhci-of-arasan: Usesdhci_pltfm_remove()
mmc: sdhci-of-at91: Usesdhci_pltfm_remove()
mmc: sdhci-of-esdhc: Usesdhci_pltfm_remove()
mmc: sdhci-of-hlwd: Usesdhci_pltfm_remove()
mmc: sdhci-of-sparx5: Usesdhci_pltfm_remove()
mmc: sdhci-pxav2: Usesdhci_pltfm_remove()
mmc: sdhci-st: Usesdhci_pltfm_remove()
mmc: sdhci-pltfm: Removesdhci_pltfm_unregister()
mmc: sdhci-pltfm: Renamesdhci_pltfm_register()drivers/mmc/host/sdhci-bcm-kona.c | 12 +++++++++++- drivers/mmc/host/sdhci-brcmstb.c | 18 +++++------------- drivers/mmc/host/sdhci-cadence.c | 17 ++++------------- drivers/mmc/host/sdhci-dove.c | 8 ++------ drivers/mmc/host/sdhci-iproc.c | 14 +++----------- drivers/mmc/host/sdhci-of-arasan.c | 4 +++- drivers/mmc/host/sdhci-of-at91.c | 2 +- drivers/mmc/host/sdhci-of-esdhc.c | 2 +- drivers/mmc/host/sdhci-of-hlwd.c | 4 ++-- drivers/mmc/host/sdhci-of-sparx5.c | 17 ++++++----------- drivers/mmc/host/sdhci-pltfm.c | 14 ++++++-------- drivers/mmc/host/sdhci-pltfm.h | 8 ++++---- drivers/mmc/host/sdhci-pxav2.c | 19 ++++++------------- drivers/mmc/host/sdhci-st.c | 4 +++- drivers/mmc/host/sdhci_f_sdh30.c | 2 +- 15 files changed, 58 insertions(+), 87 deletions(-)Regards
Adrian
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 47 lines · Adrian Hunter
Hi
sdhci_pltfm_unregister()does:clk_disable_unprepare(pltfm_host->clk)which prevents drivers from using
devm_clk_get_enabled()or similar.Move it out, and where drivers are doing devm_clk_get*() immediately followed by
clk_prepare_enable(), combine them into devm_clk_get_*enabled().
sdhci_pltfm_register()andsdhci_pltfm_unregister()are not paired functions. That are just helpers and effectively get renamed:sdhci_pltfm_register() -> sdhci_pltfm_init_and_add_host() sdhci_pltfm_unregister() -> sdhci_pltfm_remove()Please note, the patches are based on top of some "Convert to platform remove callback returning void" patches by Yangtao Li, which were posted here:
https://lore.kernel.org/linux-mmc/[email protected]/Patches can also be found here:
https://github.com/ahunter6/linux/commits/sdhci-pltfm-cleanup-1
Adrian Hunter (16):
mmc: sdhci-pltfm: Addsdhci_pltfm_remove()
mmc: sdhci-bcm-kona: Usesdhci_pltfm_remove()
mmc: sdhci-brcmstb: Usesdhci_pltfm_remove()
mmc: sdhci-cadence: Usesdhci_pltfm_remove()
mmc: sdhci-dove: Usesdhci_pltfm_remove()
mmc:sdhci_f_sdh30: Usesdhci_pltfm_remove()
mmc: sdhci-iproc: Usesdhci_pltfm_remove()
mmc: sdhci-of-arasan: Usesdhci_pltfm_remove()
mmc: sdhci-of-at91: Usesdhci_pltfm_remove()
mmc: sdhci-of-esdhc: Usesdhci_pltfm_remove()
mmc: sdhci-of-hlwd: Usesdhci_pltfm_remove()
mmc: sdhci-of-sparx5: Usesdhci_pltfm_remove()
mmc: sdhci-pxav2: Usesdhci_pltfm_remove()
mmc: sdhci-st: Usesdhci_pltfm_remove()
mmc: sdhci-pltfm: Removesdhci_pltfm_unregister()
mmc: sdhci-pltfm: Renamesdhci_pltfm_register()
Quoted 18 lines
drivers/mmc/host/sdhci-bcm-kona.c | 12 +++++++++++- drivers/mmc/host/sdhci-brcmstb.c | 18 +++++------------- drivers/mmc/host/sdhci-cadence.c | 17 ++++------------- drivers/mmc/host/sdhci-dove.c | 8 ++------ drivers/mmc/host/sdhci-iproc.c | 14 +++----------- drivers/mmc/host/sdhci-of-arasan.c | 4 +++- drivers/mmc/host/sdhci-of-at91.c | 2 +- drivers/mmc/host/sdhci-of-esdhc.c | 2 +- drivers/mmc/host/sdhci-of-hlwd.c | 4 ++-- drivers/mmc/host/sdhci-of-sparx5.c | 17 ++++++----------- drivers/mmc/host/sdhci-pltfm.c | 14 ++++++-------- drivers/mmc/host/sdhci-pltfm.h | 8 ++++---- drivers/mmc/host/sdhci-pxav2.c | 19 ++++++------------- drivers/mmc/host/sdhci-st.c | 4 +++- drivers/mmc/host/sdhci_f_sdh30.c | 2 +- 15 files changed, 58 insertions(+), 87 deletions(-)
Applied for next, thanks!
Kind regards
Uffe
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel