|
From: | Dmitry Osipenko |
Subject: | Re: [Qemu-devel] [PATCH v11 6/7] hw/ptimer: Legalize running with delta = load = 0 and abort on period = 0 |
Date: | Sun, 24 Jan 2016 18:02:46 +0300 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
24.01.2016 07:28, Peter Crosthwaite пишет: [snip]
/* Set counter frequency in Hz. */ void ptimer_set_freq(ptimer_state *s, uint32_t freq) { + g_assert(freq != 0); s->delta = ptimer_get_count(s); s->period = 1000000000ll / freq; s->period_frac = (1000000000ll << 32) / freq;
I noticed that this should be g_assert(freq != 0 && freq <= 1000000000), otherwise it possible to make period = 0 for the running timer when setting freq > 1GHz, which doesn't make sense because we can't set period < 1ns.
Or maybe we should clamp period = max(1, period), freq = min(1000000000, freq) to "allow" higher timer freq's?
What do you think? -- Dmitry
[Prev in Thread] | Current Thread | [Next in Thread] |