X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Fhardware%2Fzeroplus-logic-cube%2Fprotocol.c;h=37fcbdcc2eb04d09d3c15a8f4f18736fcef8fca0;hb=076d59b7e62e9cef40f2a9edd63b42c99f442b4f;hp=bc517c35acbf526d9c513d11fb50dd9e15417e8a;hpb=fd86380b48f1abff31f523e33c7c12280be1c1f7;p=libsigrok.git diff --git a/src/hardware/zeroplus-logic-cube/protocol.c b/src/hardware/zeroplus-logic-cube/protocol.c index bc517c35..37fcbdcc 100644 --- a/src/hardware/zeroplus-logic-cube/protocol.c +++ b/src/hardware/zeroplus-logic-cube/protocol.c @@ -21,14 +21,13 @@ #include #include "protocol.h" -SR_PRIV unsigned int get_memory_size(int type) +SR_PRIV size_t get_memory_size(int type) { if (type == MEMORY_SIZE_8K) return (8 * 1024); - else if (type <= MEMORY_SIZE_8M) + if (type <= MEMORY_SIZE_8M) return (32 * 1024) << type; - else - return 0; + return 0; } static int clz(unsigned int x) @@ -59,6 +58,8 @@ static int clz(unsigned int x) SR_PRIV int set_limit_samples(struct dev_context *devc, uint64_t samples) { + size_t mem_kb; + if (samples > devc->max_sample_depth) samples = devc->max_sample_depth; @@ -71,8 +72,8 @@ SR_PRIV int set_limit_samples(struct dev_context *devc, uint64_t samples) else devc->memory_size = 19 - clz(samples - 1); - sr_info("Setting memory size to %dK.", - get_memory_size(devc->memory_size) / 1024); + mem_kb = get_memory_size(devc->memory_size) / 1024; + sr_info("Setting memory size to %zuK.", mem_kb); analyzer_set_memory_size(devc->memory_size);