ASoC: twl6040: Convert to use devm_* when possible
In this way we can clean up the probe and remove paths Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
This commit is contained in:
parent
156db9f3bb
commit
9523fcdcc0
@ -1131,9 +1131,10 @@ static int twl6040_probe(struct snd_soc_codec *codec)
|
|||||||
struct platform_device, dev);
|
struct platform_device, dev);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
priv = kzalloc(sizeof(struct twl6040_data), GFP_KERNEL);
|
priv = devm_kzalloc(codec->dev, sizeof(*priv), GFP_KERNEL);
|
||||||
if (priv == NULL)
|
if (priv == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
snd_soc_codec_set_drvdata(codec, priv);
|
snd_soc_codec_set_drvdata(codec, priv);
|
||||||
|
|
||||||
priv->codec = codec;
|
priv->codec = codec;
|
||||||
@ -1158,25 +1159,23 @@ static int twl6040_probe(struct snd_soc_codec *codec)
|
|||||||
priv->plug_irq = platform_get_irq(pdev, 0);
|
priv->plug_irq = platform_get_irq(pdev, 0);
|
||||||
if (priv->plug_irq < 0) {
|
if (priv->plug_irq < 0) {
|
||||||
dev_err(codec->dev, "invalid irq\n");
|
dev_err(codec->dev, "invalid irq\n");
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto work_err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->workqueue = alloc_workqueue("twl6040-codec", 0, 0);
|
priv->workqueue = alloc_workqueue("twl6040-codec", 0, 0);
|
||||||
if (!priv->workqueue) {
|
if (!priv->workqueue)
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto work_err;
|
|
||||||
}
|
|
||||||
|
|
||||||
INIT_DELAYED_WORK(&priv->hs_jack.work, twl6040_accessory_work);
|
INIT_DELAYED_WORK(&priv->hs_jack.work, twl6040_accessory_work);
|
||||||
|
|
||||||
mutex_init(&priv->mutex);
|
mutex_init(&priv->mutex);
|
||||||
|
|
||||||
ret = request_threaded_irq(priv->plug_irq, NULL, twl6040_audio_handler,
|
ret = devm_request_threaded_irq(codec->dev, priv->plug_irq, NULL,
|
||||||
IRQF_NO_SUSPEND, "twl6040_irq_plug", codec);
|
twl6040_audio_handler, IRQF_NO_SUSPEND,
|
||||||
|
"twl6040_irq_plug", codec);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(codec->dev, "PLUG IRQ request failed: %d\n", ret);
|
dev_err(codec->dev, "PLUG IRQ request failed: %d\n", ret);
|
||||||
goto plugirq_err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
twl6040_init_chip(codec);
|
twl6040_init_chip(codec);
|
||||||
@ -1186,12 +1185,8 @@ static int twl6040_probe(struct snd_soc_codec *codec)
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Error path */
|
err:
|
||||||
free_irq(priv->plug_irq, codec);
|
|
||||||
plugirq_err:
|
|
||||||
destroy_workqueue(priv->workqueue);
|
destroy_workqueue(priv->workqueue);
|
||||||
work_err:
|
|
||||||
kfree(priv);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1200,9 +1195,7 @@ static int twl6040_remove(struct snd_soc_codec *codec)
|
|||||||
struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
|
struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec);
|
||||||
|
|
||||||
twl6040_set_bias_level(codec, SND_SOC_BIAS_OFF);
|
twl6040_set_bias_level(codec, SND_SOC_BIAS_OFF);
|
||||||
free_irq(priv->plug_irq, codec);
|
|
||||||
destroy_workqueue(priv->workqueue);
|
destroy_workqueue(priv->workqueue);
|
||||||
kfree(priv);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user