linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 0/4] mmc: atmel-mci: cleanup and probe deferring
@ 2014-12-01 14:35 Ludovic Desroches
  2014-12-01 14:35 ` [PATCH v4 1/4] mmc: atmel-mci: remove useless DMA stuff for non-dt devices Ludovic Desroches
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Ludovic Desroches @ 2014-12-01 14:35 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: ulf.hansson, nicolas.ferre, arnd, Ludovic Desroches

Hi Ulf,

Same as previous series, based on your next branch, and no errors with
checkpatch so let me know if you still have troubles to apply my patches.

Changes from v3:
- keep __init/__exit attributes for atmci_init/exit
- remove useless variable in atmci_configure_dma function

Ludovic Desroches (4):
  mmc: atmel-mci: remove useless DMA stuff for non-dt devices
  mmc: atmel-mci: remove __init/__exit attributes
  mmc: atmel-mci: stop using specific initcall
  mmc: atmel-mci: use probe deferring if dma controller is not ready yet

 drivers/mmc/host/atmel-mci.c | 76 ++++++++++++++++----------------------------
 1 file changed, 28 insertions(+), 48 deletions(-)

-- 
2.0.3


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

* [PATCH v4 1/4] mmc: atmel-mci: remove useless DMA stuff for non-dt devices
  2014-12-01 14:35 [PATCH v4 0/4] mmc: atmel-mci: cleanup and probe deferring Ludovic Desroches
@ 2014-12-01 14:35 ` Ludovic Desroches
  2014-12-01 14:35 ` [PATCH v4 2/4] mmc: atmel-mci: remove __init/__exit attributes Ludovic Desroches
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Ludovic Desroches @ 2014-12-01 14:35 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: ulf.hansson, nicolas.ferre, arnd, Ludovic Desroches

All devices with a DMA controller are DT compliant and legacy support
has been removed. For those reasons, some DMA stuff is useless.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 drivers/mmc/host/atmel-mci.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index de2287c..f187e75 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -2274,17 +2274,9 @@ static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
 
 static bool atmci_configure_dma(struct atmel_mci *host)
 {
-	struct mci_platform_data	*pdata;
-	dma_cap_mask_t mask;
-
 	if (host == NULL)
 		return false;
 
-	pdata = host->pdev->dev.platform_data;
-
-	dma_cap_zero(mask);
-	dma_cap_set(DMA_SLAVE, mask);
-
 	host->dma.chan = dma_request_slave_channel(&host->pdev->dev, "rxtx");
 	if (!host->dma.chan) {
 		dev_warn(&host->pdev->dev, "no DMA channel available\n");
-- 
2.0.3


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

* [PATCH v4 2/4] mmc: atmel-mci: remove __init/__exit attributes
  2014-12-01 14:35 [PATCH v4 0/4] mmc: atmel-mci: cleanup and probe deferring Ludovic Desroches
  2014-12-01 14:35 ` [PATCH v4 1/4] mmc: atmel-mci: remove useless DMA stuff for non-dt devices Ludovic Desroches
@ 2014-12-01 14:35 ` Ludovic Desroches
  2014-12-01 14:35 ` [PATCH v4 3/4] mmc: atmel-mci: stop using specific initcall Ludovic Desroches
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Ludovic Desroches @ 2014-12-01 14:35 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: ulf.hansson, nicolas.ferre, arnd, Ludovic Desroches

Using __init/__exit attributes can cause several breakages so remove
them.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 drivers/mmc/host/atmel-mci.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index f187e75..f16d019 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -2140,7 +2140,7 @@ static irqreturn_t atmci_detect_interrupt(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static int __init atmci_init_slot(struct atmel_mci *host,
+static int atmci_init_slot(struct atmel_mci *host,
 		struct mci_slot_pdata *slot_data, unsigned int id,
 		u32 sdc_reg, u32 sdio_irq)
 {
@@ -2302,7 +2302,7 @@ static bool atmci_configure_dma(struct atmel_mci *host)
  * HSMCI provides DMA support and a new config register but no more supports
  * PDC.
  */
-static void __init atmci_get_cap(struct atmel_mci *host)
+static void atmci_get_cap(struct atmel_mci *host)
 {
 	unsigned int version;
 
@@ -2351,7 +2351,7 @@ static void __init atmci_get_cap(struct atmel_mci *host)
 	}
 }
 
-static int __init atmci_probe(struct platform_device *pdev)
+static int atmci_probe(struct platform_device *pdev)
 {
 	struct mci_platform_data	*pdata;
 	struct atmel_mci		*host;
@@ -2502,7 +2502,7 @@ err_init_slot:
 	return ret;
 }
 
-static int __exit atmci_remove(struct platform_device *pdev)
+static int atmci_remove(struct platform_device *pdev)
 {
 	struct atmel_mci	*host = platform_get_drvdata(pdev);
 	unsigned int		i;
@@ -2565,7 +2565,7 @@ static const struct dev_pm_ops atmci_dev_pm_ops = {
 };
 
 static struct platform_driver atmci_driver = {
-	.remove		= __exit_p(atmci_remove),
+	.remove		= atmci_remove,
 	.driver		= {
 		.name		= "atmel_mci",
 		.of_match_table	= of_match_ptr(atmci_dt_ids),
-- 
2.0.3


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

* [PATCH v4 3/4] mmc: atmel-mci: stop using specific initcall
  2014-12-01 14:35 [PATCH v4 0/4] mmc: atmel-mci: cleanup and probe deferring Ludovic Desroches
  2014-12-01 14:35 ` [PATCH v4 1/4] mmc: atmel-mci: remove useless DMA stuff for non-dt devices Ludovic Desroches
  2014-12-01 14:35 ` [PATCH v4 2/4] mmc: atmel-mci: remove __init/__exit attributes Ludovic Desroches
@ 2014-12-01 14:35 ` Ludovic Desroches
  2014-12-01 14:35 ` [PATCH v4 4/4] mmc: atmel-mci: use probe deferring if dma controller is not ready yet Ludovic Desroches
  2014-12-02 10:10 ` [PATCH v4 0/4] mmc: atmel-mci: cleanup and probe deferring Ulf Hansson
  4 siblings, 0 replies; 7+ messages in thread
From: Ludovic Desroches @ 2014-12-01 14:35 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: ulf.hansson, nicolas.ferre, arnd, Ludovic Desroches

No more use late initcall to manage probing order. Use probe deferring
if needed.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 drivers/mmc/host/atmel-mci.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index f16d019..00f6088 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -2565,6 +2565,7 @@ static const struct dev_pm_ops atmci_dev_pm_ops = {
 };
 
 static struct platform_driver atmci_driver = {
+	.probe		= atmci_probe,
 	.remove		= atmci_remove,
 	.driver		= {
 		.name		= "atmel_mci",
@@ -2572,19 +2573,7 @@ static struct platform_driver atmci_driver = {
 		.pm		= &atmci_dev_pm_ops,
 	},
 };
-
-static int __init atmci_init(void)
-{
-	return platform_driver_probe(&atmci_driver, atmci_probe);
-}
-
-static void __exit atmci_exit(void)
-{
-	platform_driver_unregister(&atmci_driver);
-}
-
-late_initcall(atmci_init); /* try to load after dma driver when built-in */
-module_exit(atmci_exit);
+module_platform_driver(atmci_driver);
 
 MODULE_DESCRIPTION("Atmel Multimedia Card Interface driver");
 MODULE_AUTHOR("Haavard Skinnemoen (Atmel)");
-- 
2.0.3


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

* [PATCH v4 4/4] mmc: atmel-mci: use probe deferring if dma controller is not ready yet
  2014-12-01 14:35 [PATCH v4 0/4] mmc: atmel-mci: cleanup and probe deferring Ludovic Desroches
                   ` (2 preceding siblings ...)
  2014-12-01 14:35 ` [PATCH v4 3/4] mmc: atmel-mci: stop using specific initcall Ludovic Desroches
@ 2014-12-01 14:35 ` Ludovic Desroches
  2014-12-02 10:10 ` [PATCH v4 0/4] mmc: atmel-mci: cleanup and probe deferring Ulf Hansson
  4 siblings, 0 replies; 7+ messages in thread
From: Ludovic Desroches @ 2014-12-01 14:35 UTC (permalink / raw)
  To: linux-mmc, linux-arm-kernel
  Cc: ulf.hansson, nicolas.ferre, arnd, Ludovic Desroches

Return probe defer if requesting a dma channel without a dma controller
probed.

Signed-off-by: Ludovic Desroches <ludovic.desroches@atmel.com>
---
 drivers/mmc/host/atmel-mci.c | 47 ++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 24 deletions(-)

diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c
index 00f6088..1a8e30c 100644
--- a/drivers/mmc/host/atmel-mci.c
+++ b/drivers/mmc/host/atmel-mci.c
@@ -2272,29 +2272,24 @@ static void atmci_cleanup_slot(struct atmel_mci_slot *slot,
 	mmc_free_host(slot->mmc);
 }
 
-static bool atmci_configure_dma(struct atmel_mci *host)
+static int atmci_configure_dma(struct atmel_mci *host)
 {
-	if (host == NULL)
-		return false;
+	host->dma.chan = dma_request_slave_channel_reason(&host->pdev->dev, "rxtx");
+	if (IS_ERR(host->dma.chan))
+		return PTR_ERR(host->dma.chan);
 
-	host->dma.chan = dma_request_slave_channel(&host->pdev->dev, "rxtx");
-	if (!host->dma.chan) {
-		dev_warn(&host->pdev->dev, "no DMA channel available\n");
-		return false;
-	} else {
-		dev_info(&host->pdev->dev,
-					"using %s for DMA transfers\n",
-					dma_chan_name(host->dma.chan));
-
-		host->dma_conf.src_addr = host->mapbase + ATMCI_RDR;
-		host->dma_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
-		host->dma_conf.src_maxburst = 1;
-		host->dma_conf.dst_addr = host->mapbase + ATMCI_TDR;
-		host->dma_conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
-		host->dma_conf.dst_maxburst = 1;
-		host->dma_conf.device_fc = false;
-		return true;
-	}
+	dev_info(&host->pdev->dev, "using %s for DMA transfers\n",
+		 dma_chan_name(host->dma.chan));
+
+	host->dma_conf.src_addr = host->mapbase + ATMCI_RDR;
+	host->dma_conf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+	host->dma_conf.src_maxburst = 1;
+	host->dma_conf.dst_addr = host->mapbase + ATMCI_TDR;
+	host->dma_conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+	host->dma_conf.dst_maxburst = 1;
+	host->dma_conf.device_fc = false;
+
+	return 0;
 }
 
 /*
@@ -2411,7 +2406,10 @@ static int atmci_probe(struct platform_device *pdev)
 
 	/* Get MCI capabilities and set operations according to it */
 	atmci_get_cap(host);
-	if (atmci_configure_dma(host)) {
+	ret = atmci_configure_dma(host);
+	if (ret == -EPROBE_DEFER)
+		goto err_dma_probe_defer;
+	if (ret == 0) {
 		host->prepare_data = &atmci_prepare_data_dma;
 		host->submit_data = &atmci_submit_data_dma;
 		host->stop_transfer = &atmci_stop_transfer_dma;
@@ -2496,8 +2494,9 @@ err_init_slot:
 	pm_runtime_put_noidle(&pdev->dev);
 
 	del_timer_sync(&host->timer);
-	if (host->dma.chan)
+	if (!IS_ERR(host->dma.chan))
 		dma_release_channel(host->dma.chan);
+err_dma_probe_defer:
 	free_irq(irq, host);
 	return ret;
 }
@@ -2523,7 +2522,7 @@ static int atmci_remove(struct platform_device *pdev)
 	atmci_readl(host, ATMCI_SR);
 
 	del_timer_sync(&host->timer);
-	if (host->dma.chan)
+	if (!IS_ERR(host->dma.chan))
 		dma_release_channel(host->dma.chan);
 
 	free_irq(platform_get_irq(pdev, 0), host);
-- 
2.0.3


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

* Re: [PATCH v4 0/4] mmc: atmel-mci: cleanup and probe deferring
  2014-12-01 14:35 [PATCH v4 0/4] mmc: atmel-mci: cleanup and probe deferring Ludovic Desroches
                   ` (3 preceding siblings ...)
  2014-12-01 14:35 ` [PATCH v4 4/4] mmc: atmel-mci: use probe deferring if dma controller is not ready yet Ludovic Desroches
@ 2014-12-02 10:10 ` Ulf Hansson
  2014-12-03  8:22   ` Ludovic Desroches
  4 siblings, 1 reply; 7+ messages in thread
From: Ulf Hansson @ 2014-12-02 10:10 UTC (permalink / raw)
  To: Ludovic Desroches
  Cc: linux-mmc, linux-arm-kernel, Nicolas Ferre, Arnd Bergmann

On 1 December 2014 at 15:35, Ludovic Desroches
<ludovic.desroches@atmel.com> wrote:
> Hi Ulf,
>
> Same as previous series, based on your next branch, and no errors with
> checkpatch so let me know if you still have troubles to apply my patches.
>
> Changes from v3:
> - keep __init/__exit attributes for atmci_init/exit
> - remove useless variable in atmci_configure_dma function
>
> Ludovic Desroches (4):
>   mmc: atmel-mci: remove useless DMA stuff for non-dt devices
>   mmc: atmel-mci: remove __init/__exit attributes
>   mmc: atmel-mci: stop using specific initcall
>   mmc: atmel-mci: use probe deferring if dma controller is not ready yet
>
>  drivers/mmc/host/atmel-mci.c | 76 ++++++++++++++++----------------------------
>  1 file changed, 28 insertions(+), 48 deletions(-)

Thanks! Applied for next.

Patch 4, did have a minor checkpatch warning. I fixed it.

Kind regards
Uffe

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

* Re: [PATCH v4 0/4] mmc: atmel-mci: cleanup and probe deferring
  2014-12-02 10:10 ` [PATCH v4 0/4] mmc: atmel-mci: cleanup and probe deferring Ulf Hansson
@ 2014-12-03  8:22   ` Ludovic Desroches
  0 siblings, 0 replies; 7+ messages in thread
From: Ludovic Desroches @ 2014-12-03  8:22 UTC (permalink / raw)
  To: Ulf Hansson
  Cc: Ludovic Desroches, linux-mmc, linux-arm-kernel, Nicolas Ferre,
	Arnd Bergmann

On Tue, Dec 02, 2014 at 11:10:53AM +0100, Ulf Hansson wrote:
> On 1 December 2014 at 15:35, Ludovic Desroches
> <ludovic.desroches@atmel.com> wrote:
> > Hi Ulf,
> >
> > Same as previous series, based on your next branch, and no errors with
> > checkpatch so let me know if you still have troubles to apply my patches.
> >
> > Changes from v3:
> > - keep __init/__exit attributes for atmci_init/exit
> > - remove useless variable in atmci_configure_dma function
> >
> > Ludovic Desroches (4):
> >   mmc: atmel-mci: remove useless DMA stuff for non-dt devices
> >   mmc: atmel-mci: remove __init/__exit attributes
> >   mmc: atmel-mci: stop using specific initcall
> >   mmc: atmel-mci: use probe deferring if dma controller is not ready yet
> >
> >  drivers/mmc/host/atmel-mci.c | 76 ++++++++++++++++----------------------------
> >  1 file changed, 28 insertions(+), 48 deletions(-)
> 
> Thanks! Applied for next.
> 
> Patch 4, did have a minor checkpatch warning. I fixed it.

Thanks, yes I see it but I feel it is a bit too constraining when you already
have a function name doing 32 characters :p

> 
> Kind regards
> Uffe

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

end of thread, other threads:[~2014-12-03  8:21 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-01 14:35 [PATCH v4 0/4] mmc: atmel-mci: cleanup and probe deferring Ludovic Desroches
2014-12-01 14:35 ` [PATCH v4 1/4] mmc: atmel-mci: remove useless DMA stuff for non-dt devices Ludovic Desroches
2014-12-01 14:35 ` [PATCH v4 2/4] mmc: atmel-mci: remove __init/__exit attributes Ludovic Desroches
2014-12-01 14:35 ` [PATCH v4 3/4] mmc: atmel-mci: stop using specific initcall Ludovic Desroches
2014-12-01 14:35 ` [PATCH v4 4/4] mmc: atmel-mci: use probe deferring if dma controller is not ready yet Ludovic Desroches
2014-12-02 10:10 ` [PATCH v4 0/4] mmc: atmel-mci: cleanup and probe deferring Ulf Hansson
2014-12-03  8:22   ` Ludovic Desroches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).