]> sigrok.org Git - libsigrok.git/commitdiff
ols: simplify calculation of readcount
authorWolfram Sang <redacted>
Wed, 2 Jan 2019 12:15:18 +0000 (13:15 +0100)
committerUwe Hermann <redacted>
Sun, 13 Jan 2019 19:07:27 +0000 (20:07 +0100)
Somewhen we probably want DIV_ROUND_UP from the Kernel.

Signed-off-by: Wolfram Sang <redacted>
src/hardware/openbench-logic-sniffer/api.c

index 1aa7844e80d9c4f34e614f647a462c6fff5659aa..8ff1456daad47e8896fb6aaec6a1b8b387b59d94 100644 (file)
@@ -417,14 +417,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
 
        /*
         * Limit readcount to prevent reading past the end of the hardware
-        * buffer.
+        * buffer. Rather read too many samples than too few.
         */
        samplecount = MIN(devc->max_samples / num_ols_changrp, devc->limit_samples);
-       readcount = samplecount / 4;
-
-       /* Rather read too many samples than too few. */
-       if (samplecount % 4 != 0)
-               readcount++;
+       readcount = (samplecount + 3) / 4;
 
        /* Basic triggers. */
        if (ols_convert_trigger(sdi) != SR_OK) {