From: Wolfram Sang Date: Wed, 2 Jan 2019 12:15:18 +0000 (+0100) Subject: ols: simplify calculation of readcount X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=aad0c777088b7a4571272fa168a81ff9a2df05dc;p=libsigrok.git ols: simplify calculation of readcount Somewhen we probably want DIV_ROUND_UP from the Kernel. Signed-off-by: Wolfram Sang --- diff --git a/src/hardware/openbench-logic-sniffer/api.c b/src/hardware/openbench-logic-sniffer/api.c index 1aa7844e..8ff1456d 100644 --- a/src/hardware/openbench-logic-sniffer/api.c +++ b/src/hardware/openbench-logic-sniffer/api.c @@ -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) {