aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimur Tabi <timur@freescale.com>2009-02-02 16:08:29 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2009-02-02 16:34:06 -0500
commita6c255e0945160b76eabe983f59e2129e0c66246 (patch)
tree724a72ac4122c759f30ce2f384be47b65dd7d94d
parentd9fb7fbddc9a14569aad517984c1a5b0b07002ea (diff)
ASoC: fix message display in CS4270 codec driver
Replace printk calls with dev_xxx calls. Set the 'dev' field of the codec and codec_dai structures so that these calls work. Signed-off-by: Timur Tabi <timur@freescale.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r--sound/soc/codecs/cs4270.c66
1 files changed, 39 insertions, 27 deletions
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c
index 7962874258f..2c79a24186f 100644
--- a/sound/soc/codecs/cs4270.c
+++ b/sound/soc/codecs/cs4270.c
@@ -212,7 +212,7 @@ static int cs4270_set_dai_sysclk(struct snd_soc_dai *codec_dai,
212 rates &= ~SNDRV_PCM_RATE_KNOT; 212 rates &= ~SNDRV_PCM_RATE_KNOT;
213 213
214 if (!rates) { 214 if (!rates) {
215 printk(KERN_ERR "cs4270: could not find a valid sample rate\n"); 215 dev_err(codec->dev, "could not find a valid sample rate\n");
216 return -EINVAL; 216 return -EINVAL;
217 } 217 }
218 218
@@ -253,7 +253,7 @@ static int cs4270_set_dai_fmt(struct snd_soc_dai *codec_dai,
253 cs4270->mode = format & SND_SOC_DAIFMT_FORMAT_MASK; 253 cs4270->mode = format & SND_SOC_DAIFMT_FORMAT_MASK;
254 break; 254 break;
255 default: 255 default:
256 printk(KERN_ERR "cs4270: invalid DAI format\n"); 256 dev_err(codec->dev, "invalid dai format\n");
257 ret = -EINVAL; 257 ret = -EINVAL;
258 } 258 }
259 259
@@ -284,7 +284,7 @@ static int cs4270_fill_cache(struct snd_soc_codec *codec)
284 CS4270_FIRSTREG | 0x80, CS4270_NUMREGS, cache); 284 CS4270_FIRSTREG | 0x80, CS4270_NUMREGS, cache);
285 285
286 if (length != CS4270_NUMREGS) { 286 if (length != CS4270_NUMREGS) {
287 printk(KERN_ERR "cs4270: I2C read failure, addr=0x%x\n", 287 dev_err(codec->dev, "i2c read failure, addr=0x%x\n",
288 i2c_client->addr); 288 i2c_client->addr);
289 return -EIO; 289 return -EIO;
290 } 290 }
@@ -340,7 +340,7 @@ static int cs4270_i2c_write(struct snd_soc_codec *codec, unsigned int reg,
340 if (cache[reg - CS4270_FIRSTREG] != value) { 340 if (cache[reg - CS4270_FIRSTREG] != value) {
341 struct i2c_client *client = codec->control_data; 341 struct i2c_client *client = codec->control_data;
342 if (i2c_smbus_write_byte_data(client, reg, value)) { 342 if (i2c_smbus_write_byte_data(client, reg, value)) {
343 printk(KERN_ERR "cs4270: I2C write failed\n"); 343 dev_err(codec->dev, "i2c write failed\n");
344 return -EIO; 344 return -EIO;
345 } 345 }
346 346
@@ -391,7 +391,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
391 391
392 if (i == NUM_MCLK_RATIOS) { 392 if (i == NUM_MCLK_RATIOS) {
393 /* We did not find a matching ratio */ 393 /* We did not find a matching ratio */
394 printk(KERN_ERR "cs4270: could not find matching ratio\n"); 394 dev_err(codec->dev, "could not find matching ratio\n");
395 return -EINVAL; 395 return -EINVAL;
396 } 396 }
397 397
@@ -401,7 +401,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
401 CS4270_PWRCTL_PDN_ADC | CS4270_PWRCTL_PDN_DAC | 401 CS4270_PWRCTL_PDN_ADC | CS4270_PWRCTL_PDN_DAC |
402 CS4270_PWRCTL_PDN); 402 CS4270_PWRCTL_PDN);
403 if (ret < 0) { 403 if (ret < 0) {
404 printk(KERN_ERR "cs4270: I2C write failed\n"); 404 dev_err(codec->dev, "i2c write failed\n");
405 return ret; 405 return ret;
406 } 406 }
407 407
@@ -413,7 +413,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
413 413
414 ret = snd_soc_write(codec, CS4270_MODE, reg); 414 ret = snd_soc_write(codec, CS4270_MODE, reg);
415 if (ret < 0) { 415 if (ret < 0) {
416 printk(KERN_ERR "cs4270: I2C write failed\n"); 416 dev_err(codec->dev, "i2c write failed\n");
417 return ret; 417 return ret;
418 } 418 }
419 419
@@ -430,13 +430,13 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
430 reg |= CS4270_FORMAT_DAC_LJ | CS4270_FORMAT_ADC_LJ; 430 reg |= CS4270_FORMAT_DAC_LJ | CS4270_FORMAT_ADC_LJ;
431 break; 431 break;
432 default: 432 default:
433 printk(KERN_ERR "cs4270: unknown format\n"); 433 dev_err(codec->dev, "unknown dai format\n");
434 return -EINVAL; 434 return -EINVAL;
435 } 435 }
436 436
437 ret = snd_soc_write(codec, CS4270_FORMAT, reg); 437 ret = snd_soc_write(codec, CS4270_FORMAT, reg);
438 if (ret < 0) { 438 if (ret < 0) {
439 printk(KERN_ERR "cs4270: I2C write failed\n"); 439 dev_err(codec->dev, "i2c write failed\n");
440 return ret; 440 return ret;
441 } 441 }
442 442
@@ -447,7 +447,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
447 reg &= ~CS4270_MUTE_AUTO; 447 reg &= ~CS4270_MUTE_AUTO;
448 ret = snd_soc_write(codec, CS4270_MUTE, reg); 448 ret = snd_soc_write(codec, CS4270_MUTE, reg);
449 if (ret < 0) { 449 if (ret < 0) {
450 printk(KERN_ERR "cs4270: I2C write failed\n"); 450 dev_err(codec->dev, "i2c write failed\n");
451 return ret; 451 return ret;
452 } 452 }
453 453
@@ -460,7 +460,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
460 reg &= ~(CS4270_TRANS_SOFT | CS4270_TRANS_ZERO); 460 reg &= ~(CS4270_TRANS_SOFT | CS4270_TRANS_ZERO);
461 ret = cs4270_i2c_write(codec, CS4270_TRANS, reg); 461 ret = cs4270_i2c_write(codec, CS4270_TRANS, reg);
462 if (ret < 0) { 462 if (ret < 0) {
463 printk(KERN_ERR "I2C write failed\n"); 463 dev_err(codec->dev, "i2c write failed\n");
464 return ret; 464 return ret;
465 } 465 }
466 466
@@ -468,7 +468,7 @@ static int cs4270_hw_params(struct snd_pcm_substream *substream,
468 468
469 ret = snd_soc_write(codec, CS4270_PWRCTL, 0); 469 ret = snd_soc_write(codec, CS4270_PWRCTL, 0);
470 if (ret < 0) { 470 if (ret < 0) {
471 printk(KERN_ERR "cs4270: I2C write failed\n"); 471 dev_err(codec->dev, "i2c write failed\n");
472 return ret; 472 return ret;
473 } 473 }
474 474
@@ -570,7 +570,7 @@ static int cs4270_probe(struct platform_device *pdev)
570 /* Register PCMs */ 570 /* Register PCMs */
571 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); 571 ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1);
572 if (ret < 0) { 572 if (ret < 0) {
573 printk(KERN_ERR "cs4270: failed to create PCMs\n"); 573 dev_err(codec->dev, "failed to create pcms\n");
574 return ret; 574 return ret;
575 } 575 }
576 576
@@ -580,7 +580,7 @@ static int cs4270_probe(struct platform_device *pdev)
580 580
581 kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL); 581 kctrl = snd_soc_cnew(&cs4270_snd_controls[i], codec, NULL);
582 if (!kctrl) { 582 if (!kctrl) {
583 printk(KERN_ERR "cs4270: error creating control '%s'\n", 583 dev_err(codec->dev, "error creating control '%s'\n",
584 cs4270_snd_controls[i].name); 584 cs4270_snd_controls[i].name);
585 ret = -ENOMEM; 585 ret = -ENOMEM;
586 goto error_free_pcms; 586 goto error_free_pcms;
@@ -588,7 +588,7 @@ static int cs4270_probe(struct platform_device *pdev)
588 588
589 ret = snd_ctl_add(codec->card, kctrl); 589 ret = snd_ctl_add(codec->card, kctrl);
590 if (ret < 0) { 590 if (ret < 0) {
591 printk(KERN_ERR "cs4270: error adding control '%s'\n", 591 dev_err(codec->dev, "error adding control '%s'\n",
592 cs4270_snd_controls[i].name); 592 cs4270_snd_controls[i].name);
593 goto error_free_pcms; 593 goto error_free_pcms;
594 } 594 }
@@ -597,7 +597,7 @@ static int cs4270_probe(struct platform_device *pdev)
597 /* And finally, register the socdev */ 597 /* And finally, register the socdev */
598 ret = snd_soc_init_card(socdev); 598 ret = snd_soc_init_card(socdev);
599 if (ret < 0) { 599 if (ret < 0) {
600 printk(KERN_ERR "cs4270: failed to register card\n"); 600 dev_err(codec->dev, "failed to register card\n");
601 goto error_free_pcms; 601 goto error_free_pcms;
602 } 602 }
603 603
@@ -643,9 +643,9 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,
643 * comment for cs4270_codec. 643 * comment for cs4270_codec.
644 */ 644 */
645 if (cs4270_codec) { 645 if (cs4270_codec) {
646 printk(KERN_ERR "cs4270: ignoring CS4270 at addr %X\n", 646 dev_err(&i2c_client->dev, "ignoring CS4270 at addr %X\n",
647 i2c_client->addr); 647 i2c_client->addr);
648 printk(KERN_ERR "cs4270: only one CS4270 per board allowed\n"); 648 dev_err(&i2c_client->dev, "only one per board allowed\n");
649 /* Should we return something other than ENODEV here? */ 649 /* Should we return something other than ENODEV here? */
650 return -ENODEV; 650 return -ENODEV;
651 } 651 }
@@ -654,35 +654,35 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,
654 654
655 ret = i2c_smbus_read_byte_data(i2c_client, CS4270_CHIPID); 655 ret = i2c_smbus_read_byte_data(i2c_client, CS4270_CHIPID);
656 if (ret < 0) { 656 if (ret < 0) {
657 printk(KERN_ERR "cs4270: failed to read I2C at addr %X\n", 657 dev_err(&i2c_client->dev, "failed to read i2c at addr %X\n",
658 i2c_client->addr); 658 i2c_client->addr);
659 return ret; 659 return ret;
660 } 660 }
661 /* The top four bits of the chip ID should be 1100. */ 661 /* The top four bits of the chip ID should be 1100. */
662 if ((ret & 0xF0) != 0xC0) { 662 if ((ret & 0xF0) != 0xC0) {
663 printk(KERN_ERR "cs4270: device at addr %X is not a CS4270\n", 663 dev_err(&i2c_client->dev, "device at addr %X is not a CS4270\n",
664 i2c_client->addr); 664 i2c_client->addr);
665 return -ENODEV; 665 return -ENODEV;
666 } 666 }
667 667
668 printk(KERN_INFO "cs4270: found device at I2C address %X\n", 668 dev_info(&i2c_client->dev, "found device at i2c address %X\n",
669 i2c_client->addr); 669 i2c_client->addr);
670 printk(KERN_INFO "cs4270: hardware revision %X\n", ret & 0xF); 670 dev_info(&i2c_client->dev, "hardware revision %X\n", ret & 0xF);
671 671
672 /* Allocate enough space for the snd_soc_codec structure 672 /* Allocate enough space for the snd_soc_codec structure
673 and our private data together. */ 673 and our private data together. */
674 cs4270 = kzalloc(sizeof(struct cs4270_private), GFP_KERNEL); 674 cs4270 = kzalloc(sizeof(struct cs4270_private), GFP_KERNEL);
675 if (!cs4270) { 675 if (!cs4270) {
676 printk(KERN_ERR "cs4270: Could not allocate codec structure\n"); 676 dev_err(&i2c_client->dev, "could not allocate codec\n");
677 return -ENOMEM; 677 return -ENOMEM;
678 } 678 }
679 codec = &cs4270->codec; 679 codec = &cs4270->codec;
680 cs4270_codec = codec;
681 680
682 mutex_init(&codec->mutex); 681 mutex_init(&codec->mutex);
683 INIT_LIST_HEAD(&codec->dapm_widgets); 682 INIT_LIST_HEAD(&codec->dapm_widgets);
684 INIT_LIST_HEAD(&codec->dapm_paths); 683 INIT_LIST_HEAD(&codec->dapm_paths);
685 684
685 codec->dev = &i2c_client->dev;
686 codec->name = "CS4270"; 686 codec->name = "CS4270";
687 codec->owner = THIS_MODULE; 687 codec->owner = THIS_MODULE;
688 codec->dai = &cs4270_dai; 688 codec->dai = &cs4270_dai;
@@ -698,17 +698,25 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,
698 698
699 ret = cs4270_fill_cache(codec); 699 ret = cs4270_fill_cache(codec);
700 if (ret < 0) { 700 if (ret < 0) {
701 printk(KERN_ERR "cs4270: failed to fill register cache\n"); 701 dev_err(&i2c_client->dev, "failed to fill register cache\n");
702 goto error_free_codec; 702 goto error_free_codec;
703 } 703 }
704 704
705 /* Initialize the DAI. Normally, we'd prefer to have a kmalloc'd DAI
706 * structure for each CS4270 device, but the machine driver needs to
707 * have a pointer to the DAI structure, so for now it must be a global
708 * variable.
709 */
710 cs4270_dai.dev = &i2c_client->dev;
711
705 /* Register the DAI. If all the other ASoC driver have already 712 /* Register the DAI. If all the other ASoC driver have already
706 * registered, then this will call our probe function, so 713 * registered, then this will call our probe function, so
707 * cs4270_codec needs to be ready. 714 * cs4270_codec needs to be ready.
708 */ 715 */
716 cs4270_codec = codec;
709 ret = snd_soc_register_dai(&cs4270_dai); 717 ret = snd_soc_register_dai(&cs4270_dai);
710 if (ret < 0) { 718 if (ret < 0) {
711 printk(KERN_ERR "cs4270: failed to register DAIe\n"); 719 dev_err(&i2c_client->dev, "failed to register DAIe\n");
712 goto error_free_codec; 720 goto error_free_codec;
713 } 721 }
714 722
@@ -718,6 +726,8 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client,
718 726
719error_free_codec: 727error_free_codec:
720 kfree(cs4270); 728 kfree(cs4270);
729 cs4270_codec = NULL;
730 cs4270_dai.dev = NULL;
721 731
722 return ret; 732 return ret;
723} 733}
@@ -733,6 +743,8 @@ static int cs4270_i2c_remove(struct i2c_client *i2c_client)
733 struct cs4270_private *cs4270 = i2c_get_clientdata(i2c_client); 743 struct cs4270_private *cs4270 = i2c_get_clientdata(i2c_client);
734 744
735 kfree(cs4270); 745 kfree(cs4270);
746 cs4270_codec = NULL;
747 cs4270_dai.dev = NULL;
736 748
737 return 0; 749 return 0;
738} 750}
@@ -776,7 +788,7 @@ EXPORT_SYMBOL_GPL(soc_codec_device_cs4270);
776 788
777static int __init cs4270_init(void) 789static int __init cs4270_init(void)
778{ 790{
779 printk(KERN_INFO "Cirrus Logic CS4270 ALSA SoC Codec Driver\n"); 791 pr_info("Cirrus Logic CS4270 ALSA SoC Codec Driver\n");
780 792
781 return i2c_add_driver(&cs4270_i2c_driver); 793 return i2c_add_driver(&cs4270_i2c_driver);
782} 794}