From nobody Tue Feb 10 11:13:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1593189292; cv=none; d=zohomail.com; s=zohoarc; b=KwWlLq7BhGWiiKQC28sPt58atjvYw5dEXLHpkdsHes3h1wuHNOLyJf0tVv2Jb1py4BuvVNCOULXW9IcTdGBrxkcb9sp2fpsq8eZIJYpw6iCMfZHuCc5qKj5omMnQV2wizm9XLeaVHv6tux1GsCJIe07WkplahUgqkeZCpzbUVCE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593189292; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Fu1NrcnhOVIQHNzxBvKJM9PlZWrYYL+8zyKDr6GNREk=; b=VoHOxfF61Ewj9yLUxT+hx1IlOYCScOe4KxE+NGxBHWox6VwSUTkxFPlzQclu9XnuqXBi0IOt0g/GfdnuW0ogvucvoOJOCY9amyf68H6IugZ5mZZXWU879HHg53bEW8VXGQLPXxmSVUlObDMboFaa/ORXAhGpzLjuvY90WoOq7Y8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593189292430283.7662107229763; Fri, 26 Jun 2020 09:34:52 -0700 (PDT) Received: from localhost ([::1]:46776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jorJT-0006ST-12 for importer@patchew.org; Fri, 26 Jun 2020 12:34:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jorDO-0005bR-9k; Fri, 26 Jun 2020 12:28:34 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:47037) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jorDM-0003Ld-N4; Fri, 26 Jun 2020 12:28:33 -0400 Received: by mail-wr1-x444.google.com with SMTP id r12so10024964wrj.13; Fri, 26 Jun 2020 09:28:31 -0700 (PDT) Received: from localhost.localdomain (1.red-83-51-162.dynamicip.rima-tde.net. [83.51.162.1]) by smtp.gmail.com with ESMTPSA id 12sm4867255wmg.6.2020.06.26.09.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2020 09:28:30 -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=Fu1NrcnhOVIQHNzxBvKJM9PlZWrYYL+8zyKDr6GNREk=; b=UsGsFqPff4byO+Q81uVb6SiuKiI3wvz0W87LcZfET3165RbmBZj3VGkD4hS4BK5ab0 szHuEoNsROADkrk1bJL5T0NfyEW6j8S++4WsnMFTaTAMYhAE+++/kLgefbgcAGofBOkX JU3pfeQ2JPrOjOPTVsfTbgPg2jHz32izJNsJ5miChXiBsUFp0zcDBlZVu9iOL10xKL5G 7O8G9NybwwAmpExFN1g5grooDMJYFLy+ajgmyBtit3iB/DUyg2OD4k8v+Pq/FM+4sfeF VLebxsAh7W288lASPaBGfN0mDx2fPKhypxi1f6i/XTim2lVs5mfzw29H9v89fKZUZK6d C3lQ== 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=Fu1NrcnhOVIQHNzxBvKJM9PlZWrYYL+8zyKDr6GNREk=; b=HdjK6qb/pj4tIkpEdoCkk3rEgrMN+VmwAncyauN4MOTA4NIUJpunc5dOsYP9L4ZMCB fOTA+HuYH0of/uTnXnGor+NGLc4X3BzkJurc+5n5/vHzmMSRhdEYV9ldNeqZrY4FjQ1+ vVijnynD+f4HL3vo5POFMnyEgPzjxYRD+SMvPKvKkJT+Mh0LeWp4oR9RKQJcj2pXNTAh zOQh8/XfdnpwU34cU0aTQbkNZq1CjzfRuwmvZy4RbUk7+4kv9uAo18qN2fPUcRGtGi2i 51bucswxqcKGsfmijjJK45T3VyDJ9nnd6Mbssj4roktSxJYi6lT1n6WfF9SmD6HZsR9m 9sQg== X-Gm-Message-State: AOAM531ShpFSkU9SYnPK2kdhI4jrGUhf6Hnvz+OwhxY++JVEzh61H17O 7lEX2BUNgXVljeis+al31j5Vt6mc X-Google-Smtp-Source: ABdhPJx38FVdo2pvzuXGnx9jLVtqX6DL79DTMHn/pAB3Lad5+p+Vlua2ElK+H0nwY45qQMh9GaE9oA== X-Received: by 2002:adf:e901:: with SMTP id f1mr4608999wrm.80.1593188910851; Fri, 26 Jun 2020 09:28:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 09/14] hw/sd/sdcard: Simplify cmd_valid_while_locked() Date: Fri, 26 Jun 2020 18:28:13 +0200 Message-Id: <20200626162818.25840-10-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200626162818.25840-1-f4bug@amsat.org> References: <20200626162818.25840-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::444; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-wr1-x444.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 --- 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 7d20f344bf..b887dce0e1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1664,7 +1664,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) @@ -1675,13 +1675,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, @@ -1707,7 +1706,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.21.3