diff mbox series

[v42,21/98] hw/sd/sdcard: Duplicate READ_SINGLE_BLOCK / READ_MULTIPLE_BLOCK cases

Message ID 20240628070216.92609-22-philmd@linaro.org
State New
Headers show
Series hw/sd/sdcard: Add eMMC support | expand

Commit Message

Philippe Mathieu-Daudé June 28, 2024, 7 a.m. UTC
In order to modify the READ_SINGLE_BLOCK case in the
next commit, duplicate it first.

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

Comments

Cédric Le Goater June 28, 2024, 7:46 a.m. UTC | #1
On 6/28/24 9:00 AM, Philippe Mathieu-Daudé wrote:
> In order to modify the READ_SINGLE_BLOCK case in the
> next commit, duplicate it first.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>


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

Thanks,

C.


> ---
>   hw/sd/sd.c | 18 ++++++++++++++++++
>   1 file changed, 18 insertions(+)
> 
> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> index 8201f3245c..dfcb213aa9 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -1398,6 +1398,24 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
>           break;
>   
>       case 17:  /* CMD17:  READ_SINGLE_BLOCK */
> +        addr = sd_req_get_address(sd, req);
> +        switch (sd->state) {
> +        case sd_transfer_state:
> +
> +            if (!address_in_range(sd, "READ_SINGLE_BLOCK", addr, sd->blk_len)) {
> +                return sd_r1;
> +            }
> +
> +            sd->state = sd_sendingdata_state;
> +            sd->data_start = addr;
> +            sd->data_offset = 0;
> +            return sd_r1;
> +
> +        default:
> +            break;
> +        }
> +        break;
> +
>       case 18:  /* CMD18:  READ_MULTIPLE_BLOCK */
>           addr = sd_req_get_address(sd, req);
>           switch (sd->state) {
diff mbox series

Patch

diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 8201f3245c..dfcb213aa9 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1398,6 +1398,24 @@  static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req)
         break;
 
     case 17:  /* CMD17:  READ_SINGLE_BLOCK */
+        addr = sd_req_get_address(sd, req);
+        switch (sd->state) {
+        case sd_transfer_state:
+
+            if (!address_in_range(sd, "READ_SINGLE_BLOCK", addr, sd->blk_len)) {
+                return sd_r1;
+            }
+
+            sd->state = sd_sendingdata_state;
+            sd->data_start = addr;
+            sd->data_offset = 0;
+            return sd_r1;
+
+        default:
+            break;
+        }
+        break;
+
     case 18:  /* CMD18:  READ_MULTIPLE_BLOCK */
         addr = sd_req_get_address(sd, req);
         switch (sd->state) {