diff options
author | Ian Molton <ian@mnementh.co.uk> | 2009-01-08 19:23:21 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2009-01-09 05:39:49 -0500 |
commit | 3e8e1952e3a3dd59b11233a532ca68e6471742d9 (patch) | |
tree | 3dff59c0b09cbcbc0e4b80a00cecd507219a821c /sound/soc/soc-core.c | |
parent | a6ba2b2dabb583e7820e567fb309d771b50cb9ff (diff) |
ASoC: cleanup duplicated code.
Many codec drivers were implementing cookie-cutter copies of the function
that adds kcontrols to the codec.
This patch moves this code to a common function snd_soc_add_controls() in
soc-core.c and updates all drivers using copies of this function to use the
new common version.
[Edited to raise priority of error log message and document parameters.
-- broonie]
Signed-off-by: Ian Molton <ian@mnementh.co.uk>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/soc-core.c')
-rw-r--r-- | sound/soc/soc-core.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 6cbe7e82f238..d3b97a7542e0 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
@@ -1495,6 +1495,37 @@ struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, | |||
1495 | EXPORT_SYMBOL_GPL(snd_soc_cnew); | 1495 | EXPORT_SYMBOL_GPL(snd_soc_cnew); |
1496 | 1496 | ||
1497 | /** | 1497 | /** |
1498 | * snd_soc_add_controls - add an array of controls to a codec. | ||
1499 | * Convienience function to add a list of controls. Many codecs were | ||
1500 | * duplicating this code. | ||
1501 | * | ||
1502 | * @codec: codec to add controls to | ||
1503 | * @controls: array of controls to add | ||
1504 | * @num_controls: number of elements in the array | ||
1505 | * | ||
1506 | * Return 0 for success, else error. | ||
1507 | */ | ||
1508 | int snd_soc_add_controls(struct snd_soc_codec *codec, | ||
1509 | const struct snd_kcontrol_new *controls, int num_controls) | ||
1510 | { | ||
1511 | struct snd_card *card = codec->card; | ||
1512 | int err, i; | ||
1513 | |||
1514 | for (i = 0; i < num_controls; i++) { | ||
1515 | const struct snd_kcontrol_new *control = &controls[i]; | ||
1516 | err = snd_ctl_add(card, snd_soc_cnew(control, codec, NULL)); | ||
1517 | if (err < 0) { | ||
1518 | dev_err(codec->dev, "%s: Failed to add %s\n", | ||
1519 | codec->name, control->name); | ||
1520 | return err; | ||
1521 | } | ||
1522 | } | ||
1523 | |||
1524 | return 0; | ||
1525 | } | ||
1526 | EXPORT_SYMBOL_GPL(snd_soc_add_controls); | ||
1527 | |||
1528 | /** | ||
1498 | * snd_soc_info_enum_double - enumerated double mixer info callback | 1529 | * snd_soc_info_enum_double - enumerated double mixer info callback |
1499 | * @kcontrol: mixer control | 1530 | * @kcontrol: mixer control |
1500 | * @uinfo: control element information | 1531 | * @uinfo: control element information |