Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b960ce74 authored by Mark Brown's avatar Mark Brown
Browse files

ASoC: Convert Samsung I2S driver to devm_kzalloc()

parent f18b4e2e
Loading
Loading
Loading
Loading
+6 −14
Original line number Original line Diff line number Diff line
@@ -945,7 +945,7 @@ struct i2s_dai *i2s_alloc_dai(struct platform_device *pdev, bool sec)
{
{
	struct i2s_dai *i2s;
	struct i2s_dai *i2s;


	i2s = kzalloc(sizeof(struct i2s_dai), GFP_KERNEL);
	i2s = devm_kzalloc(&pdev->dev, sizeof(struct i2s_dai), GFP_KERNEL);
	if (i2s == NULL)
	if (i2s == NULL)
		return NULL;
		return NULL;


@@ -972,11 +972,9 @@ struct i2s_dai *i2s_alloc_dai(struct platform_device *pdev, bool sec)
		i2s->pdev = platform_device_register_resndata(NULL,
		i2s->pdev = platform_device_register_resndata(NULL,
				pdev->name, pdev->id + SAMSUNG_I2S_SECOFF,
				pdev->name, pdev->id + SAMSUNG_I2S_SECOFF,
				NULL, 0, NULL, 0);
				NULL, 0, NULL, 0);
		if (IS_ERR(i2s->pdev)) {
		if (IS_ERR(i2s->pdev))
			kfree(i2s);
			return NULL;
			return NULL;
	}
	}
	}


	/* Pre-assign snd_soc_dai_set_drvdata */
	/* Pre-assign snd_soc_dai_set_drvdata */
	dev_set_drvdata(&i2s->pdev->dev, i2s);
	dev_set_drvdata(&i2s->pdev->dev, i2s);
@@ -1048,7 +1046,7 @@ static __devinit int samsung_i2s_probe(struct platform_device *pdev)
	if (!pri_dai) {
	if (!pri_dai) {
		dev_err(&pdev->dev, "Unable to alloc I2S_pri\n");
		dev_err(&pdev->dev, "Unable to alloc I2S_pri\n");
		ret = -ENOMEM;
		ret = -ENOMEM;
		goto err1;
		goto err;
	}
	}


	pri_dai->dma_playback.dma_addr = regs_base + I2STXD;
	pri_dai->dma_playback.dma_addr = regs_base + I2STXD;
@@ -1073,7 +1071,7 @@ static __devinit int samsung_i2s_probe(struct platform_device *pdev)
		if (!sec_dai) {
		if (!sec_dai) {
			dev_err(&pdev->dev, "Unable to alloc I2S_sec\n");
			dev_err(&pdev->dev, "Unable to alloc I2S_sec\n");
			ret = -ENOMEM;
			ret = -ENOMEM;
			goto err2;
			goto err;
		}
		}
		sec_dai->dma_playback.dma_addr = regs_base + I2STXDS;
		sec_dai->dma_playback.dma_addr = regs_base + I2STXDS;
		sec_dai->dma_playback.client =
		sec_dai->dma_playback.client =
@@ -1092,17 +1090,13 @@ static __devinit int samsung_i2s_probe(struct platform_device *pdev)
	if (i2s_pdata->cfg_gpio && i2s_pdata->cfg_gpio(pdev)) {
	if (i2s_pdata->cfg_gpio && i2s_pdata->cfg_gpio(pdev)) {
		dev_err(&pdev->dev, "Unable to configure gpio\n");
		dev_err(&pdev->dev, "Unable to configure gpio\n");
		ret = -EINVAL;
		ret = -EINVAL;
		goto err3;
		goto err;
	}
	}


	snd_soc_register_dai(&pri_dai->pdev->dev, &pri_dai->i2s_dai_drv);
	snd_soc_register_dai(&pri_dai->pdev->dev, &pri_dai->i2s_dai_drv);


	return 0;
	return 0;
err3:
err:
	kfree(sec_dai);
err2:
	kfree(pri_dai);
err1:
	release_mem_region(regs_base, resource_size(res));
	release_mem_region(regs_base, resource_size(res));


	return ret;
	return ret;
@@ -1128,8 +1122,6 @@ static __devexit int samsung_i2s_remove(struct platform_device *pdev)
	i2s->pri_dai = NULL;
	i2s->pri_dai = NULL;
	i2s->sec_dai = NULL;
	i2s->sec_dai = NULL;


	kfree(i2s);

	snd_soc_unregister_dai(&pdev->dev);
	snd_soc_unregister_dai(&pdev->dev);


	return 0;
	return 0;