Commit 8ace4f3c authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela

[ALSA] Remove indirect control access

This patch removes the indirect control access to the control elements.
The indirect access has never been used and is even broken on 32bit
ioctl wrapper.  Let's clean it up.
The pointers still remain in snd_ctl_elem_* structs just to make sure
that the struct size won't change.  Once after checking the size
consistency, we can get rid of them, too.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
parent 38f8b397
...@@ -696,7 +696,7 @@ struct snd_timer_tread { ...@@ -696,7 +696,7 @@ struct snd_timer_tread {
* * * *
****************************************************************************/ ****************************************************************************/
#define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 4) #define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 5)
struct snd_ctl_card_info { struct snd_ctl_card_info {
int card; /* card number */ int card; /* card number */
...@@ -745,8 +745,7 @@ typedef int __bitwise snd_ctl_elem_iface_t; ...@@ -745,8 +745,7 @@ typedef int __bitwise snd_ctl_elem_iface_t;
#define SNDRV_CTL_ELEM_ACCESS_OWNER (1<<10) /* write lock owner */ #define SNDRV_CTL_ELEM_ACCESS_OWNER (1<<10) /* write lock owner */
#define SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK (1<<28) /* kernel use a TLV callback */ #define SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK (1<<28) /* kernel use a TLV callback */
#define SNDRV_CTL_ELEM_ACCESS_USER (1<<29) /* user space element */ #define SNDRV_CTL_ELEM_ACCESS_USER (1<<29) /* user space element */
#define SNDRV_CTL_ELEM_ACCESS_DINDIRECT (1<<30) /* indirect access for matrix dimensions in the info structure */ /* bits 30 and 31 are obsoleted (for indirect access) */
#define SNDRV_CTL_ELEM_ACCESS_INDIRECT (1<<31) /* indirect access for element value in the value structure */
/* for further details see the ACPI and PCI power management specification */ /* for further details see the ACPI and PCI power management specification */
#define SNDRV_CTL_POWER_D0 0x0000 /* full On */ #define SNDRV_CTL_POWER_D0 0x0000 /* full On */
...@@ -800,30 +799,30 @@ struct snd_ctl_elem_info { ...@@ -800,30 +799,30 @@ struct snd_ctl_elem_info {
} value; } value;
union { union {
unsigned short d[4]; /* dimensions */ unsigned short d[4]; /* dimensions */
unsigned short *d_ptr; /* indirect */ unsigned short *d_ptr; /* indirect - obsoleted */
} dimen; } dimen;
unsigned char reserved[64-4*sizeof(unsigned short)]; unsigned char reserved[64-4*sizeof(unsigned short)];
}; };
struct snd_ctl_elem_value { struct snd_ctl_elem_value {
struct snd_ctl_elem_id id; /* W: element ID */ struct snd_ctl_elem_id id; /* W: element ID */
unsigned int indirect: 1; /* W: use indirect pointer (xxx_ptr member) */ unsigned int indirect: 1; /* W: indirect access - obsoleted */
union { union {
union { union {
long value[128]; long value[128];
long *value_ptr; long *value_ptr; /* obsoleted */
} integer; } integer;
union { union {
long long value[64]; long long value[64];
long long *value_ptr; long long *value_ptr; /* obsoleted */
} integer64; } integer64;
union { union {
unsigned int item[128]; unsigned int item[128];
unsigned int *item_ptr; unsigned int *item_ptr; /* obsoleted */
} enumerated; } enumerated;
union { union {
unsigned char data[512]; unsigned char data[512];
unsigned char *data_ptr; unsigned char *data_ptr; /* obsoleted */
} bytes; } bytes;
struct snd_aes_iec958 iec958; struct snd_aes_iec958 iec958;
} value; /* RO */ } value; /* RO */
......
...@@ -232,8 +232,6 @@ struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol, ...@@ -232,8 +232,6 @@ struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol,
access = ncontrol->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE : access = ncontrol->access == 0 ? SNDRV_CTL_ELEM_ACCESS_READWRITE :
(ncontrol->access & (SNDRV_CTL_ELEM_ACCESS_READWRITE| (ncontrol->access & (SNDRV_CTL_ELEM_ACCESS_READWRITE|
SNDRV_CTL_ELEM_ACCESS_INACTIVE| SNDRV_CTL_ELEM_ACCESS_INACTIVE|
SNDRV_CTL_ELEM_ACCESS_DINDIRECT|
SNDRV_CTL_ELEM_ACCESS_INDIRECT|
SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE| SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE|
SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK)); SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK));
kctl.info = ncontrol->info; kctl.info = ncontrol->info;
...@@ -692,7 +690,7 @@ int snd_ctl_elem_read(struct snd_card *card, struct snd_ctl_elem_value *control) ...@@ -692,7 +690,7 @@ int snd_ctl_elem_read(struct snd_card *card, struct snd_ctl_elem_value *control)
struct snd_kcontrol *kctl; struct snd_kcontrol *kctl;
struct snd_kcontrol_volatile *vd; struct snd_kcontrol_volatile *vd;
unsigned int index_offset; unsigned int index_offset;
int result, indirect; int result;
down_read(&card->controls_rwsem); down_read(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, &control->id); kctl = snd_ctl_find_id(card, &control->id);
...@@ -701,17 +699,12 @@ int snd_ctl_elem_read(struct snd_card *card, struct snd_ctl_elem_value *control) ...@@ -701,17 +699,12 @@ int snd_ctl_elem_read(struct snd_card *card, struct snd_ctl_elem_value *control)
} else { } else {
index_offset = snd_ctl_get_ioff(kctl, &control->id); index_offset = snd_ctl_get_ioff(kctl, &control->id);
vd = &kctl->vd[index_offset]; vd = &kctl->vd[index_offset];
indirect = vd->access & SNDRV_CTL_ELEM_ACCESS_INDIRECT ? 1 : 0; if ((vd->access & SNDRV_CTL_ELEM_ACCESS_READ) &&
if (control->indirect != indirect) { kctl->get != NULL) {
result = -EACCES; snd_ctl_build_ioff(&control->id, kctl, index_offset);
} else { result = kctl->get(kctl, control);
if ((vd->access & SNDRV_CTL_ELEM_ACCESS_READ) && kctl->get != NULL) { } else
snd_ctl_build_ioff(&control->id, kctl, index_offset); result = -EPERM;
result = kctl->get(kctl, control);
} else {
result = -EPERM;
}
}
} }
up_read(&card->controls_rwsem); up_read(&card->controls_rwsem);
return result; return result;
...@@ -748,7 +741,7 @@ int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file, ...@@ -748,7 +741,7 @@ int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file,
struct snd_kcontrol *kctl; struct snd_kcontrol *kctl;
struct snd_kcontrol_volatile *vd; struct snd_kcontrol_volatile *vd;
unsigned int index_offset; unsigned int index_offset;
int result, indirect; int result;
down_read(&card->controls_rwsem); down_read(&card->controls_rwsem);
kctl = snd_ctl_find_id(card, &control->id); kctl = snd_ctl_find_id(card, &control->id);
...@@ -757,23 +750,19 @@ int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file, ...@@ -757,23 +750,19 @@ int snd_ctl_elem_write(struct snd_card *card, struct snd_ctl_file *file,
} else { } else {
index_offset = snd_ctl_get_ioff(kctl, &control->id); index_offset = snd_ctl_get_ioff(kctl, &control->id);
vd = &kctl->vd[index_offset]; vd = &kctl->vd[index_offset];
indirect = vd->access & SNDRV_CTL_ELEM_ACCESS_INDIRECT ? 1 : 0; if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_WRITE) ||
if (control->indirect != indirect) { kctl->put == NULL ||
result = -EACCES; (file && vd->owner && vd->owner != file)) {
result = -EPERM;
} else { } else {
if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_WRITE) || snd_ctl_build_ioff(&control->id, kctl, index_offset);
kctl->put == NULL || result = kctl->put(kctl, control);
(file && vd->owner != NULL && vd->owner != file)) { }
result = -EPERM; if (result > 0) {
} else { up_read(&card->controls_rwsem);
snd_ctl_build_ioff(&control->id, kctl, index_offset); snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE,
result = kctl->put(kctl, control); &control->id);
} return 0;
if (result > 0) {
up_read(&card->controls_rwsem);
snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &control->id);
return 0;
}
} }
} }
up_read(&card->controls_rwsem); up_read(&card->controls_rwsem);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment