hw/net/imx_fec: write TGSR and TCSR3 in imx_enet_write()
PATCH v4 1/1 hw/net/imx_fec: write TGSR and TCSR3 in imx_enet_write()
The current code causes clang static code analyzer generate warning:hw/net/imx_fec.c:858:9: warning: Value stored to 'value' is never read
value = value & 0x0000000f;
^ ~~~~~~~~~~~~~~~~~~
hw/net/imx_fec.c:864:9: warning: Value stored to 'value' is never read
value = value & 0x000000fd;
^ ~~~~~~~~~~~~~~~~~~According to the definition of the function, the two “value” assignments
should be written to registers.
---
Cc: Peter Maydell <[email protected]>
Cc: Jason Wang <[email protected]>
Cc: Peter Chubb <[email protected]>
v1->v2:
The register 'ENET_TGSR' write-1-to-clear timer flag. The register 'ENET_TCSRn' 7bit(TF) write-1-to-clear timer flag.
v2->v3:
Optimize code style, based on discussions with Peter.
v3->v4:
Delete reserved bits write zero(Base on Peter's comments).
--- hw/net/imx_fec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
hw/net/imx_fec.c +4 -2
@@ -855,13 +855,15 @@ static void imx_enet_write(IMXFECState *s, uint32_t index, uint32_t value)break ;case ENET_TGSR :/* implement clear timer flag */ - value = value &0x0000000f ; + s->regs[index] &= ~(value &0x0000000f );/* all bits W1C */ break ;case ENET_TCSR0 :case ENET_TCSR1 :case ENET_TCSR2 :case ENET_TCSR3 : - value = value &0x000000fd ; + s->regs[index] &= ~(value &0x00000080 );/* W1C bits */ + s->regs[index] &= ~0x0000007d ;/* writable fields */ + s->regs[index] |= (value &0x0000007d );break ;case ENET_TCCR0 :case ENET_TCCR1 :
Signature · 1 line
2.23.0
Peter Maydell
AppliedQuoted 9 lines · Chen Qun
The current code causes clang static code analyzer generate warning:
hw/net/imx_fec.c:858:9: warning: Value stored to 'value' is never readvalue = value & 0x0000000f; ^ ~~~~~~~~~~~~~~~~~~ hw/net/imx_fec.c:864:9: warning: Value stored to 'value' is never read value = value & 0x000000fd; ^ ~~~~~~~~~~~~~~~~~~
Quoted 5 lines
According to the definition of the function, the two “value” assignments
should be written to registers.Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>
Applied to target-arm.next; thanks for working through the code review process.
-- PMM
Quoted 24 lines
-----Original Message-----
From: Peter Maydell [mailto:[email protected]]
Sent: Friday, March 13, 2020 10:29 PM
To: Chenqun (kuhn) <[email protected]>
Cc: QEMU Developers <[email protected]>; QEMU Trivial <qemu- [email protected]>; Zhanghailiang <[email protected]>; Euler Robot <[email protected]>; Jason Wang <[email protected]>; Peter Chubb <[email protected]>
Subject: Re: [PATCH v4] hw/net/imx_fec: write TGSR and TCSR3 inimx_enet_write()Quoted 12 lines · Chen Qun
The current code causes clang static code analyzer generate warning:
hw/net/imx_fec.c:858:9: warning: Value stored to 'value' is never readvalue = value & 0x0000000f; ^ ~~~~~~~~~~~~~~~~~~ hw/net/imx_fec.c:864:9: warning: Value stored to 'value' is never read value = value & 0x000000fd; ^ ~~~~~~~~~~~~~~~~~~According to the definition of the function, the two “value” assignments should be written to registers.
Quoted 7 lines
Quoted 2 lines
Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>Applied to target-arm.next; thanks for working through the code review process.
Thank you for your detailed review and effective suggestions, too.