]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ALSA: ctl: evaluate macro instead of numerical value
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Thu, 9 Apr 2015 23:43:00 +0000 (08:43 +0900)
committerTakashi Iwai <tiwai@suse.de>
Fri, 10 Apr 2015 07:36:25 +0000 (09:36 +0200)
SNDRV_CTL_TLV_OP_XXX is defined but not used in core code. Instead,
raw numerical value is evaluated.

This commit replaces these values to these macros for better looking.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/control.c

index d677c27746e9896fd2181e64390f31cbd7388b2e..00fcaa0ca647e3b33e136ce17b8df08e7443db9c 100644 (file)
@@ -1099,7 +1099,7 @@ static int snd_ctl_elem_user_tlv(struct snd_kcontrol *kcontrol,
        int change = 0;
        void *new_data;
 
-       if (op_flag > 0) {
+       if (op_flag == SNDRV_CTL_TLV_OP_WRITE) {
                if (size > 1024 * 128)  /* sane value */
                        return -EINVAL;
 
@@ -1381,9 +1381,12 @@ static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file,
                goto __kctl_end;
        }
        vd = &kctl->vd[tlv.numid - kctl->id.numid];
-       if ((op_flag == 0 && (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) == 0) ||
-           (op_flag > 0 && (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) == 0) ||
-           (op_flag < 0 && (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND) == 0)) {
+       if ((op_flag == SNDRV_CTL_TLV_OP_READ &&
+            (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ) == 0) ||
+           (op_flag == SNDRV_CTL_TLV_OP_WRITE &&
+            (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_WRITE) == 0) ||
+           (op_flag == SNDRV_CTL_TLV_OP_CMD &&
+            (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND) == 0)) {
                err = -ENXIO;
                goto __kctl_end;
        }
@@ -1400,7 +1403,7 @@ static int snd_ctl_tlv_ioctl(struct snd_ctl_file *file,
                        return 0;
                }
        } else {
-               if (op_flag) {
+               if (op_flag != SNDRV_CTL_ELEM_ACCESS_TLV_READ) {
                        err = -ENXIO;
                        goto __kctl_end;
                }