Hi Dmitry, On Tue, 2016-03-15 at 21:14 +0300, Dmitry Osipenko wrote: > Hello Andrew, > > 14.03.2016 07:13, Andrew Jeffery пишет: > > Implement basic ASPEED timer functionality for the AST2400 SoC[1]: Up to > > 8 timers can independently be configured, enabled, reset and disabled. > > Some hardware features are not implemented, namely clock value matching > > and pulse generation, but the implementation is enough to boot the Linux > > kernel configured with aspeed_defconfig. > > > > [snip] > > > +static void aspeed_timer_set_value(AspeedTimerCtrlState *s, int timer, int > > reg, > > + uint32_t value) > > +{ > > + AspeedTimer *t; > > + > > + g_assert(timer >= 0 && timer < ASPEED_TIMER_NR_TIMERS); > > This would never fail, wouldn't it?
You're right, it shouldn't: I put it in as a sanity check and some "active" documentation. I'm happy to remove it if you think just adds noise. > > [snip] > > > +static void aspeed_timer_write(void *opaque, hwaddr offset, uint64_t value, > > + unsigned size) > > +{ > > + const uint32_t tv = (uint32_t)(value & 0xFFFFFFFF); > > + const int reg = (offset & 0xf) / 4; > > + AspeedTimerCtrlState *s = opaque; > > + > > + switch (offset) { > > + /* Control Registers */ > > + case 0x30: > > + aspeed_timer_set_ctrl(s, tv); > > + break; > > + case 0x34: > > + aspeed_timer_set_ctrl2(s, tv); > > + break; > > + /* Timer Registers */ > > + case 0x00 ... 0x2c: > > + aspeed_timer_set_value(s, (offset >> TIMER_NR_REGS), reg, tv); > > + break; > > + case 0x40 ... 0x8c: > > + aspeed_timer_set_value(s, (offset >> TIMER_NR_REGS) - 1, reg, tv); > > + break; > > > [snip] > > > +static void aspeed_init_one_timer(AspeedTimerCtrlState *s, uint8_t id) > > +{ > > + QEMUBH *bh; > > + AspeedTimer *t = &s->timers[id]; > > + > > + t->id = id; > > + bh = qemu_bh_new(aspeed_timer_expire, t); > > + assert(bh); > > + t->timer = ptimer_init(bh); > > + assert(t->timer); > > +} > > I'm wondering why do you need those asserts, it's very unlikely that this > code > would fail. Have you had any weird issues with it? No, no weird issues - thanks for pointing them out as I'll remove them: I put them in when I started developing the series, before understanding that either call should already have aborted if the allocations failed. Thanks for taking a look at the patch! Andrew
signature.asc
Description: This is a digitally signed message part