sh mmcif cleanups
Subsystems (2)
This is a second round of the mmcif cleanups
Changes since v1:
- fix issues with devm_ioremap return, and error printing
- change the initial print
- fix issue with disabling clock
PATCH v2 1/6 mmc: sh-mmcif: update to print version and bus clock rate on probe
Change the initial print to show chip version and the bus rate it is working at instead of the driver version. This is more useful information as we already know which driver version from the kernel it is in.
--- drivers/mmc/host/sh_mmcif.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/mmc/host/sh_mmcif.c +5 -4
@@ -1470,16 +1470,17 @@ static int sh_mmcif_probe(struct platform_device *pdev)mutex_init (&host->thread_lock); -clk_disable_unprepare (host->hclk); ret =mmc_add_host (mmc);if (ret <0 ) goto emmcaddh;dev_pm_qos_expose_latency_limit (&pdev->dev,100 ); -dev_info (&pdev->dev,"driver version %s\n" ,DRIVER_VERSION ); -dev_dbg (&pdev->dev,"chip ver H'%04x\n" , -sh_mmcif_readl (host->addr,MMCIF_CE_VERSION ) &0x0000ffff ); +dev_info (&pdev->dev,"Chip version 0x%04x, clock rate %luMHz\n" , +sh_mmcif_readl (host->addr,MMCIF_CE_VERSION ) &0xffff , +clk_get_rate (host->hclk) /1000000UL ); + +clk_disable_unprepare (host->hclk);return ret; emmcaddh:
Signature · 1 line
1.9.0
PATCH v2 2/6 mmc: sh-mmcif: use devm_ for ioremap
In reply to Ben DooksStart tidying the probe/release code by using devm_ioremap_resource() to map the IO registers.
---
Fixes from v1:
- return the PTR_ERR() from devm_ioremap
- remove error print as it already shows an error
--- drivers/mmc/host/sh_mmcif.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-)
drivers/mmc/host/sh_mmcif.c +6 -18
@@ -1379,22 +1379,15 @@ static int sh_mmcif_probe(struct platform_device *pdev)dev_err (&pdev->dev,"Get irq error\n" );return -ENXIO ; } + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res) { -dev_err (&pdev->dev,"platform_get_resource error.\n" ); -return -ENXIO ; - } - reg =ioremap (res->start,resource_size (res)); -if (!reg) { -dev_err (&pdev->dev,"ioremap error.\n" ); -return -ENOMEM ; - } + reg =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (reg)) +return PTR_ERR (reg); mmc =mmc_alloc_host (sizeof (struct sh_mmcif_host ), &pdev->dev); -if (!mmc) { - ret = -ENOMEM ; - goto ealloch; - } +if (!mmc) +return -ENOMEM ; ret =mmc_of_parse (mmc);if (ret <0 )
@@ -1499,8 +1492,6 @@ eclkget:pm_runtime_disable (&pdev->dev); eofparse:mmc_free_host (mmc); -ealloch: -iounmap (reg);return ret; }
@@ -1525,9 +1516,6 @@ static int sh_mmcif_remove(struct platform_device *pdev)*/ cancel_delayed_work_sync (&host->timeout_work); -if (host->addr) -iounmap (host->addr); - irq[0 ] =platform_get_irq (pdev,0 ); irq[1 ] =platform_get_irq (pdev,1 );
Signature · 1 line
1.9.0
PATCH v2 3/6 mmc: sh-mmcif: use devm_ for clock management
In reply to Ben DooksUse the devm_clk_get() code to get the clock and allow it to be freed automatically on release.
--- drivers/mmc/host/sh_mmcif.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
drivers/mmc/host/sh_mmcif.c +8 -10
@@ -1391,7 +1391,7 @@ static int sh_mmcif_probe(struct platform_device *pdev) ret =mmc_of_parse (mmc);if (ret <0 ) - goto eofparse; + goto err_host; host =mmc_priv (mmc); host->mmc = mmc;
@@ -1421,19 +1421,19 @@ static int sh_mmcif_probe(struct platform_device *pdev)pm_runtime_enable (&pdev->dev); host->power = false; - host->hclk =clk_get (&pdev->dev,NULL ); + host->hclk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (host->hclk)) { ret =PTR_ERR (host->hclk);dev_err (&pdev->dev,"cannot get clock: %d\n" , ret); - goto eclkget; + goto err_pm; } ret =sh_mmcif_clk_update (host);if (ret <0 ) - goto eclkupdate; + goto err_pm; ret =pm_runtime_resume (&pdev->dev);if (ret <0 ) - goto eresume; + goto err_clk;INIT_DELAYED_WORK (&host->timeout_work, mmcif_timeout_work);
@@ -1484,13 +1484,11 @@ ereqirq1:free_irq (irq[0 ], host); ereqirq0:pm_runtime_suspend (&pdev->dev); -eresume: +err_clk:clk_disable_unprepare (host->hclk); -eclkupdate: -clk_put (host->hclk); -eclkget: +err_pm:pm_runtime_disable (&pdev->dev); -eofparse: +err_host:mmc_free_host (mmc);return ret; }
Signature · 1 line
1.9.0
PATCH v2 4/6 mmc: sh-mmcif: use devm_ for irq management
In reply to Ben DooksUse devm_request_threaded_irq() for the host interrupt handlers so we do not have to worry about freeing them on exit or error. Tidies up the exit path code for the driver.
--- drivers/mmc/host/sh_mmcif.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-)
drivers/mmc/host/sh_mmcif.c +8 -18
@@ -1441,17 +1441,19 @@ static int sh_mmcif_probe(struct platform_device *pdev)sh_mmcif_writel (host->addr,MMCIF_CE_INT_MASK ,MASK_ALL ); name = irq[1 ] <0 ?dev_name (&pdev->dev) :"sh_mmc:error" ; - ret =request_threaded_irq (irq[0 ], sh_mmcif_intr, sh_mmcif_irqt,0 , name, host); + ret =devm_request_threaded_irq (&pdev->dev, irq[0 ], sh_mmcif_intr, + sh_mmcif_irqt,0 , name, host);if (ret) {dev_err (&pdev->dev,"request_irq error (%s)\n" , name); - goto ereqirq0; + goto err_irq; }if (irq[1 ] >=0 ) { - ret =request_threaded_irq (irq[1 ], sh_mmcif_intr, sh_mmcif_irqt, -0 ,"sh_mmc:int" , host); + ret =devm_request_threaded_irq (&pdev->dev, irq[1 ], + sh_mmcif_intr, sh_mmcif_irqt, +0 ,"sh_mmc:int" , host);if (ret) {dev_err (&pdev->dev,"request_irq error (sh_mmc:int)\n" ); - goto ereqirq1; + goto err_irq; } }
@@ -1478,11 +1480,7 @@ static int sh_mmcif_probe(struct platform_device *pdev) emmcaddh: erqcd: -if (irq[1 ] >=0 ) -free_irq (irq[1 ], host); -ereqirq1: -free_irq (irq[0 ], host); -ereqirq0: +err_irq:pm_runtime_suspend (&pdev->dev); err_clk:clk_disable_unprepare (host->hclk);
@@ -1496,7 +1494,6 @@ err_host:static int sh_mmcif_remove (struct platform_device *pdev) {struct sh_mmcif_host *host =platform_get_drvdata (pdev); -int irq[2 ]; host->dying = true;clk_prepare_enable (host->hclk);
@@ -1514,13 +1511,6 @@ static int sh_mmcif_remove(struct platform_device *pdev)*/ cancel_delayed_work_sync (&host->timeout_work); - irq[0 ] =platform_get_irq (pdev,0 ); - irq[1 ] =platform_get_irq (pdev,1 ); - -free_irq (irq[0 ], host); -if (irq[1 ] >=0 ) -free_irq (irq[1 ], host); -clk_disable_unprepare (host->hclk);mmc_free_host (host->mmc);pm_runtime_put_sync (&pdev->dev);
Signature · 1 line
1.9.0
PATCH v2 5/6 mmc: sh-mmcif: no need to call pm_runtime_suspend on error
In reply to Ben DooksThe pm_runtime call should implicitly disable the device once the probe is over if there is no explicit reference gained. There is no need to call pm_runtime_suspend() before the pm_runtime_disable() call.
--- drivers/mmc/host/sh_mmcif.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mmc/host/sh_mmcif.c +2 -4
@@ -1445,7 +1445,7 @@ static int sh_mmcif_probe(struct platform_device *pdev) sh_mmcif_irqt, 0, name, host);if (ret) {dev_err (&pdev->dev,"request_irq error (%s)\n" , name); - goto err_irq; + goto err_clk; }if (irq[1 ] >=0 ) { ret = devm_request_threaded_irq(&pdev->dev, irq[1],
@@ -1453,7 +1453,7 @@ static int sh_mmcif_probe(struct platform_device *pdev) 0, "sh_mmc:int", host);if (ret) {dev_err (&pdev->dev,"request_irq error (sh_mmc:int)\n" ); - goto err_irq; + goto err_clk; } }
@@ -1480,8 +1480,6 @@ static int sh_mmcif_probe(struct platform_device *pdev) emmcaddh: erqcd: -err_irq: -pm_runtime_suspend (&pdev->dev); err_clk:clk_disable_unprepare (host->hclk); err_pm:
Signature · 1 line
1.9.0
PATCH v2 6/6 mmc: sh-mmcif: final error path cleanup
In reply to Ben DooksRemove the error path items that are no longer needed. The mmc card-detect code cleans up after itself (and registers with devm) and the host error is the same as the clock disable.
--- drivers/mmc/host/sh_mmcif.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/mmc/host/sh_mmcif.c +2 -4
@@ -1460,14 +1460,14 @@ static int sh_mmcif_probe(struct platform_device *pdev)if (pd && pd->use_cd_gpio) { ret =mmc_gpio_request_cd (mmc, pd->cd_gpio,0 );if (ret <0 ) - goto erqcd; + goto err_clk; }mutex_init (&host->thread_lock); ret =mmc_add_host (mmc);if (ret <0 ) - goto emmcaddh; + goto err_clk;dev_pm_qos_expose_latency_limit (&pdev->dev,100 );
@@ -1478,8 +1478,6 @@ static int sh_mmcif_probe(struct platform_device *pdev)clk_disable_unprepare (host->hclk);return ret; -emmcaddh: -erqcd: err_clk:clk_disable_unprepare (host->hclk); err_pm:
Signature · 1 line
1.9.0
Laurent Pinchart
Reviewed-byQuoted 7 lines · On Tuesday 01 April 2014 13:01:40 Ben Dooks wrote:
This is a second round of the mmcif cleanups
Changes since v1:
- fix issues with
devm_ioremapreturn, and error printing
- change the initial print
- fix issue with disabling clock
For the whole series,
Signature · 3 lines
Regards, Laurent Pinchart
Quoted 5 lines · Laurent Pinchart
Quoted 4 lines · On Tuesday 01 April 2014 13:01:40 Ben Dooks wrote:
This is a second round of the mmcif cleanups
Changes since v1:
Quoted 7 lines
Quoted 3 lines
- fix issues with
devm_ioremapreturn, and error printing
- change the initial print
- fix issue with disabling clockFor the whole series,
Reviewed-by Laurent Pinchart <[email protected]>
Thanks, guess this is too late for the current merge window now.
Signature · 2 lines
Ben Dooks http://www.codethink.co.uk/ Senior Engineer Codethink - Providing Genius