]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
ALSA: control: Allow to pass items zero to snd_ctl_enum_info()
authorTakashi Iwai <tiwai@suse.de>
Mon, 20 Oct 2014 16:08:50 +0000 (18:08 +0200)
committerTakashi Iwai <tiwai@suse.de>
Mon, 20 Oct 2014 16:25:41 +0000 (18:25 +0200)
Although this is weird, some drivers want to allow empty control
elements intentionally, e.g. the number of items may change depending
on the firmware status.  Let the function simply returning in such a
case.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/control.c

index f95df84437e1520410370e1f54eaf777e98ceb94..5c35bbaf881e15c8e4824cd0b351b40e9caf4e56 100644 (file)
@@ -1745,6 +1745,8 @@ int snd_ctl_enum_info(struct snd_ctl_elem_info *info, unsigned int channels,
        info->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
        info->count = channels;
        info->value.enumerated.items = items;
+       if (!items)
+               return 0;
        if (info->value.enumerated.item >= items)
                info->value.enumerated.item = items - 1;
        WARN(strlen(names[info->value.enumerated.item]) >= sizeof(info->value.enumerated.name),