aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/emu10k1/emufx.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/pci/emu10k1/emufx.c')
-rw-r--r--sound/pci/emu10k1/emufx.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index 20db3ac6cd61..177c4ad0f778 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -364,12 +364,18 @@ static int snd_emu10k1_gpr_ctl_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value
364 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, db_table[val]); 364 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[i], 0, db_table[val]);
365 break; 365 break;
366 case EMU10K1_GPR_TRANSLATION_BASS: 366 case EMU10K1_GPR_TRANSLATION_BASS:
367 snd_runtime_check((ctl->count % 5) == 0 && (ctl->count / 5) == ctl->vcount, change = -EIO; goto __error); 367 if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) {
368 change = -EIO;
369 goto __error;
370 }
368 for (j = 0; j < 5; j++) 371 for (j = 0; j < 5; j++)
369 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, bass_table[val][j]); 372 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, bass_table[val][j]);
370 break; 373 break;
371 case EMU10K1_GPR_TRANSLATION_TREBLE: 374 case EMU10K1_GPR_TRANSLATION_TREBLE:
372 snd_runtime_check((ctl->count % 5) == 0 && (ctl->count / 5) == ctl->vcount, change = -EIO; goto __error); 375 if ((ctl->count % 5) != 0 || (ctl->count / 5) != ctl->vcount) {
376 change = -EIO;
377 goto __error;
378 }
373 for (j = 0; j < 5; j++) 379 for (j = 0; j < 5; j++)
374 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, treble_table[val][j]); 380 snd_emu10k1_ptr_write(emu, emu->gpr_base + ctl->gpr[j * ctl->vcount + i], 0, treble_table[val][j]);
375 break; 381 break;
@@ -412,8 +418,6 @@ int snd_emu10k1_fx8010_register_irq_handler(emu10k1_t *emu,
412 snd_emu10k1_fx8010_irq_t *irq; 418 snd_emu10k1_fx8010_irq_t *irq;
413 unsigned long flags; 419 unsigned long flags;
414 420
415 snd_runtime_check(emu, return -EINVAL);
416 snd_runtime_check(handler, return -EINVAL);
417 irq = kmalloc(sizeof(*irq), GFP_ATOMIC); 421 irq = kmalloc(sizeof(*irq), GFP_ATOMIC);
418 if (irq == NULL) 422 if (irq == NULL)
419 return -ENOMEM; 423 return -ENOMEM;
@@ -442,7 +446,6 @@ int snd_emu10k1_fx8010_unregister_irq_handler(emu10k1_t *emu,
442 snd_emu10k1_fx8010_irq_t *tmp; 446 snd_emu10k1_fx8010_irq_t *tmp;
443 unsigned long flags; 447 unsigned long flags;
444 448
445 snd_runtime_check(irq, return -EINVAL);
446 spin_lock_irqsave(&emu->fx8010.irq_lock, flags); 449 spin_lock_irqsave(&emu->fx8010.irq_lock, flags);
447 if ((tmp = emu->fx8010.irq_handlers) == irq) { 450 if ((tmp = emu->fx8010.irq_handlers) == irq) {
448 emu->fx8010.irq_handlers = tmp->next; 451 emu->fx8010.irq_handlers = tmp->next;
@@ -717,9 +720,15 @@ static int snd_emu10k1_add_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode
717 err = -EFAULT; 720 err = -EFAULT;
718 goto __error; 721 goto __error;
719 } 722 }
720 snd_runtime_check(gctl->id.iface == SNDRV_CTL_ELEM_IFACE_MIXER || 723 if (gctl->id.iface != SNDRV_CTL_ELEM_IFACE_MIXER &&
721 gctl->id.iface == SNDRV_CTL_ELEM_IFACE_PCM, err = -EINVAL; goto __error); 724 gctl->id.iface != SNDRV_CTL_ELEM_IFACE_PCM) {
722 snd_runtime_check(gctl->id.name[0] != '\0', err = -EINVAL; goto __error); 725 err = -EINVAL;
726 goto __error;
727 }
728 if (! gctl->id.name[0]) {
729 err = -EINVAL;
730 goto __error;
731 }
723 ctl = snd_emu10k1_look_for_ctl(emu, &gctl->id); 732 ctl = snd_emu10k1_look_for_ctl(emu, &gctl->id);
724 memset(&knew, 0, sizeof(knew)); 733 memset(&knew, 0, sizeof(knew));
725 knew.iface = gctl->id.iface; 734 knew.iface = gctl->id.iface;
@@ -783,7 +792,8 @@ static int snd_emu10k1_del_controls(emu10k1_t *emu, emu10k1_fx8010_code_t *icode
783 792
784 for (i = 0, _id = icode->gpr_del_controls; 793 for (i = 0, _id = icode->gpr_del_controls;
785 i < icode->gpr_del_control_count; i++, _id++) { 794 i < icode->gpr_del_control_count; i++, _id++) {
786 snd_runtime_check(copy_from_user(&id, _id, sizeof(id)) == 0, return -EFAULT); 795 if (copy_from_user(&id, _id, sizeof(id)))
796 return -EFAULT;
787 down_write(&card->controls_rwsem); 797 down_write(&card->controls_rwsem);
788 ctl = snd_emu10k1_look_for_ctl(emu, &id); 798 ctl = snd_emu10k1_look_for_ctl(emu, &id);
789 if (ctl) 799 if (ctl)
@@ -2075,14 +2085,16 @@ void snd_emu10k1_free_efx(emu10k1_t *emu)
2075#if 0 // FIXME: who use them? 2085#if 0 // FIXME: who use them?
2076int snd_emu10k1_fx8010_tone_control_activate(emu10k1_t *emu, int output) 2086int snd_emu10k1_fx8010_tone_control_activate(emu10k1_t *emu, int output)
2077{ 2087{
2078 snd_runtime_check(output >= 0 && output < 6, return -EINVAL); 2088 if (output < 0 || output >= 6)
2089 return -EINVAL;
2079 snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 1); 2090 snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 1);
2080 return 0; 2091 return 0;
2081} 2092}
2082 2093
2083int snd_emu10k1_fx8010_tone_control_deactivate(emu10k1_t *emu, int output) 2094int snd_emu10k1_fx8010_tone_control_deactivate(emu10k1_t *emu, int output)
2084{ 2095{
2085 snd_runtime_check(output >= 0 && output < 6, return -EINVAL); 2096 if (output < 0 || output >= 6)
2097 return -EINVAL;
2086 snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 0); 2098 snd_emu10k1_ptr_write(emu, emu->gpr_base + 0x94 + output, 0, 0);
2087 return 0; 2099 return 0;
2088} 2100}