public inbox for linux-mmc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mmc: mxs-mmc: Use devm_clk_get()
@ 2013-07-03 20:02 Fabio Estevam
  2013-07-03 20:02 ` [PATCH 2/2] mmc: mxs-mmc: Check the return value from stmp_reset_block() Fabio Estevam
  2013-07-04  1:27 ` [PATCH 1/2] mmc: mxs-mmc: Use devm_clk_get() Shawn Guo
  0 siblings, 2 replies; 4+ messages in thread
From: Fabio Estevam @ 2013-07-03 20:02 UTC (permalink / raw)
  To: cjb; +Cc: shawn.guo, kernel, linux-mmc, Fabio Estevam

Using devm_clk_get() allows us to remove the clk_put() calls, so let's use it
to simplify the code.

Rename the 'out_clk_put' label to 'out_clk_disable' now that clk_put is removed.

Signed-off-by: Fabio Estevam <festevam@gmail.com>
---
 drivers/mmc/host/mxs-mmc.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index f38d75f..b76778f 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -618,7 +618,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 		}
 	}
 
-	ssp->clk = clk_get(&pdev->dev, NULL);
+	ssp->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(ssp->clk)) {
 		ret = PTR_ERR(ssp->clk);
 		goto out_mmc_free;
@@ -632,7 +632,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 		dev_err(mmc_dev(host->mmc),
 			"%s: failed to request dma\n", __func__);
 		ret = -ENODEV;
-		goto out_clk_put;
+		goto out_clk_disable;
 	}
 
 	/* set mmc core parameters */
@@ -685,9 +685,8 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 out_free_dma:
 	if (ssp->dmach)
 		dma_release_channel(ssp->dmach);
-out_clk_put:
+out_clk_disable:
 	clk_disable_unprepare(ssp->clk);
-	clk_put(ssp->clk);
 out_mmc_free:
 	mmc_free_host(mmc);
 	return ret;
@@ -705,7 +704,6 @@ static int mxs_mmc_remove(struct platform_device *pdev)
 		dma_release_channel(ssp->dmach);
 
 	clk_disable_unprepare(ssp->clk);
-	clk_put(ssp->clk);
 
 	mmc_free_host(mmc);
 
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] mmc: mxs-mmc: Check the return value from stmp_reset_block()
  2013-07-03 20:02 [PATCH 1/2] mmc: mxs-mmc: Use devm_clk_get() Fabio Estevam
@ 2013-07-03 20:02 ` Fabio Estevam
  2013-07-04  1:27 ` [PATCH 1/2] mmc: mxs-mmc: Use devm_clk_get() Shawn Guo
  1 sibling, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2013-07-03 20:02 UTC (permalink / raw)
  To: cjb; +Cc: shawn.guo, kernel, linux-mmc, Fabio Estevam

From: Fabio Estevam <fabio.estevam@freescale.com>

stmp_reset_block() may fail, so let's check its return value and propagate it in
the case of error.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
 drivers/mmc/host/mxs-mmc.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index b76778f..383830d 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -102,12 +102,15 @@ static int mxs_mmc_get_cd(struct mmc_host *mmc)
 		  BM_SSP_STATUS_CARD_DETECT) ^ host->cd_inverted;
 }
 
-static void mxs_mmc_reset(struct mxs_mmc_host *host)
+static int mxs_mmc_reset(struct mxs_mmc_host *host)
 {
 	struct mxs_ssp *ssp = &host->ssp;
 	u32 ctrl0, ctrl1;
-
-	stmp_reset_block(ssp->base);
+	int ret;
+
+	ret = stmp_reset_block(ssp->base);
+	if (ret)
+		return ret;
 
 	ctrl0 = BM_SSP_CTRL0_IGNORE_CRC;
 	ctrl1 = BF_SSP(0x3, CTRL1_SSP_MODE) |
@@ -132,6 +135,7 @@ static void mxs_mmc_reset(struct mxs_mmc_host *host)
 
 	writel(ctrl0, ssp->base + HW_SSP_CTRL0);
 	writel(ctrl1, ssp->base + HW_SSP_CTRL1(ssp));
+	return 0;
 }
 
 static void mxs_mmc_start_cmd(struct mxs_mmc_host *host,
@@ -625,7 +629,11 @@ static int mxs_mmc_probe(struct platform_device *pdev)
 	}
 	clk_prepare_enable(ssp->clk);
 
-	mxs_mmc_reset(host);
+	ret = mxs_mmc_reset(host);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to reset mmc: %d\n", ret);
+		goto out_clk_disable;
+	}
 
 	ssp->dmach = dma_request_slave_channel(&pdev->dev, "rx-tx");
 	if (!ssp->dmach) {
-- 
1.8.1.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] mmc: mxs-mmc: Use devm_clk_get()
  2013-07-03 20:02 [PATCH 1/2] mmc: mxs-mmc: Use devm_clk_get() Fabio Estevam
  2013-07-03 20:02 ` [PATCH 2/2] mmc: mxs-mmc: Check the return value from stmp_reset_block() Fabio Estevam
@ 2013-07-04  1:27 ` Shawn Guo
  2013-08-25  2:07   ` Chris Ball
  1 sibling, 1 reply; 4+ messages in thread
From: Shawn Guo @ 2013-07-04  1:27 UTC (permalink / raw)
  To: Fabio Estevam; +Cc: cjb, kernel, linux-mmc

On Wed, Jul 03, 2013 at 05:02:37PM -0300, Fabio Estevam wrote:
> Using devm_clk_get() allows us to remove the clk_put() calls, so let's use it
> to simplify the code.
> 
> Rename the 'out_clk_put' label to 'out_clk_disable' now that clk_put is removed.
> 
> Signed-off-by: Fabio Estevam <festevam@gmail.com>

Both,

Acked-by: Shawn Guo <shawn.guo@linaro.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] mmc: mxs-mmc: Use devm_clk_get()
  2013-07-04  1:27 ` [PATCH 1/2] mmc: mxs-mmc: Use devm_clk_get() Shawn Guo
@ 2013-08-25  2:07   ` Chris Ball
  0 siblings, 0 replies; 4+ messages in thread
From: Chris Ball @ 2013-08-25  2:07 UTC (permalink / raw)
  To: Shawn Guo; +Cc: Fabio Estevam, kernel, linux-mmc

Hi Fabio,

On Wed, Jul 03 2013, Shawn Guo wrote:
> On Wed, Jul 03, 2013 at 05:02:37PM -0300, Fabio Estevam wrote:
>> Using devm_clk_get() allows us to remove the clk_put() calls, so let's use it
>> to simplify the code.
>> 
>> Rename the 'out_clk_put' label to 'out_clk_disable' now that clk_put
>> is removed.
>> 
>> Signed-off-by: Fabio Estevam <festevam@gmail.com>
>
> Both,
>
> Acked-by: Shawn Guo <shawn.guo@linaro.org>

Thanks, both pushed to mmc-next for 3.12.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-08-25  2:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-03 20:02 [PATCH 1/2] mmc: mxs-mmc: Use devm_clk_get() Fabio Estevam
2013-07-03 20:02 ` [PATCH 2/2] mmc: mxs-mmc: Check the return value from stmp_reset_block() Fabio Estevam
2013-07-04  1:27 ` [PATCH 1/2] mmc: mxs-mmc: Use devm_clk_get() Shawn Guo
2013-08-25  2:07   ` Chris Ball

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox