From patchwork Mon Jun 24 13:14:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 807023 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp1876919wrt; Mon, 24 Jun 2024 06:15:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVy3p3e8SIEWsMhYWQTkdx/GkECZzK9jydzKK8xtUj0lehEXjEoR1KDVyLtlo3jfPu7mygsAZEzOiKLr6v2CFz2 X-Google-Smtp-Source: AGHT+IE+0V+Q9Go1Fd+x0YfFHnoGlWwA5eIgcBdSijOjfVFU5arrMr6y/M+jXJIykRA0sxPp0509 X-Received: by 2002:a05:6808:f8e:b0:3d5:2bb7:867 with SMTP id 5614622812f47-3d54596af33mr5459485b6e.17.1719234932205; Mon, 24 Jun 2024 06:15:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719234932; cv=none; d=google.com; s=arc-20160816; b=OEJYTHd6BzRH8sO54X6QnNXGd7riWfBGAAh/OA9M7cS+2zdOgxXDi6k6AauHAYItq2 thEgYb5nbgASxTc/DGUfQXAE02uGjSJzmDLz3Cso8yZlWR1uKLuCJG4JYs0G/Ei399Nb FEm12oqH8zHbyZk4grli/wAwBOoSjg+xAyDeaXRrQWMVeWH93AHv0hAHR7Zix4sUCyhA nWwOElYkVbf/m5uLW9iNUClJvbfAVV7O7kQnq9uD9zofTru8NdcNAXTFRfAgyPVAh82Z kCwKVcEEgvfIsNPh7Tj2ZeQyPbJybb7546Rm3iblkhW44TBRbeh6XAQs+TBVYIySWEgm j0jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9AZo3Cd3b6HBjlscPz+JzsDxsvHUlQzRA2cgC5como0=; fh=/TyiCVzPJVYkT4NtrOYZRXAcrkaiLXA/rwqp4QqIc5M=; b=QEChop7NtP/RMPlC3Zvh4xmyrmeXiwzO1k2Cl1M7Tg/FhNQKk2VO8ST2GnOwbtRCWA PGMrTkg1O5kHMY6AJ92rA/S1bKe4wVj2jnMYml85YacCt6A8rLrLAMnTsRJH7y8PIfym o8064wLJE1SWCxhTYUt/1oRd0L9GvRmhTni5kQBkvcEpymysLMMnD2i5rwVJDT7yj/Ph 88EIlTPkILOo7A9Ux0PiQHcpupxgnmJRcmNMddcAUlhREk+/jVDTBuGamrT+H34tZr49 CCTsK4NxaeDM8fDaTe9k8dGKRsNNwpKcAk7yricXKPxE4sk41dc5KoELxyZM/iddEr1a QBNQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L1OZqC93; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-444c2b72274si81926531cf.191.2024.06.24.06.15.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2024 06:15:32 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L1OZqC93; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sLjXK-0001da-Kl; Mon, 24 Jun 2024 09:15:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sLjXJ-0001cR-8K for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:09 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sLjXH-0005CD-GL for qemu-devel@nongnu.org; Mon, 24 Jun 2024 09:15:08 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-362b32fbb3bso2930121f8f.2 for ; Mon, 24 Jun 2024 06:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719234905; x=1719839705; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9AZo3Cd3b6HBjlscPz+JzsDxsvHUlQzRA2cgC5como0=; b=L1OZqC937Pj0hY6ez4EYhB7/WxrMeLvrkxZXm9rXtzWMmnpKWFVXmE5Z8FmWS0Hsal 7QB+E/Cax4imOGqhTVOzT3+e5gkwFpRDQ3gCbsJBPehkD9Tp+kHSa0J6Zzcg5SYX1TMT 2MMFfMwZ1YCr1U83fGfASOIjc01xWFhkt/c/JyhDZrbCc5vId2TXVMpyxQ7QXmpYTk4K cLm0s4fE8j0kRI7WOTtnzyYuItOp+WzqAxuZyPVQfHZbVZNWH1pH70lEBts25H51nkHa WpnpoPLKGQptaGHM/EHQXaeuvh6kyaoHpOsiKKvjZUYP2VDfSbOi3gzET4AvZHijnTvY aUUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719234905; x=1719839705; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9AZo3Cd3b6HBjlscPz+JzsDxsvHUlQzRA2cgC5como0=; b=KxAja1OvsjaWuXI8EU6v+tNEn2hPuTZ8YwEgCBHc1bCx7L0s+I1J/v9BErRKRK+paV H3+xWbrI98HFR6Ikcn71mp+iHG2itJJTpiSbj+0JtAwIYP1nqgRsIz9ZGpmGpB0vPLQl 9PG/MvL3g3kJcUO5HxK0kPIeMQ0SaPBV4cK/2E2GqnP6gEbX1N/hj7ZMK6YrLjL4nlM4 jbevSkCQeOUFLOpL+dSs2AHkom9Z47f3L+QhpU96IlP9KAHISG8tm0VW7yEGffd+gzVn kMIxFbWVDjLbkvhrC8vKcK3dhHQP1yJbQcRn7LYESdJbg1mXDeJPI/dh+q5vIIK+iWr5 a4sw== X-Gm-Message-State: AOJu0YxBDoAy9fQPQDBB8qQcrtCKWdV3GOAw+G/K9ZwSHPa5lGr4oX2B SV/he2Mz0FEPnmBQ4pYCZExAR53pBuovSBv5ixSZjvW1R8Zb3U3UiI0tXrZxM3r+6PWp0hHJc+W p X-Received: by 2002:a05:6000:154d:b0:366:e7b5:3b49 with SMTP id ffacd0b85a97d-366e7b540a8mr4645416f8f.54.1719234905753; Mon, 24 Jun 2024 06:15:05 -0700 (PDT) Received: from m1x-phil.lan (bd137-h02-176-184-46-22.dsl.sta.abo.bbox.fr. [176.184.46.22]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-366387cf44asm9978938f8f.26.2024.06.24.06.15.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 24 Jun 2024 06:15:05 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , =?utf-8?q?C?= =?utf-8?q?=C3=A9dric_Le_Goater?= Subject: [PULL 04/19] hw/sd/sdcard: Rewrite sd_cmd_ALL_SEND_CID using switch case (CMD2) Date: Mon, 24 Jun 2024 15:14:25 +0200 Message-ID: <20240624131440.81111-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240624131440.81111-1-philmd@linaro.org> References: <20240624131440.81111-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é Reviewed-by: Cédric Le Goater Tested-by: Cédric Le Goater Message-Id: <20240621080554.18986-3-philmd@linaro.org> --- hw/sd/sd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index ba7f165cb5..46388a140a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -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)