diff options
Diffstat (limited to 'sound/soc/codecs/cs42l51.c')
-rw-r--r-- | sound/soc/codecs/cs42l51.c | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/sound/soc/codecs/cs42l51.c b/sound/soc/codecs/cs42l51.c index 1ee66361f61b..a8bf588e8740 100644 --- a/sound/soc/codecs/cs42l51.c +++ b/sound/soc/codecs/cs42l51.c | |||
@@ -22,7 +22,6 @@ | |||
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/platform_device.h> | ||
26 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
27 | #include <sound/core.h> | 26 | #include <sound/core.h> |
28 | #include <sound/soc.h> | 27 | #include <sound/soc.h> |
@@ -175,21 +174,18 @@ static const struct snd_kcontrol_new cs42l51_snd_controls[] = { | |||
175 | static int cs42l51_pdn_event(struct snd_soc_dapm_widget *w, | 174 | static int cs42l51_pdn_event(struct snd_soc_dapm_widget *w, |
176 | struct snd_kcontrol *kcontrol, int event) | 175 | struct snd_kcontrol *kcontrol, int event) |
177 | { | 176 | { |
178 | unsigned long value; | ||
179 | |||
180 | value = snd_soc_read(w->codec, CS42L51_POWER_CTL1); | ||
181 | value &= ~CS42L51_POWER_CTL1_PDN; | ||
182 | |||
183 | switch (event) { | 177 | switch (event) { |
184 | case SND_SOC_DAPM_PRE_PMD: | 178 | case SND_SOC_DAPM_PRE_PMD: |
185 | value |= CS42L51_POWER_CTL1_PDN; | 179 | snd_soc_update_bits(w->codec, CS42L51_POWER_CTL1, |
180 | CS42L51_POWER_CTL1_PDN, | ||
181 | CS42L51_POWER_CTL1_PDN); | ||
186 | break; | 182 | break; |
187 | default: | 183 | default: |
188 | case SND_SOC_DAPM_POST_PMD: | 184 | case SND_SOC_DAPM_POST_PMD: |
185 | snd_soc_update_bits(w->codec, CS42L51_POWER_CTL1, | ||
186 | CS42L51_POWER_CTL1_PDN, 0); | ||
189 | break; | 187 | break; |
190 | } | 188 | } |
191 | snd_soc_update_bits(w->codec, CS42L51_POWER_CTL1, | ||
192 | CS42L51_POWER_CTL1_PDN, value); | ||
193 | 189 | ||
194 | return 0; | 190 | return 0; |
195 | } | 191 | } |
@@ -486,7 +482,7 @@ static int cs42l51_dai_mute(struct snd_soc_dai *dai, int mute) | |||
486 | return snd_soc_write(codec, CS42L51_DAC_OUT_CTL, reg); | 482 | return snd_soc_write(codec, CS42L51_DAC_OUT_CTL, reg); |
487 | } | 483 | } |
488 | 484 | ||
489 | static struct snd_soc_dai_ops cs42l51_dai_ops = { | 485 | static const struct snd_soc_dai_ops cs42l51_dai_ops = { |
490 | .hw_params = cs42l51_hw_params, | 486 | .hw_params = cs42l51_hw_params, |
491 | .set_sysclk = cs42l51_set_dai_sysclk, | 487 | .set_sysclk = cs42l51_set_dai_sysclk, |
492 | .set_fmt = cs42l51_set_dai_fmt, | 488 | .set_fmt = cs42l51_set_dai_fmt, |
@@ -515,7 +511,6 @@ static struct snd_soc_dai_driver cs42l51_dai = { | |||
515 | static int cs42l51_probe(struct snd_soc_codec *codec) | 511 | static int cs42l51_probe(struct snd_soc_codec *codec) |
516 | { | 512 | { |
517 | struct cs42l51_private *cs42l51 = snd_soc_codec_get_drvdata(codec); | 513 | struct cs42l51_private *cs42l51 = snd_soc_codec_get_drvdata(codec); |
518 | struct snd_soc_dapm_context *dapm = &codec->dapm; | ||
519 | int ret, reg; | 514 | int ret, reg; |
520 | 515 | ||
521 | ret = cs42l51_fill_cache(codec); | 516 | ret = cs42l51_fill_cache(codec); |
@@ -543,20 +538,20 @@ static int cs42l51_probe(struct snd_soc_codec *codec) | |||
543 | if (ret < 0) | 538 | if (ret < 0) |
544 | return ret; | 539 | return ret; |
545 | 540 | ||
546 | snd_soc_add_controls(codec, cs42l51_snd_controls, | ||
547 | ARRAY_SIZE(cs42l51_snd_controls)); | ||
548 | snd_soc_dapm_new_controls(dapm, cs42l51_dapm_widgets, | ||
549 | ARRAY_SIZE(cs42l51_dapm_widgets)); | ||
550 | snd_soc_dapm_add_routes(dapm, cs42l51_routes, | ||
551 | ARRAY_SIZE(cs42l51_routes)); | ||
552 | |||
553 | return 0; | 541 | return 0; |
554 | } | 542 | } |
555 | 543 | ||
556 | static struct snd_soc_codec_driver soc_codec_device_cs42l51 = { | 544 | static struct snd_soc_codec_driver soc_codec_device_cs42l51 = { |
557 | .probe = cs42l51_probe, | 545 | .probe = cs42l51_probe, |
558 | .reg_cache_size = CS42L51_NUMREGS + 1, | 546 | .reg_cache_size = CS42L51_NUMREGS + 1, |
559 | .reg_word_size = sizeof(u8), | 547 | .reg_word_size = sizeof(u8), |
548 | |||
549 | .controls = cs42l51_snd_controls, | ||
550 | .num_controls = ARRAY_SIZE(cs42l51_snd_controls), | ||
551 | .dapm_widgets = cs42l51_dapm_widgets, | ||
552 | .num_dapm_widgets = ARRAY_SIZE(cs42l51_dapm_widgets), | ||
553 | .dapm_routes = cs42l51_routes, | ||
554 | .num_dapm_routes = ARRAY_SIZE(cs42l51_routes), | ||
560 | }; | 555 | }; |
561 | 556 | ||
562 | static int cs42l51_i2c_probe(struct i2c_client *i2c_client, | 557 | static int cs42l51_i2c_probe(struct i2c_client *i2c_client, |
@@ -582,7 +577,8 @@ static int cs42l51_i2c_probe(struct i2c_client *i2c_client, | |||
582 | dev_info(&i2c_client->dev, "found device cs42l51 rev %d\n", | 577 | dev_info(&i2c_client->dev, "found device cs42l51 rev %d\n", |
583 | ret & 7); | 578 | ret & 7); |
584 | 579 | ||
585 | cs42l51 = kzalloc(sizeof(struct cs42l51_private), GFP_KERNEL); | 580 | cs42l51 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l51_private), |
581 | GFP_KERNEL); | ||
586 | if (!cs42l51) { | 582 | if (!cs42l51) { |
587 | dev_err(&i2c_client->dev, "could not allocate codec\n"); | 583 | dev_err(&i2c_client->dev, "could not allocate codec\n"); |
588 | return -ENOMEM; | 584 | return -ENOMEM; |
@@ -593,18 +589,13 @@ static int cs42l51_i2c_probe(struct i2c_client *i2c_client, | |||
593 | 589 | ||
594 | ret = snd_soc_register_codec(&i2c_client->dev, | 590 | ret = snd_soc_register_codec(&i2c_client->dev, |
595 | &soc_codec_device_cs42l51, &cs42l51_dai, 1); | 591 | &soc_codec_device_cs42l51, &cs42l51_dai, 1); |
596 | if (ret < 0) | ||
597 | kfree(cs42l51); | ||
598 | error: | 592 | error: |
599 | return ret; | 593 | return ret; |
600 | } | 594 | } |
601 | 595 | ||
602 | static int cs42l51_i2c_remove(struct i2c_client *client) | 596 | static int cs42l51_i2c_remove(struct i2c_client *client) |
603 | { | 597 | { |
604 | struct cs42l51_private *cs42l51 = i2c_get_clientdata(client); | ||
605 | |||
606 | snd_soc_unregister_codec(&client->dev); | 598 | snd_soc_unregister_codec(&client->dev); |
607 | kfree(cs42l51); | ||
608 | return 0; | 599 | return 0; |
609 | } | 600 | } |
610 | 601 | ||