diff mbox series

[03/13] target/arm/ptw: Use the ld/st_endian_p() API

Message ID 20240930073450.33195-4-philmd@linaro.org (mailing list archive)
State New, archived
Headers show
Series hw: Add ld/st_endian() APIs | expand

Commit Message

Philippe Mathieu-Daudé Sept. 30, 2024, 7:34 a.m. UTC
Refactor to use the recently introduced ld/st_endian_p() API
No logical change intended.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/ptw.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

Comments

Pierrick Bouvier Oct. 1, 2024, 4:46 p.m. UTC | #1
On 9/30/24 00:34, Philippe Mathieu-Daudé wrote:
> Refactor to use the recently introduced ld/st_endian_p() API
> No logical change intended.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/arm/ptw.c | 19 ++++---------------
>   1 file changed, 4 insertions(+), 15 deletions(-)
> 
> diff --git a/target/arm/ptw.c b/target/arm/ptw.c
> index defd6b84de..a1a6b1fec3 100644
> --- a/target/arm/ptw.c
> +++ b/target/arm/ptw.c
> @@ -699,11 +699,7 @@ static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw,
>               data = le64_to_cpu(data);
>           }
>   #else
> -        if (ptw->out_be) {
> -            data = ldq_be_p(host);
> -        } else {
> -            data = ldq_le_p(host);
> -        }
> +        data = ldq_endian_p(ptw->out_be, host);
>   #endif
>       } else {
>           /* Page tables are in MMIO. */
> @@ -860,16 +856,9 @@ static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t old_val,
>       if (!locked) {
>           bql_lock();
>       }
> -    if (ptw->out_be) {
> -        cur_val = ldq_be_p(host);
> -        if (cur_val == old_val) {
> -            stq_be_p(host, new_val);
> -        }
> -    } else {
> -        cur_val = ldq_le_p(host);
> -        if (cur_val == old_val) {
> -            stq_le_p(host, new_val);
> -        }
> +    cur_val = ldq_endian_p(ptw->out_be, host);
> +    if (cur_val == old_val) {
> +        stq_endian_p(ptw->out_be, host, new_val);
>       }
>       if (!locked) {
>           bql_unlock();

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
diff mbox series

Patch

diff --git a/target/arm/ptw.c b/target/arm/ptw.c
index defd6b84de..a1a6b1fec3 100644
--- a/target/arm/ptw.c
+++ b/target/arm/ptw.c
@@ -699,11 +699,7 @@  static uint64_t arm_ldq_ptw(CPUARMState *env, S1Translate *ptw,
             data = le64_to_cpu(data);
         }
 #else
-        if (ptw->out_be) {
-            data = ldq_be_p(host);
-        } else {
-            data = ldq_le_p(host);
-        }
+        data = ldq_endian_p(ptw->out_be, host);
 #endif
     } else {
         /* Page tables are in MMIO. */
@@ -860,16 +856,9 @@  static uint64_t arm_casq_ptw(CPUARMState *env, uint64_t old_val,
     if (!locked) {
         bql_lock();
     }
-    if (ptw->out_be) {
-        cur_val = ldq_be_p(host);
-        if (cur_val == old_val) {
-            stq_be_p(host, new_val);
-        }
-    } else {
-        cur_val = ldq_le_p(host);
-        if (cur_val == old_val) {
-            stq_le_p(host, new_val);
-        }
+    cur_val = ldq_endian_p(ptw->out_be, host);
+    if (cur_val == old_val) {
+        stq_endian_p(ptw->out_be, host, new_val);
     }
     if (!locked) {
         bql_unlock();