diff options
Diffstat (limited to 'sound/soc/nuc900/nuc900-ac97.c')
-rw-r--r-- | sound/soc/nuc900/nuc900-ac97.c | 60 |
1 files changed, 21 insertions, 39 deletions
diff --git a/sound/soc/nuc900/nuc900-ac97.c b/sound/soc/nuc900/nuc900-ac97.c index fe3285ceaf5b..f4c2417a8730 100644 --- a/sound/soc/nuc900/nuc900-ac97.c +++ b/sound/soc/nuc900/nuc900-ac97.c | |||
@@ -197,13 +197,12 @@ static void nuc900_ac97_cold_reset(struct snd_ac97 *ac97) | |||
197 | } | 197 | } |
198 | 198 | ||
199 | /* AC97 controller operations */ | 199 | /* AC97 controller operations */ |
200 | struct snd_ac97_bus_ops soc_ac97_ops = { | 200 | static struct snd_ac97_bus_ops nuc900_ac97_ops = { |
201 | .read = nuc900_ac97_read, | 201 | .read = nuc900_ac97_read, |
202 | .write = nuc900_ac97_write, | 202 | .write = nuc900_ac97_write, |
203 | .reset = nuc900_ac97_cold_reset, | 203 | .reset = nuc900_ac97_cold_reset, |
204 | .warm_reset = nuc900_ac97_warm_reset, | 204 | .warm_reset = nuc900_ac97_warm_reset, |
205 | } | 205 | }; |
206 | EXPORT_SYMBOL_GPL(soc_ac97_ops); | ||
207 | 206 | ||
208 | static int nuc900_ac97_trigger(struct snd_pcm_substream *substream, | 207 | static int nuc900_ac97_trigger(struct snd_pcm_substream *substream, |
209 | int cmd, struct snd_soc_dai *dai) | 208 | int cmd, struct snd_soc_dai *dai) |
@@ -326,64 +325,52 @@ static int nuc900_ac97_drvprobe(struct platform_device *pdev) | |||
326 | if (nuc900_ac97_data) | 325 | if (nuc900_ac97_data) |
327 | return -EBUSY; | 326 | return -EBUSY; |
328 | 327 | ||
329 | nuc900_audio = kzalloc(sizeof(struct nuc900_audio), GFP_KERNEL); | 328 | nuc900_audio = devm_kzalloc(&pdev->dev, sizeof(struct nuc900_audio), |
329 | GFP_KERNEL); | ||
330 | if (!nuc900_audio) | 330 | if (!nuc900_audio) |
331 | return -ENOMEM; | 331 | return -ENOMEM; |
332 | 332 | ||
333 | spin_lock_init(&nuc900_audio->lock); | 333 | spin_lock_init(&nuc900_audio->lock); |
334 | 334 | ||
335 | nuc900_audio->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 335 | nuc900_audio->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
336 | if (!nuc900_audio->res) { | 336 | if (!nuc900_audio->res) |
337 | ret = -ENODEV; | 337 | return ret; |
338 | goto out0; | ||
339 | } | ||
340 | |||
341 | if (!request_mem_region(nuc900_audio->res->start, | ||
342 | resource_size(nuc900_audio->res), pdev->name)) { | ||
343 | ret = -EBUSY; | ||
344 | goto out0; | ||
345 | } | ||
346 | 338 | ||
347 | nuc900_audio->mmio = ioremap(nuc900_audio->res->start, | 339 | nuc900_audio->mmio = devm_ioremap_resource(&pdev->dev, |
348 | resource_size(nuc900_audio->res)); | 340 | nuc900_audio->res); |
349 | if (!nuc900_audio->mmio) { | 341 | if (IS_ERR(nuc900_audio->mmio)) |
350 | ret = -ENOMEM; | 342 | return PTR_ERR(nuc900_audio->mmio); |
351 | goto out1; | ||
352 | } | ||
353 | 343 | ||
354 | nuc900_audio->clk = clk_get(&pdev->dev, NULL); | 344 | nuc900_audio->clk = devm_clk_get(&pdev->dev, NULL); |
355 | if (IS_ERR(nuc900_audio->clk)) { | 345 | if (IS_ERR(nuc900_audio->clk)) { |
356 | ret = PTR_ERR(nuc900_audio->clk); | 346 | ret = PTR_ERR(nuc900_audio->clk); |
357 | goto out2; | 347 | goto out; |
358 | } | 348 | } |
359 | 349 | ||
360 | nuc900_audio->irq_num = platform_get_irq(pdev, 0); | 350 | nuc900_audio->irq_num = platform_get_irq(pdev, 0); |
361 | if (!nuc900_audio->irq_num) { | 351 | if (!nuc900_audio->irq_num) { |
362 | ret = -EBUSY; | 352 | ret = -EBUSY; |
363 | goto out3; | 353 | goto out; |
364 | } | 354 | } |
365 | 355 | ||
366 | nuc900_ac97_data = nuc900_audio; | 356 | nuc900_ac97_data = nuc900_audio; |
367 | 357 | ||
358 | ret = snd_soc_set_ac97_ops(&nuc900_ac97_ops); | ||
359 | if (ret) | ||
360 | goto out; | ||
361 | |||
368 | ret = snd_soc_register_component(&pdev->dev, &nuc900_ac97_component, | 362 | ret = snd_soc_register_component(&pdev->dev, &nuc900_ac97_component, |
369 | &nuc900_ac97_dai, 1); | 363 | &nuc900_ac97_dai, 1); |
370 | if (ret) | 364 | if (ret) |
371 | goto out3; | 365 | goto out; |
372 | 366 | ||
373 | /* enbale ac97 multifunction pin */ | 367 | /* enbale ac97 multifunction pin */ |
374 | mfp_set_groupg(nuc900_audio->dev, NULL); | 368 | mfp_set_groupg(nuc900_audio->dev, NULL); |
375 | 369 | ||
376 | return 0; | 370 | return 0; |
377 | 371 | ||
378 | out3: | 372 | out: |
379 | clk_put(nuc900_audio->clk); | 373 | snd_soc_set_ac97_ops(NULL); |
380 | out2: | ||
381 | iounmap(nuc900_audio->mmio); | ||
382 | out1: | ||
383 | release_mem_region(nuc900_audio->res->start, | ||
384 | resource_size(nuc900_audio->res)); | ||
385 | out0: | ||
386 | kfree(nuc900_audio); | ||
387 | return ret; | 374 | return ret; |
388 | } | 375 | } |
389 | 376 | ||
@@ -391,13 +378,8 @@ static int nuc900_ac97_drvremove(struct platform_device *pdev) | |||
391 | { | 378 | { |
392 | snd_soc_unregister_component(&pdev->dev); | 379 | snd_soc_unregister_component(&pdev->dev); |
393 | 380 | ||
394 | clk_put(nuc900_ac97_data->clk); | ||
395 | iounmap(nuc900_ac97_data->mmio); | ||
396 | release_mem_region(nuc900_ac97_data->res->start, | ||
397 | resource_size(nuc900_ac97_data->res)); | ||
398 | |||
399 | kfree(nuc900_ac97_data); | ||
400 | nuc900_ac97_data = NULL; | 381 | nuc900_ac97_data = NULL; |
382 | snd_soc_set_ac97_ops(NULL); | ||
401 | 383 | ||
402 | return 0; | 384 | return 0; |
403 | } | 385 | } |