diff options
Diffstat (limited to 'sound/pci/pcxhr/pcxhr_core.c')
-rw-r--r-- | sound/pci/pcxhr/pcxhr_core.c | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/sound/pci/pcxhr/pcxhr_core.c b/sound/pci/pcxhr/pcxhr_core.c index 000e6fed6e39..7143259cfe34 100644 --- a/sound/pci/pcxhr/pcxhr_core.c +++ b/sound/pci/pcxhr/pcxhr_core.c | |||
@@ -319,16 +319,20 @@ static int pcxhr_download_dsp(struct pcxhr_mgr *mgr, const struct firmware *dsp) | |||
319 | const unsigned char *data; | 319 | const unsigned char *data; |
320 | unsigned char dummy; | 320 | unsigned char dummy; |
321 | /* check the length of boot image */ | 321 | /* check the length of boot image */ |
322 | snd_assert(dsp->size > 0, return -EINVAL); | 322 | if (dsp->size <= 0) |
323 | snd_assert(dsp->size % 3 == 0, return -EINVAL); | 323 | return -EINVAL; |
324 | snd_assert(dsp->data, return -EINVAL); | 324 | if (dsp->size % 3) |
325 | return -EINVAL; | ||
326 | if (snd_BUG_ON(!dsp->data)) | ||
327 | return -EINVAL; | ||
325 | /* transfert data buffer from PC to DSP */ | 328 | /* transfert data buffer from PC to DSP */ |
326 | for (i = 0; i < dsp->size; i += 3) { | 329 | for (i = 0; i < dsp->size; i += 3) { |
327 | data = dsp->data + i; | 330 | data = dsp->data + i; |
328 | if (i == 0) { | 331 | if (i == 0) { |
329 | /* test data header consistency */ | 332 | /* test data header consistency */ |
330 | len = (unsigned int)((data[0]<<16) + (data[1]<<8) + data[2]); | 333 | len = (unsigned int)((data[0]<<16) + (data[1]<<8) + data[2]); |
331 | snd_assert((len==0) || (dsp->size == (len+2)*3), return -EINVAL); | 334 | if (len && dsp->size != (len + 2) * 3) |
335 | return -EINVAL; | ||
332 | } | 336 | } |
333 | /* wait DSP ready for new transfer */ | 337 | /* wait DSP ready for new transfer */ |
334 | err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_TRDY, | 338 | err = pcxhr_check_reg_bit(mgr, PCXHR_DSP_ISR, PCXHR_ISR_HI08_TRDY, |
@@ -389,7 +393,8 @@ int pcxhr_load_boot_binary(struct pcxhr_mgr *mgr, const struct firmware *boot) | |||
389 | unsigned char dummy; | 393 | unsigned char dummy; |
390 | 394 | ||
391 | /* send the hostport address to the DSP (only the upper 24 bit !) */ | 395 | /* send the hostport address to the DSP (only the upper 24 bit !) */ |
392 | snd_assert((physaddr & 0xff) == 0, return -EINVAL); | 396 | if (snd_BUG_ON(physaddr & 0xff)) |
397 | return -EINVAL; | ||
393 | PCXHR_OUTPL(mgr, PCXHR_PLX_MBOX1, (physaddr >> 8)); | 398 | PCXHR_OUTPL(mgr, PCXHR_PLX_MBOX1, (physaddr >> 8)); |
394 | 399 | ||
395 | err = pcxhr_send_it_dsp(mgr, PCXHR_IT_DOWNLOAD_BOOT, 0); | 400 | err = pcxhr_send_it_dsp(mgr, PCXHR_IT_DOWNLOAD_BOOT, 0); |
@@ -570,7 +575,8 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh) | |||
570 | u32 data; | 575 | u32 data; |
571 | unsigned char reg; | 576 | unsigned char reg; |
572 | 577 | ||
573 | snd_assert(rmh->cmd_len<PCXHR_SIZE_MAX_CMD, return -EINVAL); | 578 | if (snd_BUG_ON(rmh->cmd_len >= PCXHR_SIZE_MAX_CMD)) |
579 | return -EINVAL; | ||
574 | err = pcxhr_send_it_dsp(mgr, PCXHR_IT_MESSAGE, 1); | 580 | err = pcxhr_send_it_dsp(mgr, PCXHR_IT_MESSAGE, 1); |
575 | if (err) { | 581 | if (err) { |
576 | snd_printk(KERN_ERR "pcxhr_send_message : ED_DSP_CRASHED\n"); | 582 | snd_printk(KERN_ERR "pcxhr_send_message : ED_DSP_CRASHED\n"); |
@@ -677,7 +683,8 @@ static int pcxhr_send_msg_nolock(struct pcxhr_mgr *mgr, struct pcxhr_rmh *rmh) | |||
677 | */ | 683 | */ |
678 | void pcxhr_init_rmh(struct pcxhr_rmh *rmh, int cmd) | 684 | void pcxhr_init_rmh(struct pcxhr_rmh *rmh, int cmd) |
679 | { | 685 | { |
680 | snd_assert(cmd < CMD_LAST_INDEX, return); | 686 | if (snd_BUG_ON(cmd >= CMD_LAST_INDEX)) |
687 | return; | ||
681 | rmh->cmd[0] = pcxhr_dsp_cmds[cmd].opcode; | 688 | rmh->cmd[0] = pcxhr_dsp_cmds[cmd].opcode; |
682 | rmh->cmd_len = 1; | 689 | rmh->cmd_len = 1; |
683 | rmh->stat_len = pcxhr_dsp_cmds[cmd].st_length; | 690 | rmh->stat_len = pcxhr_dsp_cmds[cmd].st_length; |
@@ -690,17 +697,17 @@ void pcxhr_set_pipe_cmd_params(struct pcxhr_rmh *rmh, int capture, | |||
690 | unsigned int param1, unsigned int param2, | 697 | unsigned int param1, unsigned int param2, |
691 | unsigned int param3) | 698 | unsigned int param3) |
692 | { | 699 | { |
693 | snd_assert(param1 <= MASK_FIRST_FIELD); | 700 | snd_BUG_ON(param1 > MASK_FIRST_FIELD); |
694 | if (capture) | 701 | if (capture) |
695 | rmh->cmd[0] |= 0x800; /* COMMAND_RECORD_MASK */ | 702 | rmh->cmd[0] |= 0x800; /* COMMAND_RECORD_MASK */ |
696 | if (param1) | 703 | if (param1) |
697 | rmh->cmd[0] |= (param1 << FIELD_SIZE); | 704 | rmh->cmd[0] |= (param1 << FIELD_SIZE); |
698 | if (param2) { | 705 | if (param2) { |
699 | snd_assert(param2 <= MASK_FIRST_FIELD); | 706 | snd_BUG_ON(param2 > MASK_FIRST_FIELD); |
700 | rmh->cmd[0] |= param2; | 707 | rmh->cmd[0] |= param2; |
701 | } | 708 | } |
702 | if(param3) { | 709 | if(param3) { |
703 | snd_assert(param3 <= MASK_DSP_WORD); | 710 | snd_BUG_ON(param3 > MASK_DSP_WORD); |
704 | rmh->cmd[1] = param3; | 711 | rmh->cmd[1] = param3; |
705 | rmh->cmd_len = 2; | 712 | rmh->cmd_len = 2; |
706 | } | 713 | } |