[PATCH 04/23] hw/sd/sdcard: Use HWBLOCK_SHIFT definition instead of magic values

Philippe Mathieu-Daudé posted 23 patches 6 months, 1 week ago
There is a newer version of this series
[PATCH 04/23] hw/sd/sdcard: Use HWBLOCK_SHIFT definition instead of magic values
Posted by Philippe Mathieu-Daudé 6 months, 1 week ago
From: Philippe Mathieu-Daudé <f4bug@amsat.org>

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/sd/sd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 331cef5779..c528c30bcf 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -596,7 +596,7 @@ static void sd_reset(DeviceState *dev)
     } else {
         sect = 0;
     }
-    size = sect << 9;
+    size = sect << HWBLOCK_SHIFT;
 
     sect = sd_addr_to_wpnum(size) + 1;
 
@@ -822,8 +822,8 @@ static void sd_erase(SDState *sd)
 
     if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) {
         /* High capacity memory card: erase units are 512 byte blocks */
-        erase_start *= 512;
-        erase_end *= 512;
+        erase_start <<= HWBLOCK_SHIFT;
+        erase_end <<= HWBLOCK_SHIFT;
         sdsc = false;
     }
 
-- 
2.41.0


Re: [PATCH 04/23] hw/sd/sdcard: Use HWBLOCK_SHIFT definition instead of magic values
Posted by Cédric Le Goater 6 months, 1 week ago
On 6/21/24 10:05 AM, Philippe Mathieu-Daudé wrote:
> From: Philippe Mathieu-Daudé <f4bug@amsat.org>
> 
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>


Reviewed-by: Cédric Le Goater <clg@redhat.com>

Thanks,

C.


> ---
>   hw/sd/sd.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> index 331cef5779..c528c30bcf 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -596,7 +596,7 @@ static void sd_reset(DeviceState *dev)
>       } else {
>           sect = 0;
>       }
> -    size = sect << 9;
> +    size = sect << HWBLOCK_SHIFT;
>   
>       sect = sd_addr_to_wpnum(size) + 1;
>   
> @@ -822,8 +822,8 @@ static void sd_erase(SDState *sd)
>   
>       if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) {
>           /* High capacity memory card: erase units are 512 byte blocks */
> -        erase_start *= 512;
> -        erase_end *= 512;
> +        erase_start <<= HWBLOCK_SHIFT;
> +        erase_end <<= HWBLOCK_SHIFT;
>           sdsc = false;
>       }
>