From: Marek Vasut Date: Sun, 20 Apr 2014 18:50:10 +0000 (+0200) Subject: asix-sigma: Localize variables X-Git-Tag: libsigrok-0.3.0~39 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=462fe786641df67e99d67f0f7031e7ca76430981;p=libsigrok.git asix-sigma: Localize variables The trigger position, stop position and chunk in which the trigger happened are no longer needed in the global scope. Make those variables local to the download_capture() function. Signed-off-by: Marek Vasut --- diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index 734eccf2..c44bae7a 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -1075,7 +1075,8 @@ static int download_capture(struct sr_dev_inst *sdi) const int chunks_per_read = 32; unsigned char buf[chunks_per_read * CHUNK_SIZE]; int bufsz, i, numchunks, newchunks; - + uint32_t stoppos, triggerpos; + int triggerchunk, chunks_downloaded; struct sr_datafeed_packet packet; uint8_t modestatus; @@ -1088,25 +1089,25 @@ static int download_capture(struct sr_dev_inst *sdi) sigma_set_register(WRITE_MODE, 0x02, devc); /* Get the current position. */ - sigma_read_pos(&devc->state.stoppos, &devc->state.triggerpos, devc); + sigma_read_pos(&stoppos, &triggerpos, devc); /* Check if trigger has fired. */ modestatus = sigma_get_register(READ_MODE, devc); if (modestatus & 0x20) - devc->state.triggerchunk = devc->state.triggerpos / 512; + triggerchunk = triggerpos / 512; else - devc->state.triggerchunk = -1; + triggerchunk = -1; - devc->state.chunks_downloaded = 0; - numchunks = (devc->state.stoppos + 511) / 512; - newchunks = MIN(chunks_per_read, numchunks - devc->state.chunks_downloaded); + chunks_downloaded = 0; + numchunks = (stoppos + 511) / 512; + newchunks = MIN(chunks_per_read, numchunks - chunks_downloaded); - bufsz = sigma_read_dram(devc->state.chunks_downloaded, newchunks, buf, devc); + bufsz = sigma_read_dram(chunks_downloaded, newchunks, buf, devc); /* TODO: Check bufsz. For now, just avoid compiler warnings. */ (void)bufsz; /* Find first ts. */ - if (devc->state.chunks_downloaded == 0) { + if (chunks_downloaded == 0) { devc->state.lastts = RL16(buf) - 1; devc->state.lastsample = 0; } @@ -1116,16 +1117,16 @@ static int download_capture(struct sr_dev_inst *sdi) int limit_chunk = 0; /* The last chunk may potentially be only in part. */ - if (devc->state.chunks_downloaded == numchunks - 1) { + if (chunks_downloaded == numchunks - 1) { /* Find the last valid timestamp */ - limit_chunk = devc->state.stoppos % 512 + devc->state.lastts; + limit_chunk = stoppos % 512 + devc->state.lastts; } - if (devc->state.chunks_downloaded + i == devc->state.triggerchunk) + if (chunks_downloaded + i == triggerchunk) decode_chunk_ts(buf + (i * CHUNK_SIZE), &devc->state.lastts, &devc->state.lastsample, - devc->state.triggerpos & 0x1ff, + triggerpos & 0x1ff, limit_chunk, sdi); else decode_chunk_ts(buf + (i * CHUNK_SIZE), @@ -1133,7 +1134,7 @@ static int download_capture(struct sr_dev_inst *sdi) &devc->state.lastsample, -1, limit_chunk, sdi); - ++devc->state.chunks_downloaded; + ++chunks_downloaded; } /* All done. */ diff --git a/hardware/asix-sigma/asix-sigma.h b/hardware/asix-sigma/asix-sigma.h index b8362e0d..19330643 100644 --- a/hardware/asix-sigma/asix-sigma.h +++ b/hardware/asix-sigma/asix-sigma.h @@ -167,12 +167,8 @@ struct sigma_state { SIGMA_DOWNLOAD, } state; - uint32_t stoppos, triggerpos; uint16_t lastts; uint16_t lastsample; - - int triggerchunk; - int chunks_downloaded; }; /* Private, per-device-instance driver context. */