From c48bd985438bd100ddb9d0daa5bf711b5d5ddcb4 Mon Sep 17 00:00:00 2001 From: Misael Lopez Cruz Date: Mon, 28 Feb 2011 14:48:14 -0600 Subject: [PATCH 43/60] ASoC: McPDM: Avoid multiple irq request/free commit f16d91f9846e5976b0f7ef7cdd963c1607305649 upstream McPDM irq request and free was associated to mcpdm_request and mcpdm_free APIs, which are called when audio stream is opened and closed, respectively. These multiple calls are unnecessary as irq can be requested when driver is probed and released during driver removal. Change-Id: I3afcae888eb0baffd8a3f85878e30b61c70c73c8 Signed-off-by: Misael Lopez Cruz Integrated-by: Jingdong Lu --- sound/soc/omap/omap-mcpdm.c | 34 ++++++++++++++-------------------- 1 files changed, 14 insertions(+), 20 deletions(-) diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index f2e6ac3..a68546d 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c @@ -417,22 +417,20 @@ static int omap_mcpdm_request(struct omap_mcpdm *mcpdm) { struct platform_device *pdev; struct omap_mcpdm_platform_data *pdata; - int ret; int ctrl; int attemps = 0; pdev = to_platform_device(mcpdm->dev); pdata = pdev->dev.platform_data; - pm_runtime_get_sync(&pdev->dev); - if (!mcpdm->free) { dev_err(mcpdm->dev, "McPDM interface is in use\n"); - ret = -EBUSY; - goto err; + return -EBUSY; } mcpdm->free = 0; + pm_runtime_get_sync(&pdev->dev); + /* Perform SW RESET of McPDM IP */ ctrl = omap_mcpdm_read(mcpdm, MCPDM_SYSCONFIG); ctrl |= MCPDM_SOFTRESET; @@ -448,13 +446,6 @@ static int omap_mcpdm_request(struct omap_mcpdm *mcpdm) /* Disable lines while request is ongoing */ omap_mcpdm_write(mcpdm, MCPDM_CTRL, 0x00); - ret = request_irq(mcpdm->irq, omap_mcpdm_irq_handler, - 0, "McPDM", (void *)mcpdm); - if (ret) { - dev_err(mcpdm->dev, "Request for McPDM IRQ failed\n"); - goto err; - } - if (omap_rev() != OMAP4430_REV_ES1_0) { /* Enable McPDM watch dog for ES above ES 1.0 to avoid saturation */ ctrl = omap_mcpdm_read(mcpdm, MCPDM_CTRL); @@ -463,10 +454,6 @@ static int omap_mcpdm_request(struct omap_mcpdm *mcpdm) } return 0; - -err: - pm_runtime_put_sync(&pdev->dev); - return ret; } static void omap_mcpdm_free(struct omap_mcpdm *mcpdm) @@ -484,8 +471,6 @@ static void omap_mcpdm_free(struct omap_mcpdm *mcpdm) mcpdm->free = 1; pm_runtime_put_sync(&pdev->dev); - - free_irq(mcpdm->irq, (void *)mcpdm); } /* Enable/disable DC offset cancelation for the analog @@ -907,6 +892,13 @@ static __devinit int asoc_mcpdm_probe(struct platform_device *pdev) goto err_irq; } + ret = request_irq(mcpdm->irq, omap_mcpdm_irq_handler, + 0, "McPDM", mcpdm); + if (ret) { + dev_err(mcpdm->dev, "Request for McPDM IRQ failed: %d\n", ret); + goto err_irq; + } + pm_runtime_enable(&pdev->dev); mcpdm->dev = &pdev->dev; @@ -923,10 +915,12 @@ static __devinit int asoc_mcpdm_probe(struct platform_device *pdev) ret = snd_soc_register_dais(&pdev->dev, omap_mcpdm_dai, ARRAY_SIZE(omap_mcpdm_dai)); if (ret < 0) - goto err_irq; + goto err_dai; return 0; +err_dai: + free_irq(mcpdm->irq, mcpdm); err_irq: iounmap(mcpdm->io_base); err: @@ -940,7 +934,7 @@ static int __devexit asoc_mcpdm_remove(struct platform_device *pdev) snd_soc_unregister_dais(&pdev->dev, ARRAY_SIZE(omap_mcpdm_dai)); iounmap(mcpdm->io_base); - pm_runtime_put_sync(&pdev->dev); + free_irq(mcpdm->irq, mcpdm); kfree(mcpdm); return 0; } -- 1.7.4.1