Commit 81b45090 authored by Takashi Iwai's avatar Takashi Iwai

ALSA: emu10k1: Fix annotation and cast for the recent uapi header change

The recent sound/emu10k1.h uapi header change by the commit
2e468867 ("ALSA: emu10k1: Make uapi/emu10k1.h compilable again")
made sparse angry because of the inconsistency of __user annotation
and the own ctl id struct that were changed in uapi header.

This patch addresses those by adjusting the cast and annotations
properly again.

Fixes: 2e468867 ("ALSA: emu10k1: Make uapi/emu10k1.h compilable again")
Link: https://lore.kernel.org/r/20200202090724.18232-1-tiwai@suse.deSigned-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent 2acf25f1
...@@ -463,7 +463,7 @@ static void snd_emu10k1_write_op(struct snd_emu10k1_fx8010_code *icode, ...@@ -463,7 +463,7 @@ static void snd_emu10k1_write_op(struct snd_emu10k1_fx8010_code *icode,
u_int32_t *code; u_int32_t *code;
if (snd_BUG_ON(*ptr >= 512)) if (snd_BUG_ON(*ptr >= 512))
return; return;
code = (u_int32_t __force *)icode->code + (*ptr) * 2; code = icode->code + (*ptr) * 2;
set_bit(*ptr, icode->code_valid); set_bit(*ptr, icode->code_valid);
code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff); code[0] = ((x & 0x3ff) << 10) | (y & 0x3ff);
code[1] = ((op & 0x0f) << 20) | ((r & 0x3ff) << 10) | (a & 0x3ff); code[1] = ((op & 0x0f) << 20) | ((r & 0x3ff) << 10) | (a & 0x3ff);
...@@ -480,7 +480,7 @@ static void snd_emu10k1_audigy_write_op(struct snd_emu10k1_fx8010_code *icode, ...@@ -480,7 +480,7 @@ static void snd_emu10k1_audigy_write_op(struct snd_emu10k1_fx8010_code *icode,
u_int32_t *code; u_int32_t *code;
if (snd_BUG_ON(*ptr >= 1024)) if (snd_BUG_ON(*ptr >= 1024))
return; return;
code = (u_int32_t __force *)icode->code + (*ptr) * 2; code = icode->code + (*ptr) * 2;
set_bit(*ptr, icode->code_valid); set_bit(*ptr, icode->code_valid);
code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff); code[0] = ((x & 0x7ff) << 12) | (y & 0x7ff);
code[1] = ((op & 0x0f) << 24) | ((r & 0x7ff) << 12) | (a & 0x7ff); code[1] = ((op & 0x0f) << 24) | ((r & 0x7ff) << 12) | (a & 0x7ff);
...@@ -513,8 +513,8 @@ static int snd_emu10k1_gpr_poke(struct snd_emu10k1 *emu, ...@@ -513,8 +513,8 @@ static int snd_emu10k1_gpr_poke(struct snd_emu10k1 *emu,
if (!test_bit(gpr, icode->gpr_valid)) if (!test_bit(gpr, icode->gpr_valid))
continue; continue;
if (in_kernel) if (in_kernel)
val = *(__force u32 *)&icode->gpr_map[gpr]; val = icode->gpr_map[gpr];
else if (get_user(val, &icode->gpr_map[gpr])) else if (get_user(val, (__user u32 *)&icode->gpr_map[gpr]))
return -EFAULT; return -EFAULT;
snd_emu10k1_ptr_write(emu, emu->gpr_base + gpr, 0, val); snd_emu10k1_ptr_write(emu, emu->gpr_base + gpr, 0, val);
} }
...@@ -530,7 +530,7 @@ static int snd_emu10k1_gpr_peek(struct snd_emu10k1 *emu, ...@@ -530,7 +530,7 @@ static int snd_emu10k1_gpr_peek(struct snd_emu10k1 *emu,
for (gpr = 0; gpr < (emu->audigy ? 0x200 : 0x100); gpr++) { for (gpr = 0; gpr < (emu->audigy ? 0x200 : 0x100); gpr++) {
set_bit(gpr, icode->gpr_valid); set_bit(gpr, icode->gpr_valid);
val = snd_emu10k1_ptr_read(emu, emu->gpr_base + gpr, 0); val = snd_emu10k1_ptr_read(emu, emu->gpr_base + gpr, 0);
if (put_user(val, &icode->gpr_map[gpr])) if (put_user(val, (__user u32 *)&icode->gpr_map[gpr]))
return -EFAULT; return -EFAULT;
} }
return 0; return 0;
...@@ -547,11 +547,11 @@ static int snd_emu10k1_tram_poke(struct snd_emu10k1 *emu, ...@@ -547,11 +547,11 @@ static int snd_emu10k1_tram_poke(struct snd_emu10k1 *emu,
if (!test_bit(tram, icode->tram_valid)) if (!test_bit(tram, icode->tram_valid))
continue; continue;
if (in_kernel) { if (in_kernel) {
val = *(__force u32 *)&icode->tram_data_map[tram]; val = icode->tram_data_map[tram];
addr = *(__force u32 *)&icode->tram_addr_map[tram]; addr = icode->tram_addr_map[tram];
} else { } else {
if (get_user(val, &icode->tram_data_map[tram]) || if (get_user(val, (__user __u32 *)&icode->tram_data_map[tram]) ||
get_user(addr, &icode->tram_addr_map[tram])) get_user(addr, (__user __u32 *)&icode->tram_addr_map[tram]))
return -EFAULT; return -EFAULT;
} }
snd_emu10k1_ptr_write(emu, TANKMEMDATAREGBASE + tram, 0, val); snd_emu10k1_ptr_write(emu, TANKMEMDATAREGBASE + tram, 0, val);
...@@ -581,8 +581,8 @@ static int snd_emu10k1_tram_peek(struct snd_emu10k1 *emu, ...@@ -581,8 +581,8 @@ static int snd_emu10k1_tram_peek(struct snd_emu10k1 *emu,
addr = snd_emu10k1_ptr_read(emu, TANKMEMADDRREGBASE + tram, 0) >> 12; addr = snd_emu10k1_ptr_read(emu, TANKMEMADDRREGBASE + tram, 0) >> 12;
addr |= snd_emu10k1_ptr_read(emu, A_TANKMEMCTLREGBASE + tram, 0) << 20; addr |= snd_emu10k1_ptr_read(emu, A_TANKMEMCTLREGBASE + tram, 0) << 20;
} }
if (put_user(val, &icode->tram_data_map[tram]) || if (put_user(val, (__user u32 *)&icode->tram_data_map[tram]) ||
put_user(addr, &icode->tram_addr_map[tram])) put_user(addr, (__user u32 *)&icode->tram_addr_map[tram]))
return -EFAULT; return -EFAULT;
} }
return 0; return 0;
...@@ -598,11 +598,11 @@ static int snd_emu10k1_code_poke(struct snd_emu10k1 *emu, ...@@ -598,11 +598,11 @@ static int snd_emu10k1_code_poke(struct snd_emu10k1 *emu,
if (!test_bit(pc / 2, icode->code_valid)) if (!test_bit(pc / 2, icode->code_valid))
continue; continue;
if (in_kernel) { if (in_kernel) {
lo = *(__force u32 *)&icode->code[pc + 0]; lo = icode->code[pc + 0];
hi = *(__force u32 *)&icode->code[pc + 1]; hi = icode->code[pc + 1];
} else { } else {
if (get_user(lo, &icode->code[pc + 0]) || if (get_user(lo, (__user u32 *)&icode->code[pc + 0]) ||
get_user(hi, &icode->code[pc + 1])) get_user(hi, (__user u32 *)&icode->code[pc + 1]))
return -EFAULT; return -EFAULT;
} }
snd_emu10k1_efx_write(emu, pc + 0, lo); snd_emu10k1_efx_write(emu, pc + 0, lo);
...@@ -619,17 +619,21 @@ static int snd_emu10k1_code_peek(struct snd_emu10k1 *emu, ...@@ -619,17 +619,21 @@ static int snd_emu10k1_code_peek(struct snd_emu10k1 *emu,
memset(icode->code_valid, 0, sizeof(icode->code_valid)); memset(icode->code_valid, 0, sizeof(icode->code_valid));
for (pc = 0; pc < (emu->audigy ? 2*1024 : 2*512); pc += 2) { for (pc = 0; pc < (emu->audigy ? 2*1024 : 2*512); pc += 2) {
set_bit(pc / 2, icode->code_valid); set_bit(pc / 2, icode->code_valid);
if (put_user(snd_emu10k1_efx_read(emu, pc + 0), &icode->code[pc + 0])) if (put_user(snd_emu10k1_efx_read(emu, pc + 0),
(__user u32 *)&icode->code[pc + 0]))
return -EFAULT; return -EFAULT;
if (put_user(snd_emu10k1_efx_read(emu, pc + 1), &icode->code[pc + 1])) if (put_user(snd_emu10k1_efx_read(emu, pc + 1),
(__user u32 *)&icode->code[pc + 1]))
return -EFAULT; return -EFAULT;
} }
return 0; return 0;
} }
static struct snd_emu10k1_fx8010_ctl * static struct snd_emu10k1_fx8010_ctl *
snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu, struct emu10k1_ctl_elem_id *id) snd_emu10k1_look_for_ctl(struct snd_emu10k1 *emu,
struct emu10k1_ctl_elem_id *_id)
{ {
struct snd_ctl_elem_id *id = (struct snd_ctl_elem_id *)_id;
struct snd_emu10k1_fx8010_ctl *ctl; struct snd_emu10k1_fx8010_ctl *ctl;
struct snd_kcontrol *kcontrol; struct snd_kcontrol *kcontrol;
...@@ -672,41 +676,60 @@ static unsigned int *copy_tlv(const unsigned int __user *_tlv, bool in_kernel) ...@@ -672,41 +676,60 @@ static unsigned int *copy_tlv(const unsigned int __user *_tlv, bool in_kernel)
} }
static int copy_gctl(struct snd_emu10k1 *emu, static int copy_gctl(struct snd_emu10k1 *emu,
struct snd_emu10k1_fx8010_control_gpr *gctl, struct snd_emu10k1_fx8010_control_gpr *dst,
struct snd_emu10k1_fx8010_control_gpr __user *_gctl, struct snd_emu10k1_fx8010_control_gpr *src,
int idx, bool in_kernel) int idx, bool in_kernel)
{ {
struct snd_emu10k1_fx8010_control_old_gpr __user *octl; struct snd_emu10k1_fx8010_control_gpr __user *_src;
struct snd_emu10k1_fx8010_control_old_gpr *octl;
struct snd_emu10k1_fx8010_control_old_gpr __user *_octl;
_src = (struct snd_emu10k1_fx8010_control_gpr __user *)src;
if (emu->support_tlv) { if (emu->support_tlv) {
if (in_kernel) if (in_kernel)
memcpy(gctl, (__force void *)&_gctl[idx], sizeof(*gctl)); *dst = src[idx];
else if (copy_from_user(gctl, &_gctl[idx], sizeof(*gctl))) else if (copy_from_user(dst, &_src[idx], sizeof(*src)))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl; octl = (struct snd_emu10k1_fx8010_control_old_gpr *)src;
_octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)octl;
if (in_kernel) if (in_kernel)
memcpy(gctl, (__force void *)&octl[idx], sizeof(*octl)); memcpy(dst, &octl[idx], sizeof(*octl));
else if (copy_from_user(gctl, &octl[idx], sizeof(*octl))) else if (copy_from_user(dst, &_octl[idx], sizeof(*octl)))
return -EFAULT; return -EFAULT;
gctl->tlv = NULL; dst->tlv = NULL;
return 0; return 0;
} }
static int copy_gctl_to_user(struct snd_emu10k1 *emu, static int copy_gctl_to_user(struct snd_emu10k1 *emu,
struct snd_emu10k1_fx8010_control_gpr __user *_gctl, struct snd_emu10k1_fx8010_control_gpr *dst,
struct snd_emu10k1_fx8010_control_gpr *gctl, struct snd_emu10k1_fx8010_control_gpr *src,
int idx) int idx)
{ {
struct snd_emu10k1_fx8010_control_gpr __user *_dst;
struct snd_emu10k1_fx8010_control_old_gpr __user *octl; struct snd_emu10k1_fx8010_control_old_gpr __user *octl;
_dst = (struct snd_emu10k1_fx8010_control_gpr __user *)dst;
if (emu->support_tlv) if (emu->support_tlv)
return copy_to_user(&_gctl[idx], gctl, sizeof(*gctl)); return copy_to_user(&_dst[idx], src, sizeof(*src));
octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)_gctl; octl = (struct snd_emu10k1_fx8010_control_old_gpr __user *)dst;
return copy_to_user(&octl[idx], gctl, sizeof(*octl)); return copy_to_user(&octl[idx], src, sizeof(*octl));
}
static int copy_ctl_elem_id(const struct emu10k1_ctl_elem_id *list, int i,
struct emu10k1_ctl_elem_id *ret, bool in_kernel)
{
struct emu10k1_ctl_elem_id __user *_id =
(struct emu10k1_ctl_elem_id __user *)&list[i];
if (in_kernel)
*ret = list[i];
else if (copy_from_user(ret, _id, sizeof(*ret)))
return -EFAULT;
return 0;
} }
static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu,
...@@ -714,17 +737,16 @@ static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, ...@@ -714,17 +737,16 @@ static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu,
bool in_kernel) bool in_kernel)
{ {
unsigned int i; unsigned int i;
struct emu10k1_ctl_elem_id __user *_id;
struct emu10k1_ctl_elem_id id; struct emu10k1_ctl_elem_id id;
struct snd_emu10k1_fx8010_control_gpr *gctl; struct snd_emu10k1_fx8010_control_gpr *gctl;
struct snd_ctl_elem_id *gctl_id;
int err; int err;
_id = (__force struct emu10k1_ctl_elem_id __user *)icode->gpr_del_controls; for (i = 0; i < icode->gpr_del_control_count; i++) {
for (i = 0; i < icode->gpr_del_control_count; i++, _id++) { err = copy_ctl_elem_id(icode->gpr_del_controls, i, &id,
if (in_kernel) in_kernel);
id = *(__force struct emu10k1_ctl_elem_id *)_id; if (err < 0)
else if (copy_from_user(&id, _id, sizeof(id))) return err;
return -EFAULT;
if (snd_emu10k1_look_for_ctl(emu, &id) == NULL) if (snd_emu10k1_look_for_ctl(emu, &id) == NULL)
return -ENOENT; return -ENOENT;
} }
...@@ -740,16 +762,16 @@ static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu, ...@@ -740,16 +762,16 @@ static int snd_emu10k1_verify_controls(struct snd_emu10k1 *emu,
} }
if (snd_emu10k1_look_for_ctl(emu, &gctl->id)) if (snd_emu10k1_look_for_ctl(emu, &gctl->id))
continue; continue;
gctl_id = (struct snd_ctl_elem_id *)&gctl->id;
down_read(&emu->card->controls_rwsem); down_read(&emu->card->controls_rwsem);
if (snd_ctl_find_id(emu->card, if (snd_ctl_find_id(emu->card, gctl_id)) {
(struct snd_ctl_elem_id *)&gctl->id)) {
up_read(&emu->card->controls_rwsem); up_read(&emu->card->controls_rwsem);
err = -EEXIST; err = -EEXIST;
goto __error; goto __error;
} }
up_read(&emu->card->controls_rwsem); up_read(&emu->card->controls_rwsem);
if (gctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER && if (gctl_id->iface != SNDRV_CTL_ELEM_IFACE_MIXER &&
gctl->id.iface != SNDRV_CTL_ELEM_IFACE_PCM) { gctl_id->iface != SNDRV_CTL_ELEM_IFACE_PCM) {
err = -EINVAL; err = -EINVAL;
goto __error; goto __error;
} }
...@@ -784,6 +806,7 @@ static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu, ...@@ -784,6 +806,7 @@ static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
{ {
unsigned int i, j; unsigned int i, j;
struct snd_emu10k1_fx8010_control_gpr *gctl; struct snd_emu10k1_fx8010_control_gpr *gctl;
struct snd_ctl_elem_id *gctl_id;
struct snd_emu10k1_fx8010_ctl *ctl, *nctl; struct snd_emu10k1_fx8010_ctl *ctl, *nctl;
struct snd_kcontrol_new knew; struct snd_kcontrol_new knew;
struct snd_kcontrol *kctl; struct snd_kcontrol *kctl;
...@@ -804,24 +827,25 @@ static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu, ...@@ -804,24 +827,25 @@ static int snd_emu10k1_add_controls(struct snd_emu10k1 *emu,
err = -EFAULT; err = -EFAULT;
goto __error; goto __error;
} }
if (gctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER && gctl_id = (struct snd_ctl_elem_id *)&gctl->id;
gctl->id.iface != SNDRV_CTL_ELEM_IFACE_PCM) { if (gctl_id->iface != SNDRV_CTL_ELEM_IFACE_MIXER &&
gctl_id->iface != SNDRV_CTL_ELEM_IFACE_PCM) {
err = -EINVAL; err = -EINVAL;
goto __error; goto __error;
} }
if (! gctl->id.name[0]) { if (!*gctl_id->name) {
err = -EINVAL; err = -EINVAL;
goto __error; goto __error;
} }
ctl = snd_emu10k1_look_for_ctl(emu, &gctl->id); ctl = snd_emu10k1_look_for_ctl(emu, &gctl->id);
memset(&knew, 0, sizeof(knew)); memset(&knew, 0, sizeof(knew));
knew.iface = gctl->id.iface; knew.iface = gctl_id->iface;
knew.name = gctl->id.name; knew.name = gctl_id->name;
knew.index = gctl->id.index; knew.index = gctl_id->index;
knew.device = gctl->id.device; knew.device = gctl_id->device;
knew.subdevice = gctl->id.subdevice; knew.subdevice = gctl_id->subdevice;
knew.info = snd_emu10k1_gpr_ctl_info; knew.info = snd_emu10k1_gpr_ctl_info;
knew.tlv.p = copy_tlv((__force const unsigned int __user *)gctl->tlv, in_kernel); knew.tlv.p = copy_tlv((const unsigned int __user *)gctl->tlv, in_kernel);
if (knew.tlv.p) if (knew.tlv.p)
knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE | knew.access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
SNDRV_CTL_ELEM_ACCESS_TLV_READ; SNDRV_CTL_ELEM_ACCESS_TLV_READ;
...@@ -878,17 +902,15 @@ static int snd_emu10k1_del_controls(struct snd_emu10k1 *emu, ...@@ -878,17 +902,15 @@ static int snd_emu10k1_del_controls(struct snd_emu10k1 *emu,
{ {
unsigned int i; unsigned int i;
struct emu10k1_ctl_elem_id id; struct emu10k1_ctl_elem_id id;
struct emu10k1_ctl_elem_id __user *_id;
struct snd_emu10k1_fx8010_ctl *ctl; struct snd_emu10k1_fx8010_ctl *ctl;
struct snd_card *card = emu->card; struct snd_card *card = emu->card;
int err;
_id = (__force struct emu10k1_ctl_elem_id __user *)icode->gpr_del_controls; for (i = 0; i < icode->gpr_del_control_count; i++) {
err = copy_ctl_elem_id(icode->gpr_del_controls, i, &id,
for (i = 0; i < icode->gpr_del_control_count; i++, _id++) { in_kernel);
if (in_kernel) if (err < 0)
id = *(__force struct emu10k1_ctl_elem_id *)_id; return err;
else if (copy_from_user(&id, _id, sizeof(id)))
return -EFAULT;
down_write(&card->controls_rwsem); down_write(&card->controls_rwsem);
ctl = snd_emu10k1_look_for_ctl(emu, &id); ctl = snd_emu10k1_look_for_ctl(emu, &id);
if (ctl) if (ctl)
...@@ -917,7 +939,7 @@ static int snd_emu10k1_list_controls(struct snd_emu10k1 *emu, ...@@ -917,7 +939,7 @@ static int snd_emu10k1_list_controls(struct snd_emu10k1 *emu,
i < icode->gpr_list_control_count) { i < icode->gpr_list_control_count) {
memset(gctl, 0, sizeof(*gctl)); memset(gctl, 0, sizeof(*gctl));
id = &ctl->kcontrol->id; id = &ctl->kcontrol->id;
gctl->id.iface = id->iface; gctl->id.iface = (__force int)id->iface;
strlcpy(gctl->id.name, id->name, sizeof(gctl->id.name)); strlcpy(gctl->id.name, id->name, sizeof(gctl->id.name));
gctl->id.index = id->index; gctl->id.index = id->index;
gctl->id.device = id->device; gctl->id.device = id->device;
...@@ -1095,7 +1117,7 @@ static void ...@@ -1095,7 +1117,7 @@ static void
snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl, snd_emu10k1_init_mono_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
const char *name, int gpr, int defval) const char *name, int gpr, int defval)
{ {
ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
strcpy(ctl->id.name, name); strcpy(ctl->id.name, name);
ctl->vcount = ctl->count = 1; ctl->vcount = ctl->count = 1;
ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
...@@ -1116,7 +1138,7 @@ static void ...@@ -1116,7 +1138,7 @@ static void
snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl, snd_emu10k1_init_stereo_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
const char *name, int gpr, int defval) const char *name, int gpr, int defval)
{ {
ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
strcpy(ctl->id.name, name); strcpy(ctl->id.name, name);
ctl->vcount = ctl->count = 2; ctl->vcount = ctl->count = 2;
ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
...@@ -1138,7 +1160,7 @@ static void ...@@ -1138,7 +1160,7 @@ static void
snd_emu10k1_init_mono_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl, snd_emu10k1_init_mono_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
const char *name, int gpr, int defval) const char *name, int gpr, int defval)
{ {
ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
strcpy(ctl->id.name, name); strcpy(ctl->id.name, name);
ctl->vcount = ctl->count = 1; ctl->vcount = ctl->count = 1;
ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
...@@ -1151,7 +1173,7 @@ static void ...@@ -1151,7 +1173,7 @@ static void
snd_emu10k1_init_stereo_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl, snd_emu10k1_init_stereo_onoff_control(struct snd_emu10k1_fx8010_control_gpr *ctl,
const char *name, int gpr, int defval) const char *name, int gpr, int defval)
{ {
ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
strcpy(ctl->id.name, name); strcpy(ctl->id.name, name);
ctl->vcount = ctl->count = 2; ctl->vcount = ctl->count = 2;
ctl->gpr[0] = gpr + 0; ctl->value[0] = defval; ctl->gpr[0] = gpr + 0; ctl->value[0] = defval;
...@@ -1204,7 +1226,7 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu) ...@@ -1204,7 +1226,7 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
if (!icode) if (!icode)
return err; return err;
icode->gpr_map = (u_int32_t __user *) kcalloc(512 + 256 + 256 + 2 * 1024, icode->gpr_map = kcalloc(512 + 256 + 256 + 2 * 1024,
sizeof(u_int32_t), GFP_KERNEL); sizeof(u_int32_t), GFP_KERNEL);
if (!icode->gpr_map) if (!icode->gpr_map)
goto __err_gpr; goto __err_gpr;
...@@ -1213,7 +1235,7 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu) ...@@ -1213,7 +1235,7 @@ static int _snd_emu10k1_audigy_init_efx(struct snd_emu10k1 *emu)
if (!controls) if (!controls)
goto __err_ctrls; goto __err_ctrls;
gpr_map = (u32 __force *)icode->gpr_map; gpr_map = icode->gpr_map;
icode->tram_data_map = icode->gpr_map + 512; icode->tram_data_map = icode->gpr_map + 512;
icode->tram_addr_map = icode->tram_data_map + 256; icode->tram_addr_map = icode->tram_data_map + 256;
...@@ -1468,7 +1490,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) ...@@ -1468,7 +1490,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
ctl = &controls[nctl + 0]; ctl = &controls[nctl + 0];
ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
strcpy(ctl->id.name, "Tone Control - Bass"); strcpy(ctl->id.name, "Tone Control - Bass");
ctl->vcount = 2; ctl->vcount = 2;
ctl->count = 10; ctl->count = 10;
...@@ -1477,7 +1499,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) ...@@ -1477,7 +1499,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
ctl->value[0] = ctl->value[1] = 20; ctl->value[0] = ctl->value[1] = 20;
ctl->translation = EMU10K1_GPR_TRANSLATION_BASS; ctl->translation = EMU10K1_GPR_TRANSLATION_BASS;
ctl = &controls[nctl + 1]; ctl = &controls[nctl + 1];
ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
strcpy(ctl->id.name, "Tone Control - Treble"); strcpy(ctl->id.name, "Tone Control - Treble");
ctl->vcount = 2; ctl->vcount = 2;
ctl->count = 10; ctl->count = 10;
...@@ -1758,7 +1780,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) ...@@ -1758,7 +1780,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
A_OP(icode, &ptr, 0x0f, 0xc0, 0xc0, 0xcf, 0xc0); A_OP(icode, &ptr, 0x0f, 0xc0, 0xc0, 0xcf, 0xc0);
icode->gpr_add_control_count = nctl; icode->gpr_add_control_count = nctl;
icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls; icode->gpr_add_controls = controls;
emu->support_tlv = 1; /* support TLV */ emu->support_tlv = 1; /* support TLV */
err = snd_emu10k1_icode_poke(emu, icode, true); err = snd_emu10k1_icode_poke(emu, icode, true);
emu->support_tlv = 0; /* clear again */ emu->support_tlv = 0; /* clear again */
...@@ -1766,7 +1788,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input)) ...@@ -1766,7 +1788,7 @@ A_OP(icode, &ptr, iMAC0, A_GPR(var), A_GPR(var), A_GPR(vol), A_EXTIN(input))
__err: __err:
kfree(controls); kfree(controls);
__err_ctrls: __err_ctrls:
kfree((void __force *)icode->gpr_map); kfree(icode->gpr_map);
__err_gpr: __err_gpr:
kfree(icode); kfree(icode);
return err; return err;
...@@ -1839,7 +1861,7 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu) ...@@ -1839,7 +1861,7 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
if (!icode) if (!icode)
return err; return err;
icode->gpr_map = (u_int32_t __user *) kcalloc(256 + 160 + 160 + 2 * 512, icode->gpr_map = kcalloc(256 + 160 + 160 + 2 * 512,
sizeof(u_int32_t), GFP_KERNEL); sizeof(u_int32_t), GFP_KERNEL);
if (!icode->gpr_map) if (!icode->gpr_map)
goto __err_gpr; goto __err_gpr;
...@@ -1854,7 +1876,7 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu) ...@@ -1854,7 +1876,7 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
if (!ipcm) if (!ipcm)
goto __err_ipcm; goto __err_ipcm;
gpr_map = (u32 __force *)icode->gpr_map; gpr_map = icode->gpr_map;
icode->tram_data_map = icode->gpr_map + 256; icode->tram_data_map = icode->gpr_map + 256;
icode->tram_addr_map = icode->tram_data_map + 160; icode->tram_addr_map = icode->tram_data_map + 160;
...@@ -2188,7 +2210,7 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu) ...@@ -2188,7 +2210,7 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
OP(icode, &ptr, iACC3, GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 5), GPR(playback + 5), C_00000000, C_00000000); /* LFE */ OP(icode, &ptr, iACC3, GPR(playback + SND_EMU10K1_PLAYBACK_CHANNELS + 5), GPR(playback + 5), C_00000000, C_00000000); /* LFE */
ctl = &controls[i + 0]; ctl = &controls[i + 0];
ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
strcpy(ctl->id.name, "Tone Control - Bass"); strcpy(ctl->id.name, "Tone Control - Bass");
ctl->vcount = 2; ctl->vcount = 2;
ctl->count = 10; ctl->count = 10;
...@@ -2198,7 +2220,7 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu) ...@@ -2198,7 +2220,7 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
ctl->tlv = snd_emu10k1_bass_treble_db_scale; ctl->tlv = snd_emu10k1_bass_treble_db_scale;
ctl->translation = EMU10K1_GPR_TRANSLATION_BASS; ctl->translation = EMU10K1_GPR_TRANSLATION_BASS;
ctl = &controls[i + 1]; ctl = &controls[i + 1];
ctl->id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; ctl->id.iface = (__force int)SNDRV_CTL_ELEM_IFACE_MIXER;
strcpy(ctl->id.name, "Tone Control - Treble"); strcpy(ctl->id.name, "Tone Control - Treble");
ctl->vcount = 2; ctl->vcount = 2;
ctl->count = 10; ctl->count = 10;
...@@ -2384,7 +2406,7 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu) ...@@ -2384,7 +2406,7 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
if ((err = snd_emu10k1_fx8010_tram_setup(emu, ipcm->buffer_size)) < 0) if ((err = snd_emu10k1_fx8010_tram_setup(emu, ipcm->buffer_size)) < 0)
goto __err; goto __err;
icode->gpr_add_control_count = i; icode->gpr_add_control_count = i;
icode->gpr_add_controls = (struct snd_emu10k1_fx8010_control_gpr __user *)controls; icode->gpr_add_controls = controls;
emu->support_tlv = 1; /* support TLV */ emu->support_tlv = 1; /* support TLV */
err = snd_emu10k1_icode_poke(emu, icode, true); err = snd_emu10k1_icode_poke(emu, icode, true);
emu->support_tlv = 0; /* clear again */ emu->support_tlv = 0; /* clear again */
...@@ -2395,7 +2417,7 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu) ...@@ -2395,7 +2417,7 @@ static int _snd_emu10k1_init_efx(struct snd_emu10k1 *emu)
__err_ipcm: __err_ipcm:
kfree(controls); kfree(controls);
__err_ctrls: __err_ctrls:
kfree((void __force *)icode->gpr_map); kfree(icode->gpr_map);
__err_gpr: __err_gpr:
kfree(icode); kfree(icode);
return err; return err;
......
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