فهرست منبع

ALSA: control: Allow to pass items zero to snd_ctl_enum_info()

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>
Takashi Iwai 11 سال پیش
والد
کامیت
a7e6fb9915
1فایلهای تغییر یافته به همراه2 افزوده شده و 0 حذف شده
  1. 2 0
      sound/core/control.c

+ 2 - 0
sound/core/control.c

@@ -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->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
 	info->count = channels;
 	info->count = channels;
 	info->value.enumerated.items = items;
 	info->value.enumerated.items = items;
+	if (!items)
+		return 0;
 	if (info->value.enumerated.item >= items)
 	if (info->value.enumerated.item >= items)
 		info->value.enumerated.item = items - 1;
 		info->value.enumerated.item = items - 1;
 	WARN(strlen(names[info->value.enumerated.item]) >= sizeof(info->value.enumerated.name),
 	WARN(strlen(names[info->value.enumerated.item]) >= sizeof(info->value.enumerated.name),