hw/sd/sdcard: Rewrite sd_cmd_ALL_SEND_CID using switch case (CMD2)
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Mon, 17 Jun 2024 14:58:29 +0000 (16:58 +0200)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Mon, 24 Jun 2024 08:41:42 +0000 (10:41 +0200)
Keep this handler style in sync with other handlers by
using a switch() case, which might become handy to
handle other states.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Tested-by: Cédric Le Goater <clg@redhat.com>
Message-Id: <20240621080554.18986-3-philmd@linaro.org>

hw/sd/sd.c

index ba7f165cb5586bd72fc1b6d9a998052a6de0c901..46388a140ab89a215c6a415c44fdc784b29d5151 100644 (file)
@@ -1044,13 +1044,13 @@ static sd_rsp_type_t sd_cmd_SEND_OP_CMD(SDState *sd, SDRequest req)
 
 static sd_rsp_type_t sd_cmd_ALL_SEND_CID(SDState *sd, SDRequest req)
 {
-    if (sd->state != sd_ready_state) {
+    switch (sd->state) {
+    case sd_ready_state:
+        sd->state = sd_identification_state;
+        return sd_r2_i;
+    default:
         return sd_invalid_state_for_cmd(sd, req);
     }
-
-    sd->state = sd_identification_state;
-
-    return sd_r2_i;
 }
 
 static sd_rsp_type_t sd_cmd_SEND_RELATIVE_ADDR(SDState *sd, SDRequest req)