On Mon, Feb 5, 2018 at 10:44 AM, Alistair Francis <alistair.fran...@xilinx.com> wrote: > Ensure that the post write hook is called during reset. This allows us > to rely on the post write functions instead of having to call them from > the reset() function. > > Signed-off-by: Alistair Francis <alistair.fran...@xilinx.com> > Reviewed-by: Philippe Mathieu-Daudé <f4...@amsat.org>
Ping! > --- > > V2: > - Update the header documentation > > include/hw/register.h | 6 +++--- > hw/core/register.c | 8 ++++++++ > 2 files changed, 11 insertions(+), 3 deletions(-) > > diff --git a/include/hw/register.h b/include/hw/register.h > index de2414e6b4..5796584588 100644 > --- a/include/hw/register.h > +++ b/include/hw/register.h > @@ -34,7 +34,7 @@ typedef struct RegisterInfoArray RegisterInfoArray; > * immediately before the actual write. The returned value is what is > written, > * giving the handler a chance to modify the written value. > * @post_write: Post write callback. Passed the written value. Most write > side > - * effects should be implemented here. > + * effects should be implemented here. This is called during device reset. > * > * @post_read: Post read callback. Passes the value that is about to be > returned > * for a read. The return value from this function is what is ultimately > read, > @@ -135,8 +135,8 @@ uint64_t register_read(RegisterInfo *reg, uint64_t re, > const char* prefix, > bool debug); > > /** > - * reset a register > - * @reg: register to reset > + * Resets a register. This will also call the post_write hook if it exists. > + * @reg: The register to reset. > */ > > void register_reset(RegisterInfo *reg); > diff --git a/hw/core/register.c b/hw/core/register.c > index 900294b9c4..0741a1af32 100644 > --- a/hw/core/register.c > +++ b/hw/core/register.c > @@ -159,13 +159,21 @@ uint64_t register_read(RegisterInfo *reg, uint64_t re, > const char* prefix, > > void register_reset(RegisterInfo *reg) > { > + const RegisterAccessInfo *ac; > + > g_assert(reg); > > if (!reg->data || !reg->access) { > return; > } > > + ac = reg->access; > + > register_write_val(reg, reg->access->reset); > + > + if (ac->post_write) { > + ac->post_write(reg, reg->access->reset); > + } > } > > void register_init(RegisterInfo *reg) > -- > 2.14.1 >