* [PATCH 0/7] mmc: sdhci: set .remove to sdhci_pltfm_unregister()
@ 2015-02-06 3:15 Kevin Hao
2015-02-06 3:15 ` [PATCH 1/7] mmc: sdhci-dove: remove the unneeded error check Kevin Hao
` (6 more replies)
0 siblings, 7 replies; 10+ messages in thread
From: Kevin Hao @ 2015-02-06 3:15 UTC (permalink / raw)
To: linux-mmc; +Cc: Chris Ball, Ulf Hansson
Hi,
In the current kernel, the specific .remove function in several sdhci platform
drivers seem pretty similar. Actually we can just set all of them to
sdhci_pltfm_unregister() with just a bit twist.
Only run test for sdhci-of-esdhc driver. All others just passed the build test.
Kevin Hao (7):
mmc: sdhci-dove: remove the unneeded error check
mmc: sdhci-dove: kill the driver specific private struct
mmc: tegra: use devm help functions to get the clk and gpio
mmc: sdhci-sirf: kill the "clk" member in driver private struct
mmc: sdhci-bcm-kona: kill the "external_clk" member in driver private
struct
mmc: sdhci: disable the clock in sdhci_pltfm_unregister()
mmc: sdhci: set the .remove to sdhci_pltfm_unregister()
drivers/mmc/host/sdhci-bcm-kona.c | 31 +++++++-----------------------
drivers/mmc/host/sdhci-bcm2835.c | 7 +------
drivers/mmc/host/sdhci-cns3xxx.c | 7 +------
drivers/mmc/host/sdhci-dove.c | 39 +++++---------------------------------
drivers/mmc/host/sdhci-of-arasan.c | 1 -
drivers/mmc/host/sdhci-of-esdhc.c | 7 +------
drivers/mmc/host/sdhci-of-hlwd.c | 7 +------
drivers/mmc/host/sdhci-pltfm.c | 2 ++
drivers/mmc/host/sdhci-sirf.c | 30 +++++++----------------------
drivers/mmc/host/sdhci-st.c | 12 +-----------
drivers/mmc/host/sdhci-tegra.c | 30 ++++-------------------------
11 files changed, 30 insertions(+), 143 deletions(-)
--
1.9.3
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/7] mmc: sdhci-dove: remove the unneeded error check
2015-02-06 3:15 [PATCH 0/7] mmc: sdhci: set .remove to sdhci_pltfm_unregister() Kevin Hao
@ 2015-02-06 3:15 ` Kevin Hao
2015-02-06 3:15 ` [PATCH 2/7] mmc: sdhci-dove: kill the driver specific private struct Kevin Hao
` (5 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Kevin Hao @ 2015-02-06 3:15 UTC (permalink / raw)
To: linux-mmc; +Cc: Chris Ball, Ulf Hansson, Kevin Hao
The function clk_disable_unprepare() already take care of either error
or null cases.
Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
drivers/mmc/host/sdhci-dove.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/mmc/host/sdhci-dove.c b/drivers/mmc/host/sdhci-dove.c
index ca969d271a27..0a7aeb162497 100644
--- a/drivers/mmc/host/sdhci-dove.c
+++ b/drivers/mmc/host/sdhci-dove.c
@@ -117,8 +117,7 @@ static int sdhci_dove_probe(struct platform_device *pdev)
return 0;
err_sdhci_add:
- if (!IS_ERR(priv->clk))
- clk_disable_unprepare(priv->clk);
+ clk_disable_unprepare(priv->clk);
sdhci_pltfm_free(pdev);
return ret;
}
@@ -131,8 +130,7 @@ static int sdhci_dove_remove(struct platform_device *pdev)
sdhci_pltfm_unregister(pdev);
- if (!IS_ERR(priv->clk))
- clk_disable_unprepare(priv->clk);
+ clk_disable_unprepare(priv->clk);
return 0;
}
--
1.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/7] mmc: sdhci-dove: kill the driver specific private struct
2015-02-06 3:15 [PATCH 0/7] mmc: sdhci: set .remove to sdhci_pltfm_unregister() Kevin Hao
2015-02-06 3:15 ` [PATCH 1/7] mmc: sdhci-dove: remove the unneeded error check Kevin Hao
@ 2015-02-06 3:15 ` Kevin Hao
2015-02-06 3:15 ` [PATCH 3/7] mmc: tegra: use devm help functions to get the clk and gpio Kevin Hao
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Kevin Hao @ 2015-02-06 3:15 UTC (permalink / raw)
To: linux-mmc; +Cc: Chris Ball, Ulf Hansson, Kevin Hao
There is only one "clk" member in this driver specific private struct.
Actually we can use the "clk" member in the struct sdhci_pltfm_host,
and then kill this struct completely.
Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
drivers/mmc/host/sdhci-dove.c | 26 +++++---------------------
1 file changed, 5 insertions(+), 21 deletions(-)
diff --git a/drivers/mmc/host/sdhci-dove.c b/drivers/mmc/host/sdhci-dove.c
index 0a7aeb162497..f78440ef1ba4 100644
--- a/drivers/mmc/host/sdhci-dove.c
+++ b/drivers/mmc/host/sdhci-dove.c
@@ -28,10 +28,6 @@
#include "sdhci-pltfm.h"
-struct sdhci_dove_priv {
- struct clk *clk;
-};
-
static u16 sdhci_dove_readw(struct sdhci_host *host, int reg)
{
u16 ret;
@@ -84,27 +80,17 @@ static int sdhci_dove_probe(struct platform_device *pdev)
{
struct sdhci_host *host;
struct sdhci_pltfm_host *pltfm_host;
- struct sdhci_dove_priv *priv;
int ret;
- priv = devm_kzalloc(&pdev->dev, sizeof(struct sdhci_dove_priv),
- GFP_KERNEL);
- if (!priv) {
- dev_err(&pdev->dev, "unable to allocate private data");
- return -ENOMEM;
- }
-
- priv->clk = devm_clk_get(&pdev->dev, NULL);
-
host = sdhci_pltfm_init(pdev, &sdhci_dove_pdata, 0);
if (IS_ERR(host))
return PTR_ERR(host);
pltfm_host = sdhci_priv(host);
- pltfm_host->priv = priv;
+ pltfm_host->clk = devm_clk_get(&pdev->dev, NULL);
- if (!IS_ERR(priv->clk))
- clk_prepare_enable(priv->clk);
+ if (!IS_ERR(pltfm_host->clk))
+ clk_prepare_enable(pltfm_host->clk);
ret = mmc_of_parse(host->mmc);
if (ret)
@@ -117,7 +103,7 @@ static int sdhci_dove_probe(struct platform_device *pdev)
return 0;
err_sdhci_add:
- clk_disable_unprepare(priv->clk);
+ clk_disable_unprepare(pltfm_host->clk);
sdhci_pltfm_free(pdev);
return ret;
}
@@ -126,12 +112,10 @@ static int sdhci_dove_remove(struct platform_device *pdev)
{
struct sdhci_host *host = platform_get_drvdata(pdev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
- struct sdhci_dove_priv *priv = pltfm_host->priv;
+ clk_disable_unprepare(pltfm_host->clk);
sdhci_pltfm_unregister(pdev);
- clk_disable_unprepare(priv->clk);
-
return 0;
}
--
1.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/7] mmc: tegra: use devm help functions to get the clk and gpio
2015-02-06 3:15 [PATCH 0/7] mmc: sdhci: set .remove to sdhci_pltfm_unregister() Kevin Hao
2015-02-06 3:15 ` [PATCH 1/7] mmc: sdhci-dove: remove the unneeded error check Kevin Hao
2015-02-06 3:15 ` [PATCH 2/7] mmc: sdhci-dove: kill the driver specific private struct Kevin Hao
@ 2015-02-06 3:15 ` Kevin Hao
2015-02-06 3:15 ` [PATCH 4/7] mmc: sdhci-sirf: kill the "clk" member in driver private struct Kevin Hao
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Kevin Hao @ 2015-02-06 3:15 UTC (permalink / raw)
To: linux-mmc; +Cc: Chris Ball, Ulf Hansson, linux-tegra, Kevin Hao
Simplify the error and remove path.
Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
drivers/mmc/host/sdhci-tegra.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index f3778d58d1cd..0643f66b4e14 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -286,7 +286,8 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
goto err_parse_dt;
if (gpio_is_valid(tegra_host->power_gpio)) {
- rc = gpio_request(tegra_host->power_gpio, "sdhci_power");
+ rc = devm_gpio_request(&pdev->dev, tegra_host->power_gpio,
+ "sdhci_power");
if (rc) {
dev_err(mmc_dev(host->mmc),
"failed to allocate power gpio\n");
@@ -295,7 +296,7 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
gpio_direction_output(tegra_host->power_gpio, 1);
}
- clk = clk_get(mmc_dev(host->mmc), NULL);
+ clk = devm_clk_get(mmc_dev(host->mmc), NULL);
if (IS_ERR(clk)) {
dev_err(mmc_dev(host->mmc), "clk err\n");
rc = PTR_ERR(clk);
@@ -312,10 +313,7 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
err_add_host:
clk_disable_unprepare(pltfm_host->clk);
- clk_put(pltfm_host->clk);
err_clk_get:
- if (gpio_is_valid(tegra_host->power_gpio))
- gpio_free(tegra_host->power_gpio);
err_power_req:
err_parse_dt:
err_alloc_tegra_host:
@@ -327,16 +325,11 @@ static int sdhci_tegra_remove(struct platform_device *pdev)
{
struct sdhci_host *host = platform_get_drvdata(pdev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
- struct sdhci_tegra *tegra_host = pltfm_host->priv;
int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
sdhci_remove_host(host, dead);
- if (gpio_is_valid(tegra_host->power_gpio))
- gpio_free(tegra_host->power_gpio);
-
clk_disable_unprepare(pltfm_host->clk);
- clk_put(pltfm_host->clk);
sdhci_pltfm_free(pdev);
--
1.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 4/7] mmc: sdhci-sirf: kill the "clk" member in driver private struct
2015-02-06 3:15 [PATCH 0/7] mmc: sdhci: set .remove to sdhci_pltfm_unregister() Kevin Hao
` (2 preceding siblings ...)
2015-02-06 3:15 ` [PATCH 3/7] mmc: tegra: use devm help functions to get the clk and gpio Kevin Hao
@ 2015-02-06 3:15 ` Kevin Hao
2015-02-06 3:15 ` [PATCH 5/7] mmc: sdhci-bcm-kona: kill the "external_clk" " Kevin Hao
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Kevin Hao @ 2015-02-06 3:15 UTC (permalink / raw)
To: linux-mmc; +Cc: Chris Ball, Ulf Hansson, Barry Song, Kevin Hao
Actually we can use the "clk" in the struct sdhci_pltfm_host.
Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
drivers/mmc/host/sdhci-sirf.c | 20 +++++++-------------
1 file changed, 7 insertions(+), 13 deletions(-)
diff --git a/drivers/mmc/host/sdhci-sirf.c b/drivers/mmc/host/sdhci-sirf.c
index f6f82ec3618d..51b31208f559 100644
--- a/drivers/mmc/host/sdhci-sirf.c
+++ b/drivers/mmc/host/sdhci-sirf.c
@@ -20,15 +20,13 @@
#define SIRF_TUNING_COUNT 128
struct sdhci_sirf_priv {
- struct clk *clk;
int gpio_cd;
};
static unsigned int sdhci_sirf_get_max_clk(struct sdhci_host *host)
{
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
- struct sdhci_sirf_priv *priv = sdhci_pltfm_priv(pltfm_host);
- return clk_get_rate(priv->clk);
+ return clk_get_rate(pltfm_host->clk);
}
static void sdhci_sirf_set_bus_width(struct sdhci_host *host, int width)
@@ -162,13 +160,13 @@ static int sdhci_sirf_probe(struct platform_device *pdev)
return PTR_ERR(host);
pltfm_host = sdhci_priv(host);
+ pltfm_host->clk = clk;
priv = sdhci_pltfm_priv(pltfm_host);
- priv->clk = clk;
priv->gpio_cd = gpio_cd;
sdhci_get_of_property(pdev);
- ret = clk_prepare_enable(priv->clk);
+ ret = clk_prepare_enable(pltfm_host->clk);
if (ret)
goto err_clk_prepare;
@@ -195,7 +193,7 @@ static int sdhci_sirf_probe(struct platform_device *pdev)
err_request_cd:
sdhci_remove_host(host, 0);
err_sdhci_add:
- clk_disable_unprepare(priv->clk);
+ clk_disable_unprepare(pltfm_host->clk);
err_clk_prepare:
sdhci_pltfm_free(pdev);
return ret;
@@ -205,11 +203,9 @@ static int sdhci_sirf_remove(struct platform_device *pdev)
{
struct sdhci_host *host = platform_get_drvdata(pdev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
- struct sdhci_sirf_priv *priv = sdhci_pltfm_priv(pltfm_host);
+ clk_disable_unprepare(pltfm_host->clk);
sdhci_pltfm_unregister(pdev);
-
- clk_disable_unprepare(priv->clk);
return 0;
}
@@ -218,14 +214,13 @@ static int sdhci_sirf_suspend(struct device *dev)
{
struct sdhci_host *host = dev_get_drvdata(dev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
- struct sdhci_sirf_priv *priv = sdhci_pltfm_priv(pltfm_host);
int ret;
ret = sdhci_suspend_host(host);
if (ret)
return ret;
- clk_disable(priv->clk);
+ clk_disable(pltfm_host->clk);
return 0;
}
@@ -234,10 +229,9 @@ static int sdhci_sirf_resume(struct device *dev)
{
struct sdhci_host *host = dev_get_drvdata(dev);
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
- struct sdhci_sirf_priv *priv = sdhci_pltfm_priv(pltfm_host);
int ret;
- ret = clk_enable(priv->clk);
+ ret = clk_enable(pltfm_host->clk);
if (ret) {
dev_dbg(dev, "Resume: Error enabling clock\n");
return ret;
--
1.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 5/7] mmc: sdhci-bcm-kona: kill the "external_clk" member in driver private struct
2015-02-06 3:15 [PATCH 0/7] mmc: sdhci: set .remove to sdhci_pltfm_unregister() Kevin Hao
` (3 preceding siblings ...)
2015-02-06 3:15 ` [PATCH 4/7] mmc: sdhci-sirf: kill the "clk" member in driver private struct Kevin Hao
@ 2015-02-06 3:15 ` Kevin Hao
2015-02-06 5:51 ` Ray Jui
2015-02-06 3:15 ` [PATCH 6/7] mmc: sdhci: disable the clock in sdhci_pltfm_unregister() Kevin Hao
2015-02-06 3:15 ` [PATCH 7/7] mmc: sdhci: set the .remove to sdhci_pltfm_unregister() Kevin Hao
6 siblings, 1 reply; 10+ messages in thread
From: Kevin Hao @ 2015-02-06 3:15 UTC (permalink / raw)
To: linux-mmc
Cc: Chris Ball, Ulf Hansson, Christian Daudt, Matt Porter,
Florian Fainelli, bcm-kernel-feedback-list, Kevin Hao
Actually we can use the "clk" in the struct sdhci_pltfm_host.
Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
drivers/mmc/host/sdhci-bcm-kona.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/mmc/host/sdhci-bcm-kona.c b/drivers/mmc/host/sdhci-bcm-kona.c
index 34bb8f92586e..01660344e414 100644
--- a/drivers/mmc/host/sdhci-bcm-kona.c
+++ b/drivers/mmc/host/sdhci-bcm-kona.c
@@ -54,7 +54,6 @@
struct sdhci_bcm_kona_dev {
struct mutex write_lock; /* protect back to back writes */
- struct clk *external_clk;
};
@@ -265,19 +264,19 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)
}
/* Get and enable the external clock */
- kona_dev->external_clk = devm_clk_get(dev, NULL);
- if (IS_ERR(kona_dev->external_clk)) {
+ pltfm_priv->clk = devm_clk_get(dev, NULL);
+ if (IS_ERR(pltfm_priv->clk)) {
dev_err(dev, "Failed to get external clock\n");
- ret = PTR_ERR(kona_dev->external_clk);
+ ret = PTR_ERR(pltfm_priv->clk);
goto err_pltfm_free;
}
- if (clk_set_rate(kona_dev->external_clk, host->mmc->f_max) != 0) {
+ if (clk_set_rate(pltfm_priv->clk, host->mmc->f_max) != 0) {
dev_err(dev, "Failed to set rate external clock\n");
goto err_pltfm_free;
}
- if (clk_prepare_enable(kona_dev->external_clk) != 0) {
+ if (clk_prepare_enable(pltfm_priv->clk) != 0) {
dev_err(dev, "Failed to enable external clock\n");
goto err_pltfm_free;
}
@@ -333,7 +332,7 @@ err_reset:
sdhci_bcm_kona_sd_reset(host);
err_clk_disable:
- clk_disable_unprepare(kona_dev->external_clk);
+ clk_disable_unprepare(pltfm_priv->clk);
err_pltfm_free:
sdhci_pltfm_free(pdev);
@@ -346,12 +345,11 @@ static int sdhci_bcm_kona_remove(struct platform_device *pdev)
{
struct sdhci_host *host = platform_get_drvdata(pdev);
struct sdhci_pltfm_host *pltfm_priv = sdhci_priv(host);
- struct sdhci_bcm_kona_dev *kona_dev = sdhci_pltfm_priv(pltfm_priv);
int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
sdhci_remove_host(host, dead);
- clk_disable_unprepare(kona_dev->external_clk);
+ clk_disable_unprepare(pltfm_priv->clk);
sdhci_pltfm_free(pdev);
--
1.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 6/7] mmc: sdhci: disable the clock in sdhci_pltfm_unregister()
2015-02-06 3:15 [PATCH 0/7] mmc: sdhci: set .remove to sdhci_pltfm_unregister() Kevin Hao
` (4 preceding siblings ...)
2015-02-06 3:15 ` [PATCH 5/7] mmc: sdhci-bcm-kona: kill the "external_clk" " Kevin Hao
@ 2015-02-06 3:15 ` Kevin Hao
2015-02-06 3:15 ` [PATCH 7/7] mmc: sdhci: set the .remove to sdhci_pltfm_unregister() Kevin Hao
6 siblings, 0 replies; 10+ messages in thread
From: Kevin Hao @ 2015-02-06 3:15 UTC (permalink / raw)
To: linux-mmc; +Cc: Chris Ball, Ulf Hansson, Kevin Hao
So we can avoid to sprinkle the clk_disable_unprepare() in many
drivers.
Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
drivers/mmc/host/sdhci-bcm-kona.c | 12 +-----------
drivers/mmc/host/sdhci-dove.c | 8 +-------
drivers/mmc/host/sdhci-of-arasan.c | 1 -
drivers/mmc/host/sdhci-pltfm.c | 2 ++
drivers/mmc/host/sdhci-sirf.c | 5 +----
drivers/mmc/host/sdhci-st.c | 5 -----
drivers/mmc/host/sdhci-tegra.c | 12 +-----------
7 files changed, 6 insertions(+), 39 deletions(-)
diff --git a/drivers/mmc/host/sdhci-bcm-kona.c b/drivers/mmc/host/sdhci-bcm-kona.c
index 01660344e414..9313bf63d9b6 100644
--- a/drivers/mmc/host/sdhci-bcm-kona.c
+++ b/drivers/mmc/host/sdhci-bcm-kona.c
@@ -343,17 +343,7 @@ err_pltfm_free:
static int sdhci_bcm_kona_remove(struct platform_device *pdev)
{
- struct sdhci_host *host = platform_get_drvdata(pdev);
- struct sdhci_pltfm_host *pltfm_priv = sdhci_priv(host);
- int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
-
- sdhci_remove_host(host, dead);
-
- clk_disable_unprepare(pltfm_priv->clk);
-
- sdhci_pltfm_free(pdev);
-
- return 0;
+ return sdhci_pltfm_unregister(pdev);
}
static struct platform_driver sdhci_bcm_kona_driver = {
diff --git a/drivers/mmc/host/sdhci-dove.c b/drivers/mmc/host/sdhci-dove.c
index f78440ef1ba4..2314ff88d942 100644
--- a/drivers/mmc/host/sdhci-dove.c
+++ b/drivers/mmc/host/sdhci-dove.c
@@ -110,13 +110,7 @@ err_sdhci_add:
static int sdhci_dove_remove(struct platform_device *pdev)
{
- struct sdhci_host *host = platform_get_drvdata(pdev);
- struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
-
- clk_disable_unprepare(pltfm_host->clk);
- sdhci_pltfm_unregister(pdev);
-
- return 0;
+ return sdhci_pltfm_unregister(pdev);
}
static const struct of_device_id sdhci_dove_of_match_table[] = {
diff --git a/drivers/mmc/host/sdhci-of-arasan.c b/drivers/mmc/host/sdhci-of-arasan.c
index bcb51e9dfdcd..129079fb53bf 100644
--- a/drivers/mmc/host/sdhci-of-arasan.c
+++ b/drivers/mmc/host/sdhci-of-arasan.c
@@ -195,7 +195,6 @@ static int sdhci_arasan_remove(struct platform_device *pdev)
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct sdhci_arasan_data *sdhci_arasan = pltfm_host->priv;
- clk_disable_unprepare(pltfm_host->clk);
clk_disable_unprepare(sdhci_arasan->clk_ahb);
return sdhci_pltfm_unregister(pdev);
diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
index c5b01d6bb85d..74c58d9a4fc8 100644
--- a/drivers/mmc/host/sdhci-pltfm.c
+++ b/drivers/mmc/host/sdhci-pltfm.c
@@ -225,9 +225,11 @@ EXPORT_SYMBOL_GPL(sdhci_pltfm_register);
int 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);
return 0;
diff --git a/drivers/mmc/host/sdhci-sirf.c b/drivers/mmc/host/sdhci-sirf.c
index 51b31208f559..361952f958aa 100644
--- a/drivers/mmc/host/sdhci-sirf.c
+++ b/drivers/mmc/host/sdhci-sirf.c
@@ -202,11 +202,8 @@ err_clk_prepare:
static int sdhci_sirf_remove(struct platform_device *pdev)
{
struct sdhci_host *host = platform_get_drvdata(pdev);
- struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
- clk_disable_unprepare(pltfm_host->clk);
- sdhci_pltfm_unregister(pdev);
- return 0;
+ return sdhci_pltfm_unregister(pdev);
}
#ifdef CONFIG_PM_SLEEP
diff --git a/drivers/mmc/host/sdhci-st.c b/drivers/mmc/host/sdhci-st.c
index 882b07e9667e..0019df452522 100644
--- a/drivers/mmc/host/sdhci-st.c
+++ b/drivers/mmc/host/sdhci-st.c
@@ -115,11 +115,6 @@ err_of:
static int sdhci_st_remove(struct platform_device *pdev)
{
- struct sdhci_host *host = platform_get_drvdata(pdev);
- struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
-
- clk_disable_unprepare(pltfm_host->clk);
-
return sdhci_pltfm_unregister(pdev);
}
diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index 0643f66b4e14..12881e05ff30 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -323,17 +323,7 @@ err_alloc_tegra_host:
static int sdhci_tegra_remove(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);
-
- return 0;
+ return sdhci_pltfm_unregister(pdev);
}
static struct platform_driver sdhci_tegra_driver = {
--
1.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 7/7] mmc: sdhci: set the .remove to sdhci_pltfm_unregister()
2015-02-06 3:15 [PATCH 0/7] mmc: sdhci: set .remove to sdhci_pltfm_unregister() Kevin Hao
` (5 preceding siblings ...)
2015-02-06 3:15 ` [PATCH 6/7] mmc: sdhci: disable the clock in sdhci_pltfm_unregister() Kevin Hao
@ 2015-02-06 3:15 ` Kevin Hao
6 siblings, 0 replies; 10+ messages in thread
From: Kevin Hao @ 2015-02-06 3:15 UTC (permalink / raw)
To: linux-mmc; +Cc: Chris Ball, Ulf Hansson, Kevin Hao
In these drivers, the driver specific .remove function just a simple
wrapper of function sdhci_pltfm_unregister(). So remove these wrappers
and just set .remove to sdhci_pltfm_unregister().
Signed-off-by: Kevin Hao <haokexin@gmail.com>
---
drivers/mmc/host/sdhci-bcm-kona.c | 7 +------
drivers/mmc/host/sdhci-bcm2835.c | 7 +------
drivers/mmc/host/sdhci-cns3xxx.c | 7 +------
drivers/mmc/host/sdhci-dove.c | 7 +------
drivers/mmc/host/sdhci-of-esdhc.c | 7 +------
drivers/mmc/host/sdhci-of-hlwd.c | 7 +------
drivers/mmc/host/sdhci-sirf.c | 9 +--------
drivers/mmc/host/sdhci-st.c | 7 +------
drivers/mmc/host/sdhci-tegra.c | 7 +------
9 files changed, 9 insertions(+), 56 deletions(-)
diff --git a/drivers/mmc/host/sdhci-bcm-kona.c b/drivers/mmc/host/sdhci-bcm-kona.c
index 9313bf63d9b6..a773ff8be598 100644
--- a/drivers/mmc/host/sdhci-bcm-kona.c
+++ b/drivers/mmc/host/sdhci-bcm-kona.c
@@ -341,11 +341,6 @@ err_pltfm_free:
return ret;
}
-static int sdhci_bcm_kona_remove(struct platform_device *pdev)
-{
- return sdhci_pltfm_unregister(pdev);
-}
-
static struct platform_driver sdhci_bcm_kona_driver = {
.driver = {
.name = "sdhci-kona",
@@ -353,7 +348,7 @@ static struct platform_driver sdhci_bcm_kona_driver = {
.of_match_table = sdhci_bcm_kona_of_match,
},
.probe = sdhci_bcm_kona_probe,
- .remove = sdhci_bcm_kona_remove,
+ .remove = sdhci_pltfm_unregister,
};
module_platform_driver(sdhci_bcm_kona_driver);
diff --git a/drivers/mmc/host/sdhci-bcm2835.c b/drivers/mmc/host/sdhci-bcm2835.c
index 439d259fdf1d..0ef0343c603a 100644
--- a/drivers/mmc/host/sdhci-bcm2835.c
+++ b/drivers/mmc/host/sdhci-bcm2835.c
@@ -180,11 +180,6 @@ err:
return ret;
}
-static int bcm2835_sdhci_remove(struct platform_device *pdev)
-{
- return sdhci_pltfm_unregister(pdev);
-}
-
static const struct of_device_id bcm2835_sdhci_of_match[] = {
{ .compatible = "brcm,bcm2835-sdhci" },
{ }
@@ -198,7 +193,7 @@ static struct platform_driver bcm2835_sdhci_driver = {
.pm = SDHCI_PLTFM_PMOPS,
},
.probe = bcm2835_sdhci_probe,
- .remove = bcm2835_sdhci_remove,
+ .remove = sdhci_pltfm_unregister,
};
module_platform_driver(bcm2835_sdhci_driver);
diff --git a/drivers/mmc/host/sdhci-cns3xxx.c b/drivers/mmc/host/sdhci-cns3xxx.c
index a7935a8d0922..59f2923f8054 100644
--- a/drivers/mmc/host/sdhci-cns3xxx.c
+++ b/drivers/mmc/host/sdhci-cns3xxx.c
@@ -98,18 +98,13 @@ static int sdhci_cns3xxx_probe(struct platform_device *pdev)
return sdhci_pltfm_register(pdev, &sdhci_cns3xxx_pdata, 0);
}
-static int sdhci_cns3xxx_remove(struct platform_device *pdev)
-{
- return sdhci_pltfm_unregister(pdev);
-}
-
static struct platform_driver sdhci_cns3xxx_driver = {
.driver = {
.name = "sdhci-cns3xxx",
.pm = SDHCI_PLTFM_PMOPS,
},
.probe = sdhci_cns3xxx_probe,
- .remove = sdhci_cns3xxx_remove,
+ .remove = sdhci_pltfm_unregister,
};
module_platform_driver(sdhci_cns3xxx_driver);
diff --git a/drivers/mmc/host/sdhci-dove.c b/drivers/mmc/host/sdhci-dove.c
index 2314ff88d942..407c21f152b2 100644
--- a/drivers/mmc/host/sdhci-dove.c
+++ b/drivers/mmc/host/sdhci-dove.c
@@ -108,11 +108,6 @@ err_sdhci_add:
return ret;
}
-static int sdhci_dove_remove(struct platform_device *pdev)
-{
- return sdhci_pltfm_unregister(pdev);
-}
-
static const struct of_device_id sdhci_dove_of_match_table[] = {
{ .compatible = "marvell,dove-sdhci", },
{}
@@ -126,7 +121,7 @@ static struct platform_driver sdhci_dove_driver = {
.of_match_table = sdhci_dove_of_match_table,
},
.probe = sdhci_dove_probe,
- .remove = sdhci_dove_remove,
+ .remove = sdhci_pltfm_unregister,
};
module_platform_driver(sdhci_dove_driver);
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 17fe02ed6672..22e9111b11ff 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -386,11 +386,6 @@ static int sdhci_esdhc_probe(struct platform_device *pdev)
return ret;
}
-static int sdhci_esdhc_remove(struct platform_device *pdev)
-{
- return sdhci_pltfm_unregister(pdev);
-}
-
static const struct of_device_id sdhci_esdhc_of_match[] = {
{ .compatible = "fsl,mpc8379-esdhc" },
{ .compatible = "fsl,mpc8536-esdhc" },
@@ -406,7 +401,7 @@ static struct platform_driver sdhci_esdhc_driver = {
.pm = ESDHC_PMOPS,
},
.probe = sdhci_esdhc_probe,
- .remove = sdhci_esdhc_remove,
+ .remove = sdhci_pltfm_unregister,
};
module_platform_driver(sdhci_esdhc_driver);
diff --git a/drivers/mmc/host/sdhci-of-hlwd.c b/drivers/mmc/host/sdhci-of-hlwd.c
index be479279a1d5..4079a96ad37e 100644
--- a/drivers/mmc/host/sdhci-of-hlwd.c
+++ b/drivers/mmc/host/sdhci-of-hlwd.c
@@ -75,11 +75,6 @@ static int sdhci_hlwd_probe(struct platform_device *pdev)
return sdhci_pltfm_register(pdev, &sdhci_hlwd_pdata, 0);
}
-static int sdhci_hlwd_remove(struct platform_device *pdev)
-{
- return sdhci_pltfm_unregister(pdev);
-}
-
static const struct of_device_id sdhci_hlwd_of_match[] = {
{ .compatible = "nintendo,hollywood-sdhci" },
{ }
@@ -93,7 +88,7 @@ static struct platform_driver sdhci_hlwd_driver = {
.pm = SDHCI_PLTFM_PMOPS,
},
.probe = sdhci_hlwd_probe,
- .remove = sdhci_hlwd_remove,
+ .remove = sdhci_pltfm_unregister,
};
module_platform_driver(sdhci_hlwd_driver);
diff --git a/drivers/mmc/host/sdhci-sirf.c b/drivers/mmc/host/sdhci-sirf.c
index 361952f958aa..e74e2fdcaeff 100644
--- a/drivers/mmc/host/sdhci-sirf.c
+++ b/drivers/mmc/host/sdhci-sirf.c
@@ -199,13 +199,6 @@ err_clk_prepare:
return ret;
}
-static int sdhci_sirf_remove(struct platform_device *pdev)
-{
- struct sdhci_host *host = platform_get_drvdata(pdev);
-
- return sdhci_pltfm_unregister(pdev);
-}
-
#ifdef CONFIG_PM_SLEEP
static int sdhci_sirf_suspend(struct device *dev)
{
@@ -255,7 +248,7 @@ static struct platform_driver sdhci_sirf_driver = {
#endif
},
.probe = sdhci_sirf_probe,
- .remove = sdhci_sirf_remove,
+ .remove = sdhci_pltfm_unregister,
};
module_platform_driver(sdhci_sirf_driver);
diff --git a/drivers/mmc/host/sdhci-st.c b/drivers/mmc/host/sdhci-st.c
index 0019df452522..594a4ef3285b 100644
--- a/drivers/mmc/host/sdhci-st.c
+++ b/drivers/mmc/host/sdhci-st.c
@@ -113,11 +113,6 @@ err_of:
return ret;
}
-static int sdhci_st_remove(struct platform_device *pdev)
-{
- return sdhci_pltfm_unregister(pdev);
-}
-
#ifdef CONFIG_PM_SLEEP
static int sdhci_st_suspend(struct device *dev)
{
@@ -155,7 +150,7 @@ MODULE_DEVICE_TABLE(of, st_sdhci_match);
static struct platform_driver sdhci_st_driver = {
.probe = sdhci_st_probe,
- .remove = sdhci_st_remove,
+ .remove = sdhci_pltfm_unregister,
.driver = {
.name = "sdhci-st",
.pm = &sdhci_st_pmops,
diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c
index 12881e05ff30..2489bb753708 100644
--- a/drivers/mmc/host/sdhci-tegra.c
+++ b/drivers/mmc/host/sdhci-tegra.c
@@ -321,11 +321,6 @@ err_alloc_tegra_host:
return rc;
}
-static int sdhci_tegra_remove(struct platform_device *pdev)
-{
- return sdhci_pltfm_unregister(pdev);
-}
-
static struct platform_driver sdhci_tegra_driver = {
.driver = {
.name = "sdhci-tegra",
@@ -333,7 +328,7 @@ static struct platform_driver sdhci_tegra_driver = {
.pm = SDHCI_PLTFM_PMOPS,
},
.probe = sdhci_tegra_probe,
- .remove = sdhci_tegra_remove,
+ .remove = sdhci_pltfm_unregister,
};
module_platform_driver(sdhci_tegra_driver);
--
1.9.3
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 5/7] mmc: sdhci-bcm-kona: kill the "external_clk" member in driver private struct
2015-02-06 3:15 ` [PATCH 5/7] mmc: sdhci-bcm-kona: kill the "external_clk" " Kevin Hao
@ 2015-02-06 5:51 ` Ray Jui
2015-02-06 6:40 ` Kevin Hao
0 siblings, 1 reply; 10+ messages in thread
From: Ray Jui @ 2015-02-06 5:51 UTC (permalink / raw)
To: Kevin Hao, linux-mmc
Cc: Chris Ball, Ulf Hansson, Christian Daudt, Matt Porter,
Florian Fainelli, bcm-kernel-feedback-list
On 2/5/2015 7:15 PM, Kevin Hao wrote:
> Actually we can use the "clk" in the struct sdhci_pltfm_host.
>
> Signed-off-by: Kevin Hao <haokexin@gmail.com>
> ---
> drivers/mmc/host/sdhci-bcm-kona.c | 16 +++++++---------
> 1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/mmc/host/sdhci-bcm-kona.c b/drivers/mmc/host/sdhci-bcm-kona.c
> index 34bb8f92586e..01660344e414 100644
> --- a/drivers/mmc/host/sdhci-bcm-kona.c
> +++ b/drivers/mmc/host/sdhci-bcm-kona.c
> @@ -54,7 +54,6 @@
>
> struct sdhci_bcm_kona_dev {
> struct mutex write_lock; /* protect back to back writes */
> - struct clk *external_clk;
> };
>
>
> @@ -265,19 +264,19 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)
> }
>
> /* Get and enable the external clock */
Would you mind changing the above comment to "/* Get and enable the core
clock */?
> - kona_dev->external_clk = devm_clk_get(dev, NULL);
> - if (IS_ERR(kona_dev->external_clk)) {
> + pltfm_priv->clk = devm_clk_get(dev, NULL);
> + if (IS_ERR(pltfm_priv->clk)) {
> dev_err(dev, "Failed to get external clock\n");
Change to "Failed to get the core clock"
> - ret = PTR_ERR(kona_dev->external_clk);
> + ret = PTR_ERR(pltfm_priv->clk);
> goto err_pltfm_free;
> }
>
> - if (clk_set_rate(kona_dev->external_clk, host->mmc->f_max) != 0) {
> + if (clk_set_rate(pltfm_priv->clk, host->mmc->f_max) != 0) {
> dev_err(dev, "Failed to set rate external clock\n");
> goto err_pltfm_free;
> }
>
> - if (clk_prepare_enable(kona_dev->external_clk) != 0) {
> + if (clk_prepare_enable(pltfm_priv->clk) != 0) {
> dev_err(dev, "Failed to enable external clock\n");
> goto err_pltfm_free;
> }
> @@ -333,7 +332,7 @@ err_reset:
> sdhci_bcm_kona_sd_reset(host);
>
> err_clk_disable:
> - clk_disable_unprepare(kona_dev->external_clk);
> + clk_disable_unprepare(pltfm_priv->clk);
>
> err_pltfm_free:
> sdhci_pltfm_free(pdev);
> @@ -346,12 +345,11 @@ static int sdhci_bcm_kona_remove(struct platform_device *pdev)
> {
> struct sdhci_host *host = platform_get_drvdata(pdev);
> struct sdhci_pltfm_host *pltfm_priv = sdhci_priv(host);
> - struct sdhci_bcm_kona_dev *kona_dev = sdhci_pltfm_priv(pltfm_priv);
> int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff);
>
> sdhci_remove_host(host, dead);
>
> - clk_disable_unprepare(kona_dev->external_clk);
> + clk_disable_unprepare(pltfm_priv->clk);
>
> sdhci_pltfm_free(pdev);
>
>
Not sure if this is relevant and should be done in the same patch. But
both callbacks get_max_clock and get_timeout_clock in this driver can be
set to sdhci_pltfm_clk_get_max_clock. That will help to get rid of two
redundant private functions in this driver.
Thanks,
Ray
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 5/7] mmc: sdhci-bcm-kona: kill the "external_clk" member in driver private struct
2015-02-06 5:51 ` Ray Jui
@ 2015-02-06 6:40 ` Kevin Hao
0 siblings, 0 replies; 10+ messages in thread
From: Kevin Hao @ 2015-02-06 6:40 UTC (permalink / raw)
To: Ray Jui
Cc: linux-mmc, Chris Ball, Ulf Hansson, Christian Daudt, Matt Porter,
Florian Fainelli, bcm-kernel-feedback-list
[-- Attachment #1: Type: text/plain, Size: 1023 bytes --]
On Thu, Feb 05, 2015 at 09:51:17PM -0800, Ray Jui wrote:
> > @@ -265,19 +264,19 @@ static int sdhci_bcm_kona_probe(struct platform_device *pdev)
> > }
> >
> > /* Get and enable the external clock */
>
> Would you mind changing the above comment to "/* Get and enable the core
> clock */?
Sure.
>
> > - kona_dev->external_clk = devm_clk_get(dev, NULL);
> > - if (IS_ERR(kona_dev->external_clk)) {
> > + pltfm_priv->clk = devm_clk_get(dev, NULL);
> > + if (IS_ERR(pltfm_priv->clk)) {
> > dev_err(dev, "Failed to get external clock\n");
>
> Change to "Failed to get the core clock"
OK, I will change all the references of "external clock" to "core clock".
> Not sure if this is relevant and should be done in the same patch. But
> both callbacks get_max_clock and get_timeout_clock in this driver can be
> set to sdhci_pltfm_clk_get_max_clock. That will help to get rid of two
> redundant private functions in this driver.
Sounds good. I will add this in the v2.
Thanks,
Kevin
[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-02-06 6:40 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-06 3:15 [PATCH 0/7] mmc: sdhci: set .remove to sdhci_pltfm_unregister() Kevin Hao
2015-02-06 3:15 ` [PATCH 1/7] mmc: sdhci-dove: remove the unneeded error check Kevin Hao
2015-02-06 3:15 ` [PATCH 2/7] mmc: sdhci-dove: kill the driver specific private struct Kevin Hao
2015-02-06 3:15 ` [PATCH 3/7] mmc: tegra: use devm help functions to get the clk and gpio Kevin Hao
2015-02-06 3:15 ` [PATCH 4/7] mmc: sdhci-sirf: kill the "clk" member in driver private struct Kevin Hao
2015-02-06 3:15 ` [PATCH 5/7] mmc: sdhci-bcm-kona: kill the "external_clk" " Kevin Hao
2015-02-06 5:51 ` Ray Jui
2015-02-06 6:40 ` Kevin Hao
2015-02-06 3:15 ` [PATCH 6/7] mmc: sdhci: disable the clock in sdhci_pltfm_unregister() Kevin Hao
2015-02-06 3:15 ` [PATCH 7/7] mmc: sdhci: set the .remove to sdhci_pltfm_unregister() Kevin Hao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox