Re: [PATCH v3 2/6] ASoC: amd: Refactoring of DAI from DMA driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




+static int acp3x_dai_probe(struct platform_device *pdev)
+{
+	int status;
+	struct resource *res;
+	struct i2s_dev_data *adata;
+
+	if (!pdev->dev.platform_data) {
+		dev_err(&pdev->dev, "platform_data not retrieved\n");
+		return -ENODEV;
+	}
+
+	adata = devm_kzalloc(&pdev->dev, sizeof(struct i2s_dev_data),
+			GFP_KERNEL);

if (!adata)
	return -ENOMEM;
	> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!res) {
+		dev_err(&pdev->dev, "IORESOURCE_MEM FAILED\n");
+		return -ENODEV;
+	}
+
+	adata->acp3x_base = devm_ioremap(&pdev->dev, res->start,
+			resource_size(res));
+	if (IS_ERR(adata->acp3x_base))
+		return PTR_ERR(adata->acp3x_base);
+
+	adata->i2s_irq = res->start;
+	dev_set_drvdata(&pdev->dev, adata);
+	status = devm_snd_soc_register_component(&pdev->dev,
+			&acp3x_dai_component,
+			&acp3x_i2s_dai, 1);
+	if (status) {
+		dev_err(&pdev->dev, "Fail to register acp i2s dai\n");
+		return -ENODEV;

if the probe fails for such errors, don't you have a memory leak?

+	}
+
+	pm_runtime_set_autosuspend_delay(&pdev->dev, 10000);
+	pm_runtime_use_autosuspend(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
+	return 0;

err:
	kree(adata)
	return ret;
?


  static const struct snd_pcm_hardware acp3x_pcm_hardware_playback = {
  	.info = SNDRV_PCM_INFO_INTERLEAVED |
  		SNDRV_PCM_INFO_BLOCK_TRANSFER |
@@ -279,7 +261,11 @@ static int acp3x_dma_open(struct snd_soc_component *component,
  			  struct snd_pcm_substream *substream)
  {
  	int ret = 0;
+

newline?

-
  static const struct snd_soc_component_driver acp3x_i2s_component = {
  	.name		= DRV_NAME,
  	.open		= acp3x_dma_open,
@@ -619,6 +415,9 @@ static int acp3x_audio_probe(struct platform_device *pdev)
  		return -ENODEV;
  	}
  	irqflags = *((unsigned int *)(pdev->dev.platform_data));
+	adata = devm_kzalloc(&pdev->dev, sizeof(*adata), GFP_KERNEL);
+	if (!adata)
+		return -ENOMEM;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  	if (!res) {
@@ -626,10 +425,6 @@ static int acp3x_audio_probe(struct platform_device *pdev)
  		return -ENODEV;
  	}
- adata = devm_kzalloc(&pdev->dev, sizeof(*adata), GFP_KERNEL);
-	if (!adata)
-		return -ENOMEM;
-

that part is hard to review with diff, please double-check the changes.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxx
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux