tizen 2.3.1 release
[external/alsa-lib.git] / src / control / control_hw.c
index cf258b4..1920c99 100644 (file)
@@ -148,6 +148,11 @@ static int snd_ctl_hw_elem_info(snd_ctl_t *handle, snd_ctl_elem_info_t *info)
 static int snd_ctl_hw_elem_add(snd_ctl_t *handle, snd_ctl_elem_info_t *info)
 {
        snd_ctl_hw_t *hw = handle->private_data;
+
+       if (info->type == SNDRV_CTL_ELEM_TYPE_ENUMERATED &&
+           hw->protocol < SNDRV_PROTOCOL_VERSION(2, 0, 7))
+               return -ENXIO;
+
        if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEM_ADD, info) < 0)
                return -errno;
        return 0;
@@ -156,6 +161,11 @@ static int snd_ctl_hw_elem_add(snd_ctl_t *handle, snd_ctl_elem_info_t *info)
 static int snd_ctl_hw_elem_replace(snd_ctl_t *handle, snd_ctl_elem_info_t *info)
 {
        snd_ctl_hw_t *hw = handle->private_data;
+
+       if (info->type == SNDRV_CTL_ELEM_TYPE_ENUMERATED &&
+           hw->protocol < SNDRV_PROTOCOL_VERSION(2, 0, 7))
+               return -ENXIO;
+
        if (ioctl(hw->fd, SNDRV_CTL_IOCTL_ELEM_REPLACE, info) < 0)
                return -errno;
        return 0;
@@ -414,6 +424,7 @@ int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card, int mode)
        if (err < 0) {
                close(fd);
                free(hw);
+               return err;
        }
        ctl->ops = &snd_ctl_hw_ops;
        ctl->private_data = hw;