diff options
-rw-r--r-- | sound/soc/codecs/cs4270.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index d68650de39bc..0bbd94501d7e 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c | |||
@@ -681,7 +681,7 @@ static int cs4270_probe(struct platform_device *pdev) | |||
681 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); | 681 | ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); |
682 | if (ret < 0) { | 682 | if (ret < 0) { |
683 | printk(KERN_ERR "cs4270: failed to create PCMs\n"); | 683 | printk(KERN_ERR "cs4270: failed to create PCMs\n"); |
684 | return ret; | 684 | goto error_free_codec; |
685 | } | 685 | } |
686 | 686 | ||
687 | #ifdef USE_I2C | 687 | #ifdef USE_I2C |
@@ -690,8 +690,7 @@ static int cs4270_probe(struct platform_device *pdev) | |||
690 | ret = i2c_add_driver(&cs4270_i2c_driver); | 690 | ret = i2c_add_driver(&cs4270_i2c_driver); |
691 | if (ret) { | 691 | if (ret) { |
692 | printk(KERN_ERR "cs4270: failed to attach driver"); | 692 | printk(KERN_ERR "cs4270: failed to attach driver"); |
693 | snd_soc_free_pcms(socdev); | 693 | goto error_free_pcms; |
694 | return ret; | ||
695 | } | 694 | } |
696 | 695 | ||
697 | /* Did we find a CS4270 on the I2C bus? */ | 696 | /* Did we find a CS4270 on the I2C bus? */ |
@@ -713,10 +712,23 @@ static int cs4270_probe(struct platform_device *pdev) | |||
713 | ret = snd_soc_register_card(socdev); | 712 | ret = snd_soc_register_card(socdev); |
714 | if (ret < 0) { | 713 | if (ret < 0) { |
715 | printk(KERN_ERR "cs4270: failed to register card\n"); | 714 | printk(KERN_ERR "cs4270: failed to register card\n"); |
716 | snd_soc_free_pcms(socdev); | 715 | goto error_del_driver; |
717 | return ret; | ||
718 | } | 716 | } |
719 | 717 | ||
718 | return 0; | ||
719 | |||
720 | error_del_driver: | ||
721 | #ifdef USE_I2C | ||
722 | i2c_del_driver(&cs4270_i2c_driver); | ||
723 | |||
724 | error_free_pcms: | ||
725 | #endif | ||
726 | snd_soc_free_pcms(socdev); | ||
727 | |||
728 | error_free_codec: | ||
729 | kfree(socdev->codec); | ||
730 | socdev->codec = NULL; | ||
731 | |||
720 | return ret; | 732 | return ret; |
721 | } | 733 | } |
722 | 734 | ||
@@ -727,8 +739,7 @@ static int cs4270_remove(struct platform_device *pdev) | |||
727 | snd_soc_free_pcms(socdev); | 739 | snd_soc_free_pcms(socdev); |
728 | 740 | ||
729 | #ifdef USE_I2C | 741 | #ifdef USE_I2C |
730 | if (socdev->codec->control_data) | 742 | i2c_del_driver(&cs4270_i2c_driver); |
731 | i2c_del_driver(&cs4270_i2c_driver); | ||
732 | #endif | 743 | #endif |
733 | 744 | ||
734 | kfree(socdev->codec); | 745 | kfree(socdev->codec); |