[PATCH qemu] hw/timer: Add clock value matching support to aspeed_timer

Joel Stanley joel at jms.id.au
Wed May 25 12:53:49 AEST 2016


On Wed, May 25, 2016 at 11:43 AM, Andrew Jeffery <andrew at aj.id.au> wrote:
>> > +    now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
>> > +    for (i = 0; i < ARRAY_SIZE(seq); i++) {
>> > +        next = calculate_time(t, seq[i]);
>> > +        if (now < next) {
>> > +            return next;
>> > +        }
>> > +    }
>> > +
>> > +    {
>> > +        uint64_t reload_ns;
>> > +
>> > +        reload_ns = (uint64_t) floor(t->reload * calculate_period(t));
>> > +        t->start = now - ((now - t->start) % reload_ns);
>> > +    }
>> Why is this scoped like this?
>
> Because reload_ns wasn't relevant for the loop above, so to make it's
> useful lifetime explicit I scoped it to where I needed it.

Yep. It looks a bit unusual though. Is this a coding style that Qemu uses?

Cheers,

Joel


More information about the openbmc mailing list