Skip to contentSkip to conversation

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

PATCH Applied Philippe Mathieu-Daudé 3 participants 4 messages Jan 4, 2019 – Jan 8, 2019 Arm STM32

lore
Share & tools
lore
#0 lore raw

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

When the device is disable, the internal circuitry keep the data register loaded and doesn't update it.

---
 hw/char/stm32f2xx_usart.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/char/stm32f2xx_usart.c +1 -2
index f3363a2952..10392c70e2 100644
@@ -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) {
Signature · 1 line
2.17.2
#1 lore raw
Quoted 1 line · Philippe Mathieu-Daudé

When the device is disable, the internal circuitry keep the data

"keep" -> "keeps"

Quoted 28 lines

register loaded and doesn't update it.

---
 hw/char/stm32f2xx_usart.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/char/stm32f2xx_usart.c +1 -2
index f3363a2952..10392c70e2 100644
@@ -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) {
Reviewed-by
#2 lore raw
Quoted 9 lines · Philippe Mathieu-Daudé
Quoted 1 line · Philippe Mathieu-Daudé

When the device is disable, the internal circuitry keep the data

"keep" -> "keeps"

Quoted 3 lines

register loaded and doesn't update it.

Alistair

Quoted 26 lines
Quoted 25 lines
---
 hw/char/stm32f2xx_usart.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/char/stm32f2xx_usart.c +1 -2
index f3363a2952..10392c70e2 100644
@@ -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) {
#3 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 30 lines · Philippe Mathieu-Daudé

When the device is disable, the internal circuitry keep the data register loaded and doesn't update it.

---
 hw/char/stm32f2xx_usart.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
hw/char/stm32f2xx_usart.c +1 -3
index f3363a2952..10392c70e2 100644
@@ -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) {
--
Quoted 1 line

2.17.2

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

-- PMM