diff mbox series

[1/2] hw/arm/gumstix: Simplify since the machines are little-endian only

Message ID 20200223231044.8003-2-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series hw/arm/gumstix: Trivial cleanups | expand

Commit Message

Philippe Mathieu-Daudé Feb. 23, 2020, 11:10 p.m. UTC
From: Philippe Mathieu-Daudé <f4bug@amsat.org>

As the Connex and Verdex machines only boot in little-endian,
we can simplify the code.

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 hw/arm/gumstix.c | 19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

Comments

Peter Maydell Feb. 25, 2020, 11:12 a.m. UTC | #1
On Sun, 23 Feb 2020 at 23:10, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
>
> As the Connex and Verdex machines only boot in little-endian,
> we can simplify the code.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---

>  static void gumstix_machine_init(void)
>  {
> +    if (target_words_bigendian()) {
> +        return;
> +    }

I don't think we really need to do this, do we? We don't
in any of the other arm boards that just assume little-endian.
I think TARGET_WORDS_BIGENDIAN will only be true on Arm for
the BE linux-user targets, never for softmmu.

Also, there's a warning comment in the header file for
the declaration of target_words_bigendian() that says
you probably don't want to use it...

If you drop this, then otherwise
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM
Philippe Mathieu-Daudé Feb. 25, 2020, 11:16 a.m. UTC | #2
On 2/25/20 12:12 PM, Peter Maydell wrote:
> On Sun, 23 Feb 2020 at 23:10, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>>
>> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
>>
>> As the Connex and Verdex machines only boot in little-endian,
>> we can simplify the code.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> ---
> 
>>   static void gumstix_machine_init(void)
>>   {
>> +    if (target_words_bigendian()) {
>> +        return;
>> +    }
> 
> I don't think we really need to do this, do we? We don't
> in any of the other arm boards that just assume little-endian.
> I think TARGET_WORDS_BIGENDIAN will only be true on Arm for
> the BE linux-user targets, never for softmmu.
> 
> Also, there's a warning comment in the header file for
> the declaration of target_words_bigendian() that says
> you probably don't want to use it...

Yes you (and the comment) are right, we should not use this call in 
target-specific code.

> 
> If you drop this, then otherwise
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

Thanks!

> 
> thanks
> -- PMM
>
diff mbox series

Patch

diff --git a/hw/arm/gumstix.c b/hw/arm/gumstix.c
index f26a0e8010..94904d717b 100644
--- a/hw/arm/gumstix.c
+++ b/hw/arm/gumstix.c
@@ -51,7 +51,6 @@  static void connex_init(MachineState *machine)
 {
     PXA2xxState *cpu;
     DriveInfo *dinfo;
-    int be;
     MemoryRegion *address_space_mem = get_system_memory();
 
     uint32_t connex_rom = 0x01000000;
@@ -66,14 +65,9 @@  static void connex_init(MachineState *machine)
         exit(1);
     }
 
-#ifdef TARGET_WORDS_BIGENDIAN
-    be = 1;
-#else
-    be = 0;
-#endif
     if (!pflash_cfi01_register(0x00000000, "connext.rom", connex_rom,
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                               sector_len, 2, 0, 0, 0, 0, be)) {
+                               sector_len, 2, 0, 0, 0, 0, 0)) {
         error_report("Error registering flash memory");
         exit(1);
     }
@@ -87,7 +81,6 @@  static void verdex_init(MachineState *machine)
 {
     PXA2xxState *cpu;
     DriveInfo *dinfo;
-    int be;
     MemoryRegion *address_space_mem = get_system_memory();
 
     uint32_t verdex_rom = 0x02000000;
@@ -102,14 +95,9 @@  static void verdex_init(MachineState *machine)
         exit(1);
     }
 
-#ifdef TARGET_WORDS_BIGENDIAN
-    be = 1;
-#else
-    be = 0;
-#endif
     if (!pflash_cfi01_register(0x00000000, "verdex.rom", verdex_rom,
                                dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
-                               sector_len, 2, 0, 0, 0, 0, be)) {
+                               sector_len, 2, 0, 0, 0, 0, 0)) {
         error_report("Error registering flash memory");
         exit(1);
     }
@@ -152,6 +140,9 @@  static const TypeInfo verdex_type = {
 
 static void gumstix_machine_init(void)
 {
+    if (target_words_bigendian()) {
+        return;
+    }
     type_register_static(&connex_type);
     type_register_static(&verdex_type);
 }