diff options
Diffstat (limited to 'sound/pci/pcxhr')
-rw-r--r-- | sound/pci/pcxhr/pcxhr.c | 6 | ||||
-rw-r--r-- | sound/pci/pcxhr/pcxhr_core.c | 27 | ||||
-rw-r--r-- | sound/pci/pcxhr/pcxhr_hwdep.c | 15 |
3 files changed, 30 insertions, 18 deletions
diff --git a/sound/pci/pcxhr/pcxhr.c b/sound/pci/pcxhr/pcxhr.c index 2c7e25336795..0e06c6c9fcc0 100644 --- a/sound/pci/pcxhr/pcxhr.c +++ b/sound/pci/pcxhr/pcxhr.c | |||
@@ -464,7 +464,8 @@ static int pcxhr_update_r_buffer(struct pcxhr_stream *stream) | |||
464 | pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS); | 464 | pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS); |
465 | pcxhr_set_pipe_cmd_params(&rmh, is_capture, stream->pipe->first_audio, stream_num, 0); | 465 | pcxhr_set_pipe_cmd_params(&rmh, is_capture, stream->pipe->first_audio, stream_num, 0); |
466 | 466 | ||
467 | snd_assert(subs->runtime->dma_bytes < 0x200000); /* max buffer size is 2 MByte */ | 467 | /* max buffer size is 2 MByte */ |
468 | snd_BUG_ON(subs->runtime->dma_bytes >= 0x200000); | ||
468 | rmh.cmd[1] = subs->runtime->dma_bytes * 8; /* size in bits */ | 469 | rmh.cmd[1] = subs->runtime->dma_bytes * 8; /* size in bits */ |
469 | rmh.cmd[2] = subs->runtime->dma_addr >> 24; /* most significant byte */ | 470 | rmh.cmd[2] = subs->runtime->dma_addr >> 24; /* most significant byte */ |
470 | rmh.cmd[2] |= 1<<19; /* this is a circular buffer */ | 471 | rmh.cmd[2] |= 1<<19; /* this is a circular buffer */ |
@@ -1228,7 +1229,8 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id | |||
1228 | return -ENOMEM; | 1229 | return -ENOMEM; |
1229 | } | 1230 | } |
1230 | 1231 | ||
1231 | snd_assert(pci_id->driver_data < PCI_ID_LAST, return -ENODEV); | 1232 | if (snd_BUG_ON(pci_id->driver_data >= PCI_ID_LAST)) |
1233 | return -ENODEV; | ||
1232 | card_name = pcxhr_board_params[pci_id->driver_data].board_name; | 1234 | card_name = pcxhr_board_params[pci_id->driver_data].board_name; |
1233 | mgr->playback_chips = pcxhr_board_params[pci_id->driver_data].playback_chips; | 1235 | mgr->playback_chips = pcxhr_board_params[pci_id->driver_data].playback_chips; |
1234 | mgr->capture_chips = pcxhr_board_params[pci_id->driver_data].capture_chips; | 1236 | mgr->capture_chips = pcxhr_board_params[pci_id->driver_data].capture_chips; |
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 | } |
diff --git a/sound/pci/pcxhr/pcxhr_hwdep.c b/sound/pci/pcxhr/pcxhr_hwdep.c index d2f043278cf4..96640d9c227d 100644 --- a/sound/pci/pcxhr/pcxhr_hwdep.c +++ b/sound/pci/pcxhr/pcxhr_hwdep.c | |||
@@ -65,15 +65,18 @@ static int pcxhr_init_board(struct pcxhr_mgr *mgr) | |||
65 | if (err) | 65 | if (err) |
66 | return err; | 66 | return err; |
67 | /* test 8 or 12 phys out */ | 67 | /* test 8 or 12 phys out */ |
68 | snd_assert((rmh.stat[0] & MASK_FIRST_FIELD) == mgr->playback_chips*2, | 68 | if ((rmh.stat[0] & MASK_FIRST_FIELD) != mgr->playback_chips * 2) |
69 | return -EINVAL); | 69 | return -EINVAL; |
70 | /* test 8 or 2 phys in */ | 70 | /* test 8 or 2 phys in */ |
71 | snd_assert(((rmh.stat[0] >> (2*FIELD_SIZE)) & MASK_FIRST_FIELD) == | 71 | if (((rmh.stat[0] >> (2 * FIELD_SIZE)) & MASK_FIRST_FIELD) != |
72 | mgr->capture_chips * 2, return -EINVAL); | 72 | mgr->capture_chips * 2) |
73 | return -EINVAL; | ||
73 | /* test max nb substream per board */ | 74 | /* test max nb substream per board */ |
74 | snd_assert((rmh.stat[1] & 0x5F) >= card_streams, return -EINVAL); | 75 | if ((rmh.stat[1] & 0x5F) < card_streams) |
76 | return -EINVAL; | ||
75 | /* test max nb substream per pipe */ | 77 | /* test max nb substream per pipe */ |
76 | snd_assert(((rmh.stat[1]>>7)&0x5F) >= PCXHR_PLAYBACK_STREAMS, return -EINVAL); | 78 | if (((rmh.stat[1] >> 7) & 0x5F) < PCXHR_PLAYBACK_STREAMS) |
79 | return -EINVAL; | ||
77 | 80 | ||
78 | pcxhr_init_rmh(&rmh, CMD_VERSION); | 81 | pcxhr_init_rmh(&rmh, CMD_VERSION); |
79 | /* firmware num for DSP */ | 82 | /* firmware num for DSP */ |