aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/au1x/ac97c.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/au1x/ac97c.c')
-rw-r--r--sound/soc/au1x/ac97c.c42
1 files changed, 14 insertions, 28 deletions
diff --git a/sound/soc/au1x/ac97c.c b/sound/soc/au1x/ac97c.c
index 726bd651a105..c5ac2449563a 100644
--- a/sound/soc/au1x/ac97c.c
+++ b/sound/soc/au1x/ac97c.c
@@ -195,7 +195,7 @@ static int alchemy_ac97c_startup(struct snd_pcm_substream *substream,
195 return 0; 195 return 0;
196} 196}
197 197
198static struct snd_soc_dai_ops alchemy_ac97c_ops = { 198static const struct snd_soc_dai_ops alchemy_ac97c_ops = {
199 .startup = alchemy_ac97c_startup, 199 .startup = alchemy_ac97c_startup,
200}; 200};
201 201
@@ -229,35 +229,34 @@ static int __devinit au1xac97c_drvprobe(struct platform_device *pdev)
229 struct resource *iores, *dmares; 229 struct resource *iores, *dmares;
230 struct au1xpsc_audio_data *ctx; 230 struct au1xpsc_audio_data *ctx;
231 231
232 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); 232 ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
233 if (!ctx) 233 if (!ctx)
234 return -ENOMEM; 234 return -ENOMEM;
235 235
236 mutex_init(&ctx->lock); 236 mutex_init(&ctx->lock);
237 237
238 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); 238 iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
239 if (!iores) { 239 if (!iores)
240 ret = -ENODEV; 240 return -ENODEV;
241 goto out0;
242 }
243 241
244 ret = -EBUSY; 242 if (!devm_request_mem_region(&pdev->dev, iores->start,
245 if (!request_mem_region(iores->start, resource_size(iores), 243 resource_size(iores),
246 pdev->name)) 244 pdev->name))
247 goto out0; 245 return -EBUSY;
248 246
249 ctx->mmio = ioremap_nocache(iores->start, resource_size(iores)); 247 ctx->mmio = devm_ioremap_nocache(&pdev->dev, iores->start,
248 resource_size(iores));
250 if (!ctx->mmio) 249 if (!ctx->mmio)
251 goto out1; 250 return -EBUSY;
252 251
253 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0); 252 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
254 if (!dmares) 253 if (!dmares)
255 goto out2; 254 return -EBUSY;
256 ctx->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start; 255 ctx->dmaids[SNDRV_PCM_STREAM_PLAYBACK] = dmares->start;
257 256
258 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1); 257 dmares = platform_get_resource(pdev, IORESOURCE_DMA, 1);
259 if (!dmares) 258 if (!dmares)
260 goto out2; 259 return -EBUSY;
261 ctx->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start; 260 ctx->dmaids[SNDRV_PCM_STREAM_CAPTURE] = dmares->start;
262 261
263 /* switch it on */ 262 /* switch it on */
@@ -271,33 +270,20 @@ static int __devinit au1xac97c_drvprobe(struct platform_device *pdev)
271 270
272 ret = snd_soc_register_dai(&pdev->dev, &au1xac97c_dai_driver); 271 ret = snd_soc_register_dai(&pdev->dev, &au1xac97c_dai_driver);
273 if (ret) 272 if (ret)
274 goto out2; 273 return ret;
275 274
276 ac97c_workdata = ctx; 275 ac97c_workdata = ctx;
277 return 0; 276 return 0;
278
279out2:
280 iounmap(ctx->mmio);
281out1:
282 release_mem_region(iores->start, resource_size(iores));
283out0:
284 kfree(ctx);
285 return ret;
286} 277}
287 278
288static int __devexit au1xac97c_drvremove(struct platform_device *pdev) 279static int __devexit au1xac97c_drvremove(struct platform_device *pdev)
289{ 280{
290 struct au1xpsc_audio_data *ctx = platform_get_drvdata(pdev); 281 struct au1xpsc_audio_data *ctx = platform_get_drvdata(pdev);
291 struct resource *r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
292 282
293 snd_soc_unregister_dai(&pdev->dev); 283 snd_soc_unregister_dai(&pdev->dev);
294 284
295 WR(ctx, AC97_ENABLE, EN_D); /* clock off, disable */ 285 WR(ctx, AC97_ENABLE, EN_D); /* clock off, disable */
296 286
297 iounmap(ctx->mmio);
298 release_mem_region(r->start, resource_size(r));
299 kfree(ctx);
300
301 ac97c_workdata = NULL; /* MDEV */ 287 ac97c_workdata = NULL; /* MDEV */
302 288
303 return 0; 289 return 0;