mmc: atmel-mci: cleanup and probe deferring
v3 cover mmc: atmel-mci: cleanup and probe deferring
Hi Ulf,
I have rebased my series on your next branch but I didn't have any conflict and a warning on the whole series with checkpatch so please tell me if something goes wrong.
Regards
Ludovic
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, 29 insertions(+), 47 deletions(-)
Signature · 1 line
2.0.3
PATCH v3 1/4 mmc: atmel-mci: remove useless DMA stuff for non-dt devices
All devices with a DMA controller are DT compliant and legacy support has been removed. For those reasons, some DMA stuff is useless.
--- drivers/mmc/host/atmel-mci.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/mmc/host/atmel-mci.c +0 -8
@@ -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" );
Signature · 1 line
2.0.3
PATCH v3 2/4 mmc: atmel-mci: remove __init/__exit attributes
In reply to Ludovic DesrochesUsing __init/__exit attributes can cause several breakages so remove them.
--- drivers/mmc/host/atmel-mci.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/mmc/host/atmel-mci.c +7 -7
@@ -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),
@@ -2573,12 +2573,12 @@ static struct platform_driver atmci_driver = { }, }; -static int __init atmci_init (void ) +static int atmci_init (void ) {return platform_driver_probe (&atmci_driver, atmci_probe); } -static void __exit atmci_exit(void) +static void atmci_exit (void ) {platform_driver_unregister (&atmci_driver); }
Signature · 1 line
2.0.3
PATCH v3 2/4 mmc: atmel-mci: remove __init/__exit attributes
Quoted 2 lines · Ludovic Desroches
Using __init/__exit attributes can cause several breakages so remove them.
I've really no idea why people jump overboard with these things - it seems people go from one extreme to the other (adding lots of __init / __exit annotations everywhere to removing them all), but:
Quoted 5 lines
drivers/mmc/host/atmel-mci.c +0
-1@@ -2573,12 +2573,12 @@ static struct platform_driver atmci_driver = { }, }; -static int __init atmci_init (void )
drivers/mmc/host/atmel-mci.c static struct platform_driver atmci_driver = { · line 2584
Quoted 10 lines
drivers/mmc/host/atmel-mci.c +2
-1+static int atmci_init (void ) {return platform_driver_probe (&atmci_driver, atmci_probe); } -static void __exit atmci_exit(void) +static void atmci_exit (void ) {platform_driver_unregister (&atmci_driver); }
These last two are totally fine to leave there.
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up according to speedtest.net.
PATCH v3 3/4 mmc: atmel-mci: stop using specific initcall
In reply to Ludovic DesrochesNo more use late initcall to manage probing order. Use probe deferring if needed.
--- drivers/mmc/host/atmel-mci.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-)
drivers/mmc/host/atmel-mci.c +2 -13
@@ -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 atmci_init (void ) -{ -return platform_driver_probe (&atmci_driver, atmci_probe); -} - -static void 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)" );
Signature · 1 line
2.0.3
PATCH v3 4/4 mmc: atmel-mci: use probe deferring if dma controller is not ready yet
In reply to Ludovic DesrochesReturn probe defer if requesting a dma channel without a dma controller probed.
--- drivers/mmc/host/atmel-mci.c | 49 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 24 deletions(-)
drivers/mmc/host/atmel-mci.c +25 -24
@@ -2272,29 +2272,26 @@ 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; +int ret =0 ; - 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; - } + host->dma.chan =dma_request_slave_channel_reason (&host->pdev->dev,"rxtx" ); +if (IS_ERR (host->dma.chan)) +return PTR_ERR (host->dma.chan); + +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 ret; }/*
@@ -2411,7 +2408,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 +2496,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 +2524,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);
Signature · 1 line
2.0.3
PATCH v3 4/4 mmc: atmel-mci: use probe deferring if dma controller is not ready yet
Let's look at the resulting code:
Quoted 11 lines · Ludovic Desroches
drivers/mmc/host/atmel-mci.c +9
-0+static int atmci_configure_dma (struct atmel_mci *host) { +int ret =0 ; + host->dma.chan =dma_request_slave_channel_reason (&host->pdev->dev,"rxtx" ); +if (IS_ERR (host->dma.chan)) +return PTR_ERR (host->dma.chan); + +dev_info (&host->pdev->dev,"using %s for DMA transfers\n" , +dma_chan_name (host->dma.chan)); +
drivers/mmc/host/atmel-mci.c static void atmci_cleanup_slot(struct atmel_mci_slot *slot, · line 2295
Quoted 10 lines
drivers/mmc/host/atmel-mci.c +9
-0+ 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 ret; }
I think you can clean this up a little further - what do you notice about the value of "ret" here?
Signature · 2 lines
FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up according to speedtest.net.
PATCH v3 4/4 mmc: atmel-mci: use probe deferring if dma controller is not ready yet
Quoted 19 lines · Russell King - ARM Linux
Let's look at the resulting code:
Quoted 16 lines · Ludovic Desroches
drivers/mmc/host/atmel-mci.c +14
-0+static int atmci_configure_dma (struct atmel_mci *host) { +int ret =0 ; + host->dma.chan =dma_request_slave_channel_reason (&host->pdev->dev,"rxtx" ); +if (IS_ERR (host->dma.chan)) +return PTR_ERR (host->dma.chan); + +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 ;
Quoted 8 lines
drivers/mmc/host/atmel-mci.c static void atmci_cleanup_slot(struct atmel_mci_slot *slot, · line 2295
Quoted 5 lines
drivers/mmc/host/atmel-mci.c +4
-0+ host->dma_conf.dst_maxburst =1 ; + host->dma_conf.device_fc = false; + +return ret; }I think you can clean this up a little further - what do you notice about the value of "ret" here?
I think I see what you mean :) The fix I have merged for this patch makes ret useless.
Quoted 4 lines
Signature · 3 lines
-- FTTC broadband for 0.8mile line: currently at 9.5Mbps down 400kbps up according to speedtest.net.