alsactl: remove open-coded search

Remove search_comment_item since it does the same as snd_config_search.

Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
This commit is contained in:
Clemens Ladisch 2010-05-26 10:19:17 +02:00
parent ad47784b01
commit 224c12238e

View file

@ -899,32 +899,15 @@ static int add_user_control(snd_ctl_t *handle, snd_ctl_elem_info_t *info, snd_co
return snd_ctl_elem_info(handle, info); return snd_ctl_elem_info(handle, info);
} }
/*
* look for a config node with the given item name
*/
static snd_config_t *search_comment_item(snd_config_t *conf, const char *name)
{
snd_config_iterator_t i, next;
snd_config_for_each(i, next, conf) {
snd_config_t *n = snd_config_iterator_entry(i);
const char *id;
if (snd_config_get_id(n, &id) < 0)
continue;
if (strcmp(id, name) == 0)
return n;
}
return NULL;
}
/* /*
* check whether the config item has the same of compatible type * check whether the config item has the same of compatible type
*/ */
static int check_comment_type(snd_config_t *conf, int type) static int check_comment_type(snd_config_t *conf, int type)
{ {
snd_config_t *n = search_comment_item(conf, "type"); snd_config_t *n;
int ctype; int ctype;
if (!n) if (snd_config_search(conf, "type", &n) < 0)
return 0; /* not defined */ return 0; /* not defined */
ctype = get_comment_type(n); ctype = get_comment_type(n);
if (ctype == type) if (ctype == type)
@ -980,8 +963,7 @@ static int check_comment_range(snd_ctl_t *handle, snd_config_t *conf,
long ndbmin, ndbmax; long ndbmin, ndbmax;
snd_ctl_elem_id_t *id; snd_ctl_elem_id_t *id;
n = search_comment_item(conf, "range"); if (snd_config_search(conf, "range", &n) < 0)
if (!n)
return 0; return 0;
if (get_comment_range(n, SND_CTL_ELEM_TYPE_INTEGER, if (get_comment_range(n, SND_CTL_ELEM_TYPE_INTEGER,
&omin, &omax, &ostep) < 0) &omin, &omax, &ostep) < 0)
@ -996,13 +978,11 @@ static int check_comment_range(snd_ctl_t *handle, snd_config_t *conf,
if (omin >= omax || nmin >= nmax) if (omin >= omax || nmin >= nmax)
return 0; /* invalid values */ return 0; /* invalid values */
n = search_comment_item(conf, "dbmin"); if (snd_config_search(conf, "dbmin", &n) < 0)
if (!n)
return 0; return 0;
if (config_integer(n, &odbmin, doit) < 0) if (config_integer(n, &odbmin, doit) < 0)
return 0; return 0;
n = search_comment_item(conf, "dbmax"); if (snd_config_search(conf, "dbmax", &n) < 0)
if (!n)
return 0; return 0;
if (config_integer(n, &odbmax, doit) < 0) if (config_integer(n, &odbmax, doit) < 0)
return 0; return 0;