From nobody Mon Nov 17 09:50:10 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.128.44 as permitted sender) client-ip=209.85.128.44; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wm1-f44.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.44 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1603710209; cv=none; d=zohomail.com; s=zohoarc; b=K0q+4LbjljAdZiCzPTzTC41XtpkdphZ5RsSNTcJDL6QLxKnzZuc5BiwORtJDBXzTu18Xq35VPICUA16CF19WfIhw9Xvr9u+06cJ2fXxcOEIcT6lpZ8uNPrruiBpSMsLsc5pCfBe/7lpWj8WSyeF8D/SUWWPLLfSUZtc8+gImxLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603710209; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Yet6HVLB8K+LmlUq3G4sMPBL+CDXC+2uR7gzK1ybwmo=; b=l49pVi2lD8dK2RnE8g/H4gl/Pyl9rZSVxR5SvG3C083gY7ig51+N306TzGabw7h6vc5DuHjqTNK37s6mF/RSULTUgtBQZmXnjqGNXjkCB70MFIP3KDbBaGvD0o9fY55D0u1F5l74Pp1fYHKwHKAPnyLJA9AbxsFPC5WLXrjDc2o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.128.44 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) by mx.zohomail.com with SMTPS id 1603710209582185.20866945371938; Mon, 26 Oct 2020 04:03:29 -0700 (PDT) Received: by mail-wm1-f44.google.com with SMTP id l20so4904048wme.0 for ; Mon, 26 Oct 2020 04:03:28 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (237.red-88-18-140.staticip.rima-tde.net. [88.18.140.237]) by smtp.gmail.com with ESMTPSA id d142sm3477530wmd.11.2020.10.26.04.03.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Oct 2020 04:03:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Yet6HVLB8K+LmlUq3G4sMPBL+CDXC+2uR7gzK1ybwmo=; b=UCo+P/KimaEH9WytkmPvQ/gRniaWbuuX5EwVTO78FshBUt9XvuxdcqKUYg2HRl2/HF uujgy62NrA307zdeDZagBpPrb/WBbmK6ejwOmopfjlJxceDfmhznY5D7Z3JCk8g0Smnu JhLVbOk/kmZrBxfpz8OR6d2BsVM3r8NABNpEu/WudgZe9NI7uvPKSQFuP6dkEJzV2pGG sYxzpmWo68kYWQpX7fY4ep45ReiTDtXAClQkBrLYwm+hcrdFgdiWvjWtkUJyoMbIBst+ CVgSTIlAIZcGZX+rez0oJ/N/ZAo7trHBDrT+PNwt5jBUx+yH4JEBaWVqqMxfvNUIp10M mKRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Yet6HVLB8K+LmlUq3G4sMPBL+CDXC+2uR7gzK1ybwmo=; b=gHEOTAsEI4liKdjI7SuuoOmSe5LEQRIL7ilhp2lIunLW9U2Jj4cIpXx7MayMK/M6E3 N1t9CiG3LtEkNTAdRH34hHnrk4upO5b/6wA54iwhKcPfr/A9LtR0iCWJr/zNtoIBPMbI DVDZttf/7GmnKUd7SxdH+rJ6A5BrNcQ7heuJXP+dHGJ5UW3BgmA6vaHyTYxVYqKZpgDg 8t2UzW70qYhe4h4zPeoVYO4MAISHsvVMOJS1gvmrTrWjbiLLJaVetof76juuRI3Mubta xR1hm/OfpvD0Rf6iFvbbGxyQc6oPutJINlD738euapf9BimxZHDIvqsnNljjOwgQ2rfV Ii4Q== X-Gm-Message-State: AOAM531qVHvFfNrRZla4t0UPnnRX4Uws6p6axiFCkH4LBRd+Uf4HI0tY TXvT4hnKLPu3ParEZ2nKSh4zQ9Z7NzI= X-Google-Smtp-Source: ABdhPJySLdeCrCbVanjmhMuFWvOBkSLtLEZCareuAGPGAtFaAqKlTzrurMZUBBK7Bia6aOfWyrjV6w== X-Received: by 2002:a1c:1946:: with SMTP id 67mr15250854wmz.15.1603710207286; Mon, 26 Oct 2020 04:03:27 -0700 (PDT) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Peter Maydell , Alistair Francis Subject: [PULL 2/5] hw/sd/sdcard: Simplify cmd_valid_while_locked() Date: Mon, 26 Oct 2020 12:03:12 +0100 Message-Id: <20201026110315.4026183-3-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201026110315.4026183-1-f4bug@amsat.org> References: <20201026110315.4026183-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) cmd_valid_while_locked() only needs to read SDRequest->cmd, pass it directly and make it const. Reviewed-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Message-Id: <20200630133912.9428-13-f4bug@amsat.org> --- hw/sd/sd.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 9b53053527e..5510a64401b 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1679,7 +1679,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd, return sd_illegal; } =20 -static int cmd_valid_while_locked(SDState *sd, SDRequest *req) +static int cmd_valid_while_locked(SDState *sd, const uint8_t cmd) { /* Valid commands in locked state: * basic class (0) @@ -1690,13 +1690,12 @@ static int cmd_valid_while_locked(SDState *sd, SDRe= quest *req) * Anything else provokes an "illegal command" response. */ if (sd->expecting_acmd) { - return req->cmd =3D=3D 41 || req->cmd =3D=3D 42; + return cmd =3D=3D 41 || cmd =3D=3D 42; } - if (req->cmd =3D=3D 16 || req->cmd =3D=3D 55) { + if (cmd =3D=3D 16 || cmd =3D=3D 55) { return 1; } - return sd_cmd_class[req->cmd] =3D=3D 0 - || sd_cmd_class[req->cmd] =3D=3D 7; + return sd_cmd_class[cmd] =3D=3D 0 || sd_cmd_class[cmd] =3D=3D 7; } =20 int sd_do_command(SDState *sd, SDRequest *req, @@ -1722,7 +1721,7 @@ int sd_do_command(SDState *sd, SDRequest *req, } =20 if (sd->card_status & CARD_IS_LOCKED) { - if (!cmd_valid_while_locked(sd, req)) { + if (!cmd_valid_while_locked(sd, req->cmd)) { sd->card_status |=3D ILLEGAL_COMMAND; sd->expecting_acmd =3D false; qemu_log_mask(LOG_GUEST_ERROR, "SD: Card is locked\n"); --=20 2.26.2