aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2012-09-13 06:03:23 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-13 06:08:21 -0400
commit040242ccfcd4ae878267b521d16539e7b3000527 (patch)
tree6fae1cd8ddfa4fd3c9154fc7666e132710cc9a7c /sound
parentab7af5c8d456103ea57c7e9e6f5b03162965e665 (diff)
ASoC: ad193x: Use managed regmap init
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/codecs/ad193x.c50
1 files changed, 10 insertions, 40 deletions
diff --git a/sound/soc/codecs/ad193x.c b/sound/soc/codecs/ad193x.c
index 13e62be4f990..2f752660f678 100644
--- a/sound/soc/codecs/ad193x.c
+++ b/sound/soc/codecs/ad193x.c
@@ -381,40 +381,25 @@ static const struct regmap_config ad193x_spi_regmap_config = {
381static int __devinit ad193x_spi_probe(struct spi_device *spi) 381static int __devinit ad193x_spi_probe(struct spi_device *spi)
382{ 382{
383 struct ad193x_priv *ad193x; 383 struct ad193x_priv *ad193x;
384 int ret;
385 384
386 ad193x = devm_kzalloc(&spi->dev, sizeof(struct ad193x_priv), 385 ad193x = devm_kzalloc(&spi->dev, sizeof(struct ad193x_priv),
387 GFP_KERNEL); 386 GFP_KERNEL);
388 if (ad193x == NULL) 387 if (ad193x == NULL)
389 return -ENOMEM; 388 return -ENOMEM;
390 389
391 ad193x->regmap = regmap_init_spi(spi, &ad193x_spi_regmap_config); 390 ad193x->regmap = devm_regmap_init_spi(spi, &ad193x_spi_regmap_config);
392 if (IS_ERR(ad193x->regmap)) { 391 if (IS_ERR(ad193x->regmap))
393 ret = PTR_ERR(ad193x->regmap); 392 return PTR_ERR(ad193x->regmap);
394 goto err_out;
395 }
396 393
397 spi_set_drvdata(spi, ad193x); 394 spi_set_drvdata(spi, ad193x);
398 395
399 ret = snd_soc_register_codec(&spi->dev, 396 return snd_soc_register_codec(&spi->dev, &soc_codec_dev_ad193x,
400 &soc_codec_dev_ad193x, &ad193x_dai, 1); 397 &ad193x_dai, 1);
401 if (ret < 0)
402 goto err_regmap_exit;
403
404 return 0;
405
406err_regmap_exit:
407 regmap_exit(ad193x->regmap);
408err_out:
409 return ret;
410} 398}
411 399
412static int __devexit ad193x_spi_remove(struct spi_device *spi) 400static int __devexit ad193x_spi_remove(struct spi_device *spi)
413{ 401{
414 struct ad193x_priv *ad193x = spi_get_drvdata(spi);
415
416 snd_soc_unregister_codec(&spi->dev); 402 snd_soc_unregister_codec(&spi->dev);
417 regmap_exit(ad193x->regmap);
418 return 0; 403 return 0;
419} 404}
420 405
@@ -449,40 +434,25 @@ static int __devinit ad193x_i2c_probe(struct i2c_client *client,
449 const struct i2c_device_id *id) 434 const struct i2c_device_id *id)
450{ 435{
451 struct ad193x_priv *ad193x; 436 struct ad193x_priv *ad193x;
452 int ret;
453 437
454 ad193x = devm_kzalloc(&client->dev, sizeof(struct ad193x_priv), 438 ad193x = devm_kzalloc(&client->dev, sizeof(struct ad193x_priv),
455 GFP_KERNEL); 439 GFP_KERNEL);
456 if (ad193x == NULL) 440 if (ad193x == NULL)
457 return -ENOMEM; 441 return -ENOMEM;
458 442
459 ad193x->regmap = regmap_init_i2c(client, &ad193x_i2c_regmap_config); 443 ad193x->regmap = devm_regmap_init_i2c(client, &ad193x_i2c_regmap_config);
460 if (IS_ERR(ad193x->regmap)) { 444 if (IS_ERR(ad193x->regmap))
461 ret = PTR_ERR(ad193x->regmap); 445 return PTR_ERR(ad193x->regmap);
462 goto err_out;
463 }
464 446
465 i2c_set_clientdata(client, ad193x); 447 i2c_set_clientdata(client, ad193x);
466 448
467 ret = snd_soc_register_codec(&client->dev, 449 return snd_soc_register_codec(&client->dev, &soc_codec_dev_ad193x,
468 &soc_codec_dev_ad193x, &ad193x_dai, 1); 450 &ad193x_dai, 1);
469 if (ret < 0)
470 goto err_regmap_exit;
471
472 return 0;
473
474err_regmap_exit:
475 regmap_exit(ad193x->regmap);
476err_out:
477 return ret;
478} 451}
479 452
480static int __devexit ad193x_i2c_remove(struct i2c_client *client) 453static int __devexit ad193x_i2c_remove(struct i2c_client *client)
481{ 454{
482 struct ad193x_priv *ad193x = i2c_get_clientdata(client);
483
484 snd_soc_unregister_codec(&client->dev); 455 snd_soc_unregister_codec(&client->dev);
485 regmap_exit(ad193x->regmap);
486 return 0; 456 return 0;
487} 457}
488 458