unsigned int data)
{
unsigned int res;
- int retry = 50;
+ unsigned long timeout = jiffies + msecs_to_jiffies(1000);
/* send bits of data specified by reg */
do {
reg, data);
if (res == VENDOR_STATUS_CHIPIO_OK)
return 0;
- } while (--retry);
+ msleep(20);
+ } while (time_before(jiffies, timeout));
+
return -EIO;
}
unsigned int data)
{
int res;
- int retry = 50;
+ unsigned long timeout = jiffies + msecs_to_jiffies(1000);
/* send bits of data specified by reg to dsp */
do {
res = snd_hda_codec_read(codec, WIDGET_DSP_CTRL, 0, reg, data);
if ((res >= 0) && (res != VENDOR_STATUS_DSPIO_BUSY))
return res;
- } while (--retry);
+ msleep(20);
+ } while (time_before(jiffies, timeout));
return -EIO;
}
unsigned int *bytes_returned)
{
struct ca0132_spec *spec = codec->spec;
- int retry;
int status = -1;
unsigned int scp_send_size = 0;
unsigned int total_size;
}
if (waiting_for_resp) {
+ unsigned long timeout = jiffies + msecs_to_jiffies(1000);
memset(return_buf, 0, return_buf_size);
- retry = 50;
do {
msleep(20);
- } while (spec->wait_scp && (--retry != 0));
+ } while (spec->wait_scp && time_before(jiffies, timeout));
waiting_for_resp = false;
- if (retry != 0) {
+ if (!spec->wait_scp) {
ret_msg = (struct scp_msg *)return_buf;
memcpy(&ret_msg->hdr, &spec->scp_resp_header, 4);
memcpy(&ret_msg->data, spec->scp_resp_data,
u32 chip_addx_remainder;
unsigned int run_size_words;
const struct dsp_image_seg *hci_write = NULL;
- int retry;
+ unsigned long timeout;
+ bool dma_active;
if (fls == NULL)
return -EINVAL;
status = dspxfr_hci_write(codec, hci_write);
hci_write = NULL;
}
- retry = 5000;
- while (dsp_is_dma_active(codec, dma_chan)) {
- if (--retry <= 0)
+
+ timeout = jiffies + msecs_to_jiffies(2000);
+ do {
+ dma_active = dsp_is_dma_active(codec, dma_chan);
+ if (!dma_active)
break;
- }
+ msleep(20);
+ } while (time_before(jiffies, timeout));
+ if (dma_active)
+ break;
+
snd_printdd(KERN_INFO "+++++ DMA complete");
dma_set_state(dma_engine, DMA_STATE_STOP);
dma_reset(dma_engine);
static bool dspload_wait_loaded(struct hda_codec *codec)
{
- int retry = 100;
+ unsigned long timeout = jiffies + msecs_to_jiffies(2000);
do {
- msleep(20);
if (dspload_is_loaded(codec)) {
pr_info("ca0132 DOWNLOAD OK :-) DSP IS RUNNING.\n");
return true;
}
- } while (--retry);
+ msleep(20);
+ } while (time_before(jiffies, timeout));
pr_err("ca0132 DOWNLOAD FAILED!!! DSP IS NOT RUNNING.\n");
return false;