aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2015-07-16 15:22:52 -0400
committerMark Brown <broonie@kernel.org>2015-07-16 16:36:23 -0400
commit04b5cbd80af899c6a4d51835b069b96ae8864e5a (patch)
tree11a99157e14aad009948cfa2ac98f6215cf2c79c
parentd79cca1a994f6f4f1cf3d92909f2a73df6b84874 (diff)
ASoC: max9768: Convert to component
The driver does not use any CODEC specific constructs anymore. Convert it to snd_soc_component. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--sound/soc/codecs/max9768.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/sound/soc/codecs/max9768.c b/sound/soc/codecs/max9768.c
index d70a8205c6ad..4c300f317c3a 100644
--- a/sound/soc/codecs/max9768.c
+++ b/sound/soc/codecs/max9768.c
@@ -43,8 +43,8 @@ static struct reg_default max9768_default_regs[] = {
43static int max9768_get_gpio(struct snd_kcontrol *kcontrol, 43static int max9768_get_gpio(struct snd_kcontrol *kcontrol,
44 struct snd_ctl_elem_value *ucontrol) 44 struct snd_ctl_elem_value *ucontrol)
45{ 45{
46 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 46 struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
47 struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); 47 struct max9768 *max9768 = snd_soc_component_get_drvdata(c);
48 int val = gpio_get_value_cansleep(max9768->mute_gpio); 48 int val = gpio_get_value_cansleep(max9768->mute_gpio);
49 49
50 ucontrol->value.integer.value[0] = !val; 50 ucontrol->value.integer.value[0] = !val;
@@ -55,8 +55,8 @@ static int max9768_get_gpio(struct snd_kcontrol *kcontrol,
55static int max9768_set_gpio(struct snd_kcontrol *kcontrol, 55static int max9768_set_gpio(struct snd_kcontrol *kcontrol,
56 struct snd_ctl_elem_value *ucontrol) 56 struct snd_ctl_elem_value *ucontrol)
57{ 57{
58 struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); 58 struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
59 struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); 59 struct max9768 *max9768 = snd_soc_component_get_drvdata(c);
60 60
61 gpio_set_value_cansleep(max9768->mute_gpio, !ucontrol->value.integer.value[0]); 61 gpio_set_value_cansleep(max9768->mute_gpio, !ucontrol->value.integer.value[0]);
62 62
@@ -130,19 +130,20 @@ static const struct snd_soc_dapm_route max9768_dapm_routes[] = {
130 { "OUT-", NULL, "IN" }, 130 { "OUT-", NULL, "IN" },
131}; 131};
132 132
133static int max9768_probe(struct snd_soc_codec *codec) 133static int max9768_probe(struct snd_soc_component *component)
134{ 134{
135 struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); 135 struct max9768 *max9768 = snd_soc_component_get_drvdata(component);
136 int ret; 136 int ret;
137 137
138 if (max9768->flags & MAX9768_FLAG_CLASSIC_PWM) { 138 if (max9768->flags & MAX9768_FLAG_CLASSIC_PWM) {
139 ret = snd_soc_write(codec, MAX9768_CTRL, MAX9768_CTRL_PWM); 139 ret = regmap_write(max9768->regmap, MAX9768_CTRL,
140 MAX9768_CTRL_PWM);
140 if (ret) 141 if (ret)
141 return ret; 142 return ret;
142 } 143 }
143 144
144 if (gpio_is_valid(max9768->mute_gpio)) { 145 if (gpio_is_valid(max9768->mute_gpio)) {
145 ret = snd_soc_add_codec_controls(codec, max9768_mute, 146 ret = snd_soc_add_component_controls(component, max9768_mute,
146 ARRAY_SIZE(max9768_mute)); 147 ARRAY_SIZE(max9768_mute));
147 if (ret) 148 if (ret)
148 return ret; 149 return ret;
@@ -151,7 +152,7 @@ static int max9768_probe(struct snd_soc_codec *codec)
151 return 0; 152 return 0;
152} 153}
153 154
154static struct snd_soc_codec_driver max9768_codec_driver = { 155static struct snd_soc_component_driver max9768_component_driver = {
155 .probe = max9768_probe, 156 .probe = max9768_probe,
156 .controls = max9768_volume, 157 .controls = max9768_volume,
157 .num_controls = ARRAY_SIZE(max9768_volume), 158 .num_controls = ARRAY_SIZE(max9768_volume),
@@ -204,15 +205,8 @@ static int max9768_i2c_probe(struct i2c_client *client,
204 if (IS_ERR(max9768->regmap)) 205 if (IS_ERR(max9768->regmap))
205 return PTR_ERR(max9768->regmap); 206 return PTR_ERR(max9768->regmap);
206 207
207 return snd_soc_register_codec(&client->dev, &max9768_codec_driver, 208 return devm_snd_soc_register_component(&client->dev,
208 NULL, 0); 209 &max9768_component_driver, NULL, 0);
209}
210
211static int max9768_i2c_remove(struct i2c_client *client)
212{
213 snd_soc_unregister_codec(&client->dev);
214
215 return 0;
216} 210}
217 211
218static const struct i2c_device_id max9768_i2c_id[] = { 212static const struct i2c_device_id max9768_i2c_id[] = {
@@ -226,7 +220,6 @@ static struct i2c_driver max9768_i2c_driver = {
226 .name = "max9768", 220 .name = "max9768",
227 }, 221 },
228 .probe = max9768_i2c_probe, 222 .probe = max9768_i2c_probe,
229 .remove = max9768_i2c_remove,
230 .id_table = max9768_i2c_id, 223 .id_table = max9768_i2c_id,
231}; 224};
232module_i2c_driver(max9768_i2c_driver); 225module_i2c_driver(max9768_i2c_driver);