diff options
author | Peter Ujfalusi <peter.ujfalusi@ti.com> | 2013-01-11 11:01:01 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-01-11 18:54:57 -0500 |
commit | 9523fcdcc02e812f3a0f4849b3af1b295ad50470 (patch) | |
tree | 30073e8ddd54f26a6c6b401bc5fc14bd345990bf | |
parent | 156db9f3bb3c210cdf905172f6063c90c4a62c3c (diff) |
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>
-rw-r--r-- | sound/soc/codecs/twl6040.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index 86f12a498f38..90b721e437a3 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c | |||
@@ -1131,9 +1131,10 @@ static int twl6040_probe(struct snd_soc_codec *codec) | |||
1131 | struct platform_device, dev); | 1131 | struct platform_device, dev); |
1132 | int ret = 0; | 1132 | int ret = 0; |
1133 | 1133 | ||
1134 | priv = kzalloc(sizeof(struct twl6040_data), GFP_KERNEL); | 1134 | priv = devm_kzalloc(codec->dev, sizeof(*priv), GFP_KERNEL); |
1135 | if (priv == NULL) | 1135 | if (priv == NULL) |
1136 | return -ENOMEM; | 1136 | return -ENOMEM; |
1137 | |||
1137 | snd_soc_codec_set_drvdata(codec, priv); | 1138 | snd_soc_codec_set_drvdata(codec, priv); |
1138 | 1139 | ||
1139 | priv->codec = codec; | 1140 | priv->codec = codec; |
@@ -1158,25 +1159,23 @@ static int twl6040_probe(struct snd_soc_codec *codec) | |||
1158 | priv->plug_irq = platform_get_irq(pdev, 0); | 1159 | priv->plug_irq = platform_get_irq(pdev, 0); |
1159 | if (priv->plug_irq < 0) { | 1160 | if (priv->plug_irq < 0) { |
1160 | dev_err(codec->dev, "invalid irq\n"); | 1161 | dev_err(codec->dev, "invalid irq\n"); |
1161 | ret = -EINVAL; | 1162 | return -EINVAL; |
1162 | goto work_err; | ||
1163 | } | 1163 | } |
1164 | 1164 | ||
1165 | priv->workqueue = alloc_workqueue("twl6040-codec", 0, 0); | 1165 | priv->workqueue = alloc_workqueue("twl6040-codec", 0, 0); |
1166 | if (!priv->workqueue) { | 1166 | if (!priv->workqueue) |
1167 | ret = -ENOMEM; | 1167 | return -ENOMEM; |
1168 | goto work_err; | ||
1169 | } | ||
1170 | 1168 | ||
1171 | INIT_DELAYED_WORK(&priv->hs_jack.work, twl6040_accessory_work); | 1169 | INIT_DELAYED_WORK(&priv->hs_jack.work, twl6040_accessory_work); |
1172 | 1170 | ||
1173 | mutex_init(&priv->mutex); | 1171 | mutex_init(&priv->mutex); |
1174 | 1172 | ||
1175 | ret = request_threaded_irq(priv->plug_irq, NULL, twl6040_audio_handler, | 1173 | ret = devm_request_threaded_irq(codec->dev, priv->plug_irq, NULL, |
1176 | IRQF_NO_SUSPEND, "twl6040_irq_plug", codec); | 1174 | twl6040_audio_handler, IRQF_NO_SUSPEND, |
1175 | "twl6040_irq_plug", codec); | ||
1177 | if (ret) { | 1176 | if (ret) { |
1178 | dev_err(codec->dev, "PLUG IRQ request failed: %d\n", ret); | 1177 | dev_err(codec->dev, "PLUG IRQ request failed: %d\n", ret); |
1179 | goto plugirq_err; | 1178 | goto err; |
1180 | } | 1179 | } |
1181 | 1180 | ||
1182 | twl6040_init_chip(codec); | 1181 | twl6040_init_chip(codec); |
@@ -1186,12 +1185,8 @@ static int twl6040_probe(struct snd_soc_codec *codec) | |||
1186 | if (!ret) | 1185 | if (!ret) |
1187 | return 0; | 1186 | return 0; |
1188 | 1187 | ||
1189 | /* Error path */ | 1188 | err: |
1190 | free_irq(priv->plug_irq, codec); | ||
1191 | plugirq_err: | ||
1192 | destroy_workqueue(priv->workqueue); | 1189 | destroy_workqueue(priv->workqueue); |
1193 | work_err: | ||
1194 | kfree(priv); | ||
1195 | return ret; | 1190 | return ret; |
1196 | } | 1191 | } |
1197 | 1192 | ||
@@ -1200,9 +1195,7 @@ static int twl6040_remove(struct snd_soc_codec *codec) | |||
1200 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); | 1195 | struct twl6040_data *priv = snd_soc_codec_get_drvdata(codec); |
1201 | 1196 | ||
1202 | twl6040_set_bias_level(codec, SND_SOC_BIAS_OFF); | 1197 | twl6040_set_bias_level(codec, SND_SOC_BIAS_OFF); |
1203 | free_irq(priv->plug_irq, codec); | ||
1204 | destroy_workqueue(priv->workqueue); | 1198 | destroy_workqueue(priv->workqueue); |
1205 | kfree(priv); | ||
1206 | 1199 | ||
1207 | return 0; | 1200 | return 0; |
1208 | } | 1201 | } |