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>
This commit is contained in:
Lars-Peter Clausen 2015-07-16 21:22:52 +02:00 committed by Mark Brown
parent d79cca1a99
commit 04b5cbd80a

View file

@ -43,8 +43,8 @@ static struct reg_default max9768_default_regs[] = {
static int max9768_get_gpio(struct snd_kcontrol *kcontrol, static int max9768_get_gpio(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); struct max9768 *max9768 = snd_soc_component_get_drvdata(c);
int val = gpio_get_value_cansleep(max9768->mute_gpio); int val = gpio_get_value_cansleep(max9768->mute_gpio);
ucontrol->value.integer.value[0] = !val; ucontrol->value.integer.value[0] = !val;
@ -55,8 +55,8 @@ static int max9768_get_gpio(struct snd_kcontrol *kcontrol,
static int max9768_set_gpio(struct snd_kcontrol *kcontrol, static int max9768_set_gpio(struct snd_kcontrol *kcontrol,
struct snd_ctl_elem_value *ucontrol) struct snd_ctl_elem_value *ucontrol)
{ {
struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); struct snd_soc_component *c = snd_soc_kcontrol_component(kcontrol);
struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); struct max9768 *max9768 = snd_soc_component_get_drvdata(c);
gpio_set_value_cansleep(max9768->mute_gpio, !ucontrol->value.integer.value[0]); gpio_set_value_cansleep(max9768->mute_gpio, !ucontrol->value.integer.value[0]);
@ -130,19 +130,20 @@ static const struct snd_soc_dapm_route max9768_dapm_routes[] = {
{ "OUT-", NULL, "IN" }, { "OUT-", NULL, "IN" },
}; };
static int max9768_probe(struct snd_soc_codec *codec) static int max9768_probe(struct snd_soc_component *component)
{ {
struct max9768 *max9768 = snd_soc_codec_get_drvdata(codec); struct max9768 *max9768 = snd_soc_component_get_drvdata(component);
int ret; int ret;
if (max9768->flags & MAX9768_FLAG_CLASSIC_PWM) { if (max9768->flags & MAX9768_FLAG_CLASSIC_PWM) {
ret = snd_soc_write(codec, MAX9768_CTRL, MAX9768_CTRL_PWM); ret = regmap_write(max9768->regmap, MAX9768_CTRL,
MAX9768_CTRL_PWM);
if (ret) if (ret)
return ret; return ret;
} }
if (gpio_is_valid(max9768->mute_gpio)) { if (gpio_is_valid(max9768->mute_gpio)) {
ret = snd_soc_add_codec_controls(codec, max9768_mute, ret = snd_soc_add_component_controls(component, max9768_mute,
ARRAY_SIZE(max9768_mute)); ARRAY_SIZE(max9768_mute));
if (ret) if (ret)
return ret; return ret;
@ -151,7 +152,7 @@ static int max9768_probe(struct snd_soc_codec *codec)
return 0; return 0;
} }
static struct snd_soc_codec_driver max9768_codec_driver = { static struct snd_soc_component_driver max9768_component_driver = {
.probe = max9768_probe, .probe = max9768_probe,
.controls = max9768_volume, .controls = max9768_volume,
.num_controls = ARRAY_SIZE(max9768_volume), .num_controls = ARRAY_SIZE(max9768_volume),
@ -204,15 +205,8 @@ static int max9768_i2c_probe(struct i2c_client *client,
if (IS_ERR(max9768->regmap)) if (IS_ERR(max9768->regmap))
return PTR_ERR(max9768->regmap); return PTR_ERR(max9768->regmap);
return snd_soc_register_codec(&client->dev, &max9768_codec_driver, return devm_snd_soc_register_component(&client->dev,
NULL, 0); &max9768_component_driver, NULL, 0);
}
static int max9768_i2c_remove(struct i2c_client *client)
{
snd_soc_unregister_codec(&client->dev);
return 0;
} }
static const struct i2c_device_id max9768_i2c_id[] = { static const struct i2c_device_id max9768_i2c_id[] = {
@ -226,7 +220,6 @@ static struct i2c_driver max9768_i2c_driver = {
.name = "max9768", .name = "max9768",
}, },
.probe = max9768_i2c_probe, .probe = max9768_i2c_probe,
.remove = max9768_i2c_remove,
.id_table = max9768_i2c_id, .id_table = max9768_i2c_id,
}; };
module_i2c_driver(max9768_i2c_driver); module_i2c_driver(max9768_i2c_driver);