On Thu, 28 Jan 2021 at 14:32, Philippe Mathieu-Daudé <f4...@amsat.org> wrote:
> Oh I totally missed that :S
>
> Bin, I'd correct this as:
>
> - extract imx_spi_soft_reset(IMXSPIState *s) from imx_spi_reset()
> - zero-initialize CONREG in imx_spi_reset().
>
> static void imx_spi_soft_reset(IMXSPIState *s)
> {
>  ...
> }
>
> static void imx_spi_reset(DeviceState *dev)
> {
>     IMXSPIState *s = IMX_SPI(dev);
>
>     s->regs[ECSPI_CONREG] = 0;
>     imx_spi_soft_reset(s);
> }
>
> What do you think?

That doesn't give you anywhere to put the imx_spi_update_irq()
call, which must happen only on soft reset and not on DeviceState
reset. You could do one of:
 * have a 'common reset' function that does most of this,
   plus an imx_spi_reset which clears CONREG and calls
   common reset and an imx_spi_soft_reset which calls
   common reset and imx_spi_update_irq()
 * have imx_spi_soft_reset save the old CONREG in a local
   variable before calling imx_spi_reset and then restore it
   to s->regs

thanks
-- PMM

Reply via email to