[1/1] ASoC: dwc: Use devm_ioremap_shared_resource
diff mbox

Message ID 1518767009-15232-2-git-send-email-akshu.agrawal@amd.com
State New
Headers show

Commit Message

Agrawal, Akshu Feb. 16, 2018, 7:43 a.m. UTC
In the event when resgiters are same, this patch checks shared
flag and uses devm_ioremap_shared_resource for mapping. This allows
us to have 2 separate cpu dais for playback and capture having same
register set.

Signed-off-by: Akshu Agrawal <akshu.agrawal@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
---
 include/sound/designware_i2s.h |  1 +
 sound/soc/dwc/dwc-i2s.c        | 18 +++++++++++++++---
 2 files changed, 16 insertions(+), 3 deletions(-)

Comments

kbuild test robot Feb. 18, 2018, 5:33 a.m. UTC | #1
Hi Akshu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on asoc/for-next]
[also build test ERROR on v4.16-rc1 next-20180216]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Akshu-Agrawal/Use-of-shared-resource-in-designware/20180218-130807
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: i386-randconfig-x019-201807 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All error/warnings (new ones prefixed by >>):

   sound/soc/dwc/dwc-i2s.c: In function 'dw_i2s_probe':
>> sound/soc/dwc/dwc-i2s.c:642:5: error: implicit declaration of function 'devm_ioremap_shared_resource'; did you mean 'devm_ioremap_resource'? [-Werror=implicit-function-declaration]
        devm_ioremap_shared_resource(&pdev->dev, res);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
        devm_ioremap_resource
>> sound/soc/dwc/dwc-i2s.c:641:18: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       dev->i2s_base =
                     ^
   cc1: some warnings being treated as errors

vim +642 sound/soc/dwc/dwc-i2s.c

   613	
   614	static int dw_i2s_probe(struct platform_device *pdev)
   615	{
   616		const struct i2s_platform_data *pdata = pdev->dev.platform_data;
   617		struct dw_i2s_dev *dev;
   618		struct resource *res;
   619		int ret, irq;
   620		struct snd_soc_dai_driver *dw_i2s_dai;
   621		const char *clk_id;
   622	
   623		dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
   624		if (!dev)
   625			return -ENOMEM;
   626	
   627		dw_i2s_dai = devm_kzalloc(&pdev->dev, sizeof(*dw_i2s_dai), GFP_KERNEL);
   628		if (!dw_i2s_dai)
   629			return -ENOMEM;
   630	
   631		dw_i2s_dai->ops = &dw_i2s_dai_ops;
   632		dw_i2s_dai->suspend = dw_i2s_suspend;
   633		dw_i2s_dai->resume = dw_i2s_resume;
   634	
   635		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
   636		/* For devices which use the same registers for playback
   637		 * and capture, we would set shared flag for registering
   638		 * the second cpu dai.
   639		 */
   640		if (pdata && pdata->shared) {
 > 641				dev->i2s_base =
 > 642					devm_ioremap_shared_resource(&pdev->dev, res);
   643				if (IS_ERR(dev->i2s_base))
   644					return PTR_ERR(dev->i2s_base);
   645		} else {
   646				dev->i2s_base =
   647					devm_ioremap_resource(&pdev->dev, res);
   648				if (IS_ERR(dev->i2s_base))
   649					return PTR_ERR(dev->i2s_base);
   650		}
   651	
   652		dev->dev = &pdev->dev;
   653	
   654		irq = platform_get_irq(pdev, 0);
   655		if (irq >= 0) {
   656			ret = devm_request_irq(&pdev->dev, irq, i2s_irq_handler, 0,
   657					pdev->name, dev);
   658			if (ret < 0) {
   659				dev_err(&pdev->dev, "failed to request irq\n");
   660				return ret;
   661			}
   662		}
   663	
   664		dev->i2s_reg_comp1 = I2S_COMP_PARAM_1;
   665		dev->i2s_reg_comp2 = I2S_COMP_PARAM_2;
   666		if (pdata) {
   667			dev->capability = pdata->cap;
   668			clk_id = NULL;
   669			dev->quirks = pdata->quirks;
   670			if (dev->quirks & DW_I2S_QUIRK_COMP_REG_OFFSET) {
   671				dev->i2s_reg_comp1 = pdata->i2s_reg_comp1;
   672				dev->i2s_reg_comp2 = pdata->i2s_reg_comp2;
   673			}
   674			ret = dw_configure_dai_by_pd(dev, dw_i2s_dai, res, pdata);
   675		} else {
   676			clk_id = "i2sclk";
   677			ret = dw_configure_dai_by_dt(dev, dw_i2s_dai, res);
   678		}
   679		if (ret < 0)
   680			return ret;
   681	
   682		if (dev->capability & DW_I2S_MASTER) {
   683			if (pdata) {
   684				dev->i2s_clk_cfg = pdata->i2s_clk_cfg;
   685				if (!dev->i2s_clk_cfg) {
   686					dev_err(&pdev->dev, "no clock configure method\n");
   687					return -ENODEV;
   688				}
   689			}
   690			dev->clk = devm_clk_get(&pdev->dev, clk_id);
   691	
   692			if (IS_ERR(dev->clk))
   693				return PTR_ERR(dev->clk);
   694	
   695			ret = clk_prepare_enable(dev->clk);
   696			if (ret < 0)
   697				return ret;
   698		}
   699	
   700		dev_set_drvdata(&pdev->dev, dev);
   701		ret = devm_snd_soc_register_component(&pdev->dev, &dw_i2s_component,
   702						 dw_i2s_dai, 1);
   703		if (ret != 0) {
   704			dev_err(&pdev->dev, "not able to register dai\n");
   705			goto err_clk_disable;
   706		}
   707	
   708		if (!pdata) {
   709			if (irq >= 0) {
   710				ret = dw_pcm_register(pdev);
   711				dev->use_pio = true;
   712			} else {
   713				ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL,
   714						0);
   715				dev->use_pio = false;
   716			}
   717	
   718			if (ret) {
   719				dev_err(&pdev->dev, "could not register pcm: %d\n",
   720						ret);
   721				goto err_clk_disable;
   722			}
   723		}
   724	
   725		pm_runtime_enable(&pdev->dev);
   726		return 0;
   727	
   728	err_clk_disable:
   729		if (dev->capability & DW_I2S_MASTER)
   730			clk_disable_unprepare(dev->clk);
   731		return ret;
   732	}
   733	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kbuild test robot Feb. 18, 2018, 6:45 a.m. UTC | #2
Hi Akshu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on asoc/for-next]
[also build test ERROR on v4.16-rc1 next-20180216]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Akshu-Agrawal/Use-of-shared-resource-in-designware/20180218-130807
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: x86_64-randconfig-g0-02181159 (attached as .config)
compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   sound/soc/dwc/dwc-i2s.c: In function 'dw_i2s_probe':
>> sound/soc/dwc/dwc-i2s.c:642:5: error: implicit declaration of function 'devm_ioremap_shared_resource' [-Werror=implicit-function-declaration]
        devm_ioremap_shared_resource(&pdev->dev, res);
        ^
   sound/soc/dwc/dwc-i2s.c:641:18: warning: assignment makes pointer from integer without a cast
       dev->i2s_base =
                     ^
   cc1: some warnings being treated as errors

vim +/devm_ioremap_shared_resource +642 sound/soc/dwc/dwc-i2s.c

   613	
   614	static int dw_i2s_probe(struct platform_device *pdev)
   615	{
   616		const struct i2s_platform_data *pdata = pdev->dev.platform_data;
   617		struct dw_i2s_dev *dev;
   618		struct resource *res;
   619		int ret, irq;
   620		struct snd_soc_dai_driver *dw_i2s_dai;
   621		const char *clk_id;
   622	
   623		dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
   624		if (!dev)
   625			return -ENOMEM;
   626	
   627		dw_i2s_dai = devm_kzalloc(&pdev->dev, sizeof(*dw_i2s_dai), GFP_KERNEL);
   628		if (!dw_i2s_dai)
   629			return -ENOMEM;
   630	
   631		dw_i2s_dai->ops = &dw_i2s_dai_ops;
   632		dw_i2s_dai->suspend = dw_i2s_suspend;
   633		dw_i2s_dai->resume = dw_i2s_resume;
   634	
   635		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
   636		/* For devices which use the same registers for playback
   637		 * and capture, we would set shared flag for registering
   638		 * the second cpu dai.
   639		 */
   640		if (pdata && pdata->shared) {
   641				dev->i2s_base =
 > 642					devm_ioremap_shared_resource(&pdev->dev, res);
   643				if (IS_ERR(dev->i2s_base))
   644					return PTR_ERR(dev->i2s_base);
   645		} else {
   646				dev->i2s_base =
   647					devm_ioremap_resource(&pdev->dev, res);
   648				if (IS_ERR(dev->i2s_base))
   649					return PTR_ERR(dev->i2s_base);
   650		}
   651	
   652		dev->dev = &pdev->dev;
   653	
   654		irq = platform_get_irq(pdev, 0);
   655		if (irq >= 0) {
   656			ret = devm_request_irq(&pdev->dev, irq, i2s_irq_handler, 0,
   657					pdev->name, dev);
   658			if (ret < 0) {
   659				dev_err(&pdev->dev, "failed to request irq\n");
   660				return ret;
   661			}
   662		}
   663	
   664		dev->i2s_reg_comp1 = I2S_COMP_PARAM_1;
   665		dev->i2s_reg_comp2 = I2S_COMP_PARAM_2;
   666		if (pdata) {
   667			dev->capability = pdata->cap;
   668			clk_id = NULL;
   669			dev->quirks = pdata->quirks;
   670			if (dev->quirks & DW_I2S_QUIRK_COMP_REG_OFFSET) {
   671				dev->i2s_reg_comp1 = pdata->i2s_reg_comp1;
   672				dev->i2s_reg_comp2 = pdata->i2s_reg_comp2;
   673			}
   674			ret = dw_configure_dai_by_pd(dev, dw_i2s_dai, res, pdata);
   675		} else {
   676			clk_id = "i2sclk";
   677			ret = dw_configure_dai_by_dt(dev, dw_i2s_dai, res);
   678		}
   679		if (ret < 0)
   680			return ret;
   681	
   682		if (dev->capability & DW_I2S_MASTER) {
   683			if (pdata) {
   684				dev->i2s_clk_cfg = pdata->i2s_clk_cfg;
   685				if (!dev->i2s_clk_cfg) {
   686					dev_err(&pdev->dev, "no clock configure method\n");
   687					return -ENODEV;
   688				}
   689			}
   690			dev->clk = devm_clk_get(&pdev->dev, clk_id);
   691	
   692			if (IS_ERR(dev->clk))
   693				return PTR_ERR(dev->clk);
   694	
   695			ret = clk_prepare_enable(dev->clk);
   696			if (ret < 0)
   697				return ret;
   698		}
   699	
   700		dev_set_drvdata(&pdev->dev, dev);
   701		ret = devm_snd_soc_register_component(&pdev->dev, &dw_i2s_component,
   702						 dw_i2s_dai, 1);
   703		if (ret != 0) {
   704			dev_err(&pdev->dev, "not able to register dai\n");
   705			goto err_clk_disable;
   706		}
   707	
   708		if (!pdata) {
   709			if (irq >= 0) {
   710				ret = dw_pcm_register(pdev);
   711				dev->use_pio = true;
   712			} else {
   713				ret = devm_snd_dmaengine_pcm_register(&pdev->dev, NULL,
   714						0);
   715				dev->use_pio = false;
   716			}
   717	
   718			if (ret) {
   719				dev_err(&pdev->dev, "could not register pcm: %d\n",
   720						ret);
   721				goto err_clk_disable;
   722			}
   723		}
   724	
   725		pm_runtime_enable(&pdev->dev);
   726		return 0;
   727	
   728	err_clk_disable:
   729		if (dev->capability & DW_I2S_MASTER)
   730			clk_disable_unprepare(dev->clk);
   731		return ret;
   732	}
   733	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Patch
diff mbox

diff --git a/include/sound/designware_i2s.h b/include/sound/designware_i2s.h
index 830f5ca..a43a3708 100644
--- a/include/sound/designware_i2s.h
+++ b/include/sound/designware_i2s.h
@@ -56,6 +56,7 @@  struct i2s_platform_data {
 	void *capture_dma_data;
 	bool (*filter)(struct dma_chan *chan, void *slave);
 	int (*i2s_clk_cfg)(struct i2s_clk_config_data *config);
+	bool shared;
 };
 
 struct i2s_dma_data {
diff --git a/sound/soc/dwc/dwc-i2s.c b/sound/soc/dwc/dwc-i2s.c
index e27e21f..1e7c285 100644
--- a/sound/soc/dwc/dwc-i2s.c
+++ b/sound/soc/dwc/dwc-i2s.c
@@ -629,9 +629,21 @@  static int dw_i2s_probe(struct platform_device *pdev)
 	dw_i2s_dai->resume = dw_i2s_resume;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	dev->i2s_base = devm_ioremap_resource(&pdev->dev, res);
-	if (IS_ERR(dev->i2s_base))
-		return PTR_ERR(dev->i2s_base);
+	/* For devices which use the same registers for playback
+	 * and capture, we would set shared flag for registering
+	 * the second cpu dai.
+	 */
+	if (pdata && pdata->shared) {
+			dev->i2s_base =
+				devm_ioremap_shared_resource(&pdev->dev, res);
+			if (IS_ERR(dev->i2s_base))
+				return PTR_ERR(dev->i2s_base);
+	} else {
+			dev->i2s_base =
+				devm_ioremap_resource(&pdev->dev, res);
+			if (IS_ERR(dev->i2s_base))
+				return PTR_ERR(dev->i2s_base);
+	}
 
 	dev->dev = &pdev->dev;