]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
ARM: imx: romapi: Fix signed integer bitwise ops misuse
authorMarek Vasut <marex@denx.de>
Sun, 2 Jul 2023 01:03:51 +0000 (03:03 +0200)
committerStefano Babic <sbabic@denx.de>
Thu, 13 Jul 2023 09:29:40 +0000 (11:29 +0200)
Bitwise operations on signed integers are not defined,
replace them with per-call checks.

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Fabio Estevam <festevam@denx.de>
Reviewed-by: Heiko Schocher <hs@denx.de>
arch/arm/mach-imx/spl_imx_romapi.c

index 9164045115f1c54d3808391d046ccd98ad3bcd2d..4af41699678cd8a520f25689ad070888f844c75d 100644 (file)
@@ -76,13 +76,16 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,
        u32 image_offset;
 
        ret = rom_api_query_boot_infor(QUERY_IVT_OFF, &offset);
-       ret |= rom_api_query_boot_infor(QUERY_PAGE_SZ, &pagesize);
-       ret |= rom_api_query_boot_infor(QUERY_IMG_OFF, &image_offset);
+       if (ret != ROM_API_OKAY)
+               goto err;
 
-       if (ret != ROM_API_OKAY) {
-               puts("ROMAPI: Failure query boot infor pagesize/offset\n");
-               return -1;
-       }
+       ret = rom_api_query_boot_infor(QUERY_PAGE_SZ, &pagesize);
+       if (ret != ROM_API_OKAY)
+               goto err;
+
+       ret = rom_api_query_boot_infor(QUERY_IMG_OFF, &image_offset);
+       if (ret != ROM_API_OKAY)
+               goto err;
 
        header = (struct legacy_img_hdr *)(CONFIG_SPL_IMX_ROMAPI_LOADADDR);
 
@@ -124,6 +127,10 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,
        }
 
        return 0;
+
+err:
+       puts("ROMAPI: Failure query boot infor pagesize/offset\n");
+       return -1;
 }
 
 static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
@@ -344,12 +351,12 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,
        u32 boot, bstage;
 
        ret = rom_api_query_boot_infor(QUERY_BT_DEV, &boot);
-       ret |= rom_api_query_boot_infor(QUERY_BT_STAGE, &bstage);
+       if (ret != ROM_API_OKAY)
+               goto err;
 
-       if (ret != ROM_API_OKAY) {
-               puts("ROMAPI: failure at query_boot_info\n");
-               return -1;
-       }
+       ret = rom_api_query_boot_infor(QUERY_BT_STAGE, &bstage);
+       if (ret != ROM_API_OKAY)
+               goto err;
 
        printf("Boot Stage: ");
 
@@ -374,4 +381,7 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,
                return spl_romapi_load_image_stream(spl_image, bootdev);
 
        return spl_romapi_load_image_seekable(spl_image, bootdev, boot);
+err:
+       puts("ROMAPI: failure at query_boot_info\n");
+       return -1;
 }