aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sound/soc/codecs/uda1380.c55
1 files changed, 20 insertions, 35 deletions
diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c
index 8e52439a58fd..2918fdb95e58 100644
--- a/sound/soc/codecs/uda1380.c
+++ b/sound/soc/codecs/uda1380.c
@@ -698,25 +698,10 @@ static int uda1380_probe(struct snd_soc_codec *codec)
698 codec->hw_write = (hw_write_t)i2c_master_send; 698 codec->hw_write = (hw_write_t)i2c_master_send;
699 codec->control_data = uda1380->control_data; 699 codec->control_data = uda1380->control_data;
700 700
701 if (!pdata) 701 if (!gpio_is_valid(pdata->gpio_power)) {
702 return -EINVAL;
703
704 if (gpio_is_valid(pdata->gpio_reset)) {
705 ret = gpio_request_one(pdata->gpio_reset, GPIOF_OUT_INIT_LOW,
706 "uda1380 reset");
707 if (ret)
708 goto err_out;
709 }
710
711 if (gpio_is_valid(pdata->gpio_power)) {
712 ret = gpio_request_one(pdata->gpio_power, GPIOF_OUT_INIT_LOW,
713 "uda1380 power");
714 if (ret)
715 goto err_free_gpio;
716 } else {
717 ret = uda1380_reset(codec); 702 ret = uda1380_reset(codec);
718 if (ret) 703 if (ret)
719 goto err_free_gpio; 704 return ret;
720 } 705 }
721 706
722 INIT_WORK(&uda1380->work, uda1380_flush_work); 707 INIT_WORK(&uda1380->work, uda1380_flush_work);
@@ -733,28 +718,10 @@ static int uda1380_probe(struct snd_soc_codec *codec)
733 } 718 }
734 719
735 return 0; 720 return 0;
736
737err_free_gpio:
738 if (gpio_is_valid(pdata->gpio_reset))
739 gpio_free(pdata->gpio_reset);
740err_out:
741 return ret;
742}
743
744/* power down chip */
745static int uda1380_remove(struct snd_soc_codec *codec)
746{
747 struct uda1380_platform_data *pdata =codec->dev->platform_data;
748
749 gpio_free(pdata->gpio_reset);
750 gpio_free(pdata->gpio_power);
751
752 return 0;
753} 721}
754 722
755static struct snd_soc_codec_driver soc_codec_dev_uda1380 = { 723static struct snd_soc_codec_driver soc_codec_dev_uda1380 = {
756 .probe = uda1380_probe, 724 .probe = uda1380_probe,
757 .remove = uda1380_remove,
758 .read = uda1380_read_reg_cache, 725 .read = uda1380_read_reg_cache,
759 .write = uda1380_write, 726 .write = uda1380_write,
760 .set_bias_level = uda1380_set_bias_level, 727 .set_bias_level = uda1380_set_bias_level,
@@ -778,14 +745,32 @@ static struct snd_soc_codec_driver soc_codec_dev_uda1380 = {
778static int uda1380_i2c_probe(struct i2c_client *i2c, 745static int uda1380_i2c_probe(struct i2c_client *i2c,
779 const struct i2c_device_id *id) 746 const struct i2c_device_id *id)
780{ 747{
748 struct uda1380_platform_data *pdata = i2c->dev.platform_data;
781 struct uda1380_priv *uda1380; 749 struct uda1380_priv *uda1380;
782 int ret; 750 int ret;
783 751
752 if (!pdata)
753 return -EINVAL;
754
784 uda1380 = devm_kzalloc(&i2c->dev, sizeof(struct uda1380_priv), 755 uda1380 = devm_kzalloc(&i2c->dev, sizeof(struct uda1380_priv),
785 GFP_KERNEL); 756 GFP_KERNEL);
786 if (uda1380 == NULL) 757 if (uda1380 == NULL)
787 return -ENOMEM; 758 return -ENOMEM;
788 759
760 if (gpio_is_valid(pdata->gpio_reset)) {
761 ret = devm_gpio_request_one(&i2c->dev, pdata->gpio_reset,
762 GPIOF_OUT_INIT_LOW, "uda1380 reset");
763 if (ret)
764 return ret;
765 }
766
767 if (gpio_is_valid(pdata->gpio_power)) {
768 ret = devm_gpio_request_one(&i2c->dev, pdata->gpio_power,
769 GPIOF_OUT_INIT_LOW, "uda1380 power");
770 if (ret)
771 return ret;
772 }
773
789 i2c_set_clientdata(i2c, uda1380); 774 i2c_set_clientdata(i2c, uda1380);
790 uda1380->control_data = i2c; 775 uda1380->control_data = i2c;
791 776