diff mbox series

hw/char/stm32f2xx_usart: Do not update data register when device is disabled

Message ID 20190104182057.8778-1-philmd@redhat.com
State New
Headers show
Series hw/char/stm32f2xx_usart: Do not update data register when device is disabled | expand

Commit Message

Philippe Mathieu-Daudé Jan. 4, 2019, 6:20 p.m. UTC
When the device is disable, the internal circuitry keep the data
register loaded and doesn't update it.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/char/stm32f2xx_usart.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Philippe Mathieu-Daudé Jan. 4, 2019, 6:31 p.m. UTC | #1
On 1/4/19 7:20 PM, Philippe Mathieu-Daudé wrote:
> When the device is disable, the internal circuitry keep the data

"keep" -> "keeps"

> register loaded and doesn't update it.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/char/stm32f2xx_usart.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c
> index f3363a2952..10392c70e2 100644
> --- a/hw/char/stm32f2xx_usart.c
> +++ b/hw/char/stm32f2xx_usart.c
> @@ -53,14 +53,13 @@ static void stm32f2xx_usart_receive(void *opaque, const uint8_t *buf, int size)
>  {
>      STM32F2XXUsartState *s = opaque;
>  
> -    s->usart_dr = *buf;
> -
>      if (!(s->usart_cr1 & USART_CR1_UE && s->usart_cr1 & USART_CR1_RE)) {
>          /* USART not enabled - drop the chars */
>          DB_PRINT("Dropping the chars\n");
>          return;
>      }
>  
> +    s->usart_dr = *buf;
>      s->usart_sr |= USART_SR_RXNE;
>  
>      if (s->usart_cr1 & USART_CR1_RXNEIE) {
>
Alistair Francis Jan. 4, 2019, 7:47 p.m. UTC | #2
On Fri, Jan 4, 2019 at 10:31 AM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> On 1/4/19 7:20 PM, Philippe Mathieu-Daudé wrote:
> > When the device is disable, the internal circuitry keep the data
>
> "keep" -> "keeps"
>
> > register loaded and doesn't update it.
> >
> > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> > ---
> >  hw/char/stm32f2xx_usart.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c
> > index f3363a2952..10392c70e2 100644
> > --- a/hw/char/stm32f2xx_usart.c
> > +++ b/hw/char/stm32f2xx_usart.c
> > @@ -53,14 +53,13 @@ static void stm32f2xx_usart_receive(void *opaque, const uint8_t *buf, int size)
> >  {
> >      STM32F2XXUsartState *s = opaque;
> >
> > -    s->usart_dr = *buf;
> > -
> >      if (!(s->usart_cr1 & USART_CR1_UE && s->usart_cr1 & USART_CR1_RE)) {
> >          /* USART not enabled - drop the chars */
> >          DB_PRINT("Dropping the chars\n");
> >          return;
> >      }
> >
> > +    s->usart_dr = *buf;
> >      s->usart_sr |= USART_SR_RXNE;
> >
> >      if (s->usart_cr1 & USART_CR1_RXNEIE) {
> >
>
Peter Maydell Jan. 8, 2019, 11:53 a.m. UTC | #3
On Fri, 4 Jan 2019 at 18:21, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> When the device is disable, the internal circuitry keep the data
> register loaded and doesn't update it.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/char/stm32f2xx_usart.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c
> index f3363a2952..10392c70e2 100644
> --- a/hw/char/stm32f2xx_usart.c
> +++ b/hw/char/stm32f2xx_usart.c
> @@ -53,14 +53,13 @@ static void stm32f2xx_usart_receive(void *opaque, const uint8_t *buf, int size)
>  {
>      STM32F2XXUsartState *s = opaque;
>
> -    s->usart_dr = *buf;
> -
>      if (!(s->usart_cr1 & USART_CR1_UE && s->usart_cr1 & USART_CR1_RE)) {
>          /* USART not enabled - drop the chars */
>          DB_PRINT("Dropping the chars\n");
>          return;
>      }
>
> +    s->usart_dr = *buf;
>      s->usart_sr |= USART_SR_RXNE;
>
>      if (s->usart_cr1 & USART_CR1_RXNEIE) {
> --
> 2.17.2




Applied to target-arm.next, thanks (with the commit message typos fixed).

-- PMM
diff mbox series

Patch

diff --git a/hw/char/stm32f2xx_usart.c b/hw/char/stm32f2xx_usart.c
index f3363a2952..10392c70e2 100644
--- a/hw/char/stm32f2xx_usart.c
+++ b/hw/char/stm32f2xx_usart.c
@@ -53,14 +53,13 @@  static void stm32f2xx_usart_receive(void *opaque, const uint8_t *buf, int size)
 {
     STM32F2XXUsartState *s = opaque;
 
-    s->usart_dr = *buf;
-
     if (!(s->usart_cr1 & USART_CR1_UE && s->usart_cr1 & USART_CR1_RE)) {
         /* USART not enabled - drop the chars */
         DB_PRINT("Dropping the chars\n");
         return;
     }
 
+    s->usart_dr = *buf;
     s->usart_sr |= USART_SR_RXNE;
 
     if (s->usart_cr1 & USART_CR1_RXNEIE) {