Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: ad193x: Use managed regmap init

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

authored by

Lars-Peter Clausen and committed by
Mark Brown
040242cc ab7af5c8

+10 -40
+10 -40
sound/soc/codecs/ad193x.c
··· 381 381 static int __devinit ad193x_spi_probe(struct spi_device *spi) 382 382 { 383 383 struct ad193x_priv *ad193x; 384 - int ret; 385 384 386 385 ad193x = devm_kzalloc(&spi->dev, sizeof(struct ad193x_priv), 387 386 GFP_KERNEL); 388 387 if (ad193x == NULL) 389 388 return -ENOMEM; 390 389 391 - ad193x->regmap = regmap_init_spi(spi, &ad193x_spi_regmap_config); 392 - if (IS_ERR(ad193x->regmap)) { 393 - ret = PTR_ERR(ad193x->regmap); 394 - goto err_out; 395 - } 390 + ad193x->regmap = devm_regmap_init_spi(spi, &ad193x_spi_regmap_config); 391 + if (IS_ERR(ad193x->regmap)) 392 + return PTR_ERR(ad193x->regmap); 396 393 397 394 spi_set_drvdata(spi, ad193x); 398 395 399 - ret = snd_soc_register_codec(&spi->dev, 400 - &soc_codec_dev_ad193x, &ad193x_dai, 1); 401 - if (ret < 0) 402 - goto err_regmap_exit; 403 - 404 - return 0; 405 - 406 - err_regmap_exit: 407 - regmap_exit(ad193x->regmap); 408 - err_out: 409 - return ret; 396 + return snd_soc_register_codec(&spi->dev, &soc_codec_dev_ad193x, 397 + &ad193x_dai, 1); 410 398 } 411 399 412 400 static int __devexit ad193x_spi_remove(struct spi_device *spi) 413 401 { 414 - struct ad193x_priv *ad193x = spi_get_drvdata(spi); 415 - 416 402 snd_soc_unregister_codec(&spi->dev); 417 - regmap_exit(ad193x->regmap); 418 403 return 0; 419 404 } 420 405 ··· 434 449 const struct i2c_device_id *id) 435 450 { 436 451 struct ad193x_priv *ad193x; 437 - int ret; 438 452 439 453 ad193x = devm_kzalloc(&client->dev, sizeof(struct ad193x_priv), 440 454 GFP_KERNEL); 441 455 if (ad193x == NULL) 442 456 return -ENOMEM; 443 457 444 - ad193x->regmap = regmap_init_i2c(client, &ad193x_i2c_regmap_config); 445 - if (IS_ERR(ad193x->regmap)) { 446 - ret = PTR_ERR(ad193x->regmap); 447 - goto err_out; 448 - } 458 + ad193x->regmap = devm_regmap_init_i2c(client, &ad193x_i2c_regmap_config); 459 + if (IS_ERR(ad193x->regmap)) 460 + return PTR_ERR(ad193x->regmap); 449 461 450 462 i2c_set_clientdata(client, ad193x); 451 463 452 - ret = snd_soc_register_codec(&client->dev, 453 - &soc_codec_dev_ad193x, &ad193x_dai, 1); 454 - if (ret < 0) 455 - goto err_regmap_exit; 456 - 457 - return 0; 458 - 459 - err_regmap_exit: 460 - regmap_exit(ad193x->regmap); 461 - err_out: 462 - return ret; 464 + return snd_soc_register_codec(&client->dev, &soc_codec_dev_ad193x, 465 + &ad193x_dai, 1); 463 466 } 464 467 465 468 static int __devexit ad193x_i2c_remove(struct i2c_client *client) 466 469 { 467 - struct ad193x_priv *ad193x = i2c_get_clientdata(client); 468 - 469 470 snd_soc_unregister_codec(&client->dev); 470 - regmap_exit(ad193x->regmap); 471 471 return 0; 472 472 } 473 473