From nobody Mon Nov 25 02:28:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1719505551; cv=none; d=zohomail.com; s=zohoarc; b=hAMuEn3rCl3IsXz5K83JB0d90ASeinlcoC1Sy74LV7wprSgXQ0fFvsG2sTRZfuGFmIYdwBlBG1Zb34MJimgLaks5MgQPRauQW1i0GANgbC7wS4UgBXZvFt+G25WRssXL6lOU2lTTJH+6KEUXSVQuT/C49YKkG2avyV432FrGdM0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719505551; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DSF5Ro3NaUsJXtCUAFWLr+3NgzU6nFSUILhMkj2n5D4=; b=DPsphfxmbUB5Fx+E0P2Onvz/LfM1CcveSSN8jxK7gV7DhoYCp3RMvbVCrVMM2DRJ/OcF7jx5BOiqpOw6RfqfWQRKkXMZVK29iJCQTt52uh6eccCplw7kh22Z6Fpt4r+apdqmrqszk2vCDA7Ry/USyoSeIdtL+EVOj/gu4dEkgOo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1719505551650507.2204235419267; Thu, 27 Jun 2024 09:25:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMrwT-0004EN-9Z; Thu, 27 Jun 2024 12:25:49 -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 1sMrwO-0003iz-5W for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:25:44 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMrwJ-0002d1-KG for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:25:42 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-363826fbcdeso5900204f8f.0 for ; Thu, 27 Jun 2024 09:25:37 -0700 (PDT) Received: from localhost.localdomain (33.red-95-127-46.staticip.rima-tde.net. [95.127.46.33]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3674369ebaesm2348335f8f.91.2024.06.27.09.25.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719505535; x=1720110335; 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=DSF5Ro3NaUsJXtCUAFWLr+3NgzU6nFSUILhMkj2n5D4=; b=VRTLmw2Kl7Psz2fJJmQvLVcfBWkyXFy7RNqZ2CiL1cd/wxLbsNePqyzT3SatEzCGLq ZOdhDuNshAIun+hWnUpgFP1XrOxY7+BlE7WBpPu7NqwXAuAZW3ls73bh0plkc1xQu35n RnDUSnc452/zeszBtOLdrqe4K8EpfwhRWBRZVFwukNPIwcUYGpwO84lTYkAAIzTLNq6k +k9pPHJePki5DmfklbxS9uJpxuGwsZbpnXxtECvNJORbmS0jbxafDPrvNrQlGeko/rhL 5CPq7Vn8QNAjmR9x9MjI0HzNCSKjlHadeVY4jnrSTgYznvCIuf3dc7EJNVOFL7RnS/lO whrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719505535; x=1720110335; 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=DSF5Ro3NaUsJXtCUAFWLr+3NgzU6nFSUILhMkj2n5D4=; b=vAHgYyhiIA1sxjYXsZvLim9iPEJkv7hpkqHBjyYFgQSZ/tkTCfVAJ+s5oOMQvvltxX GzZPI1iaxPsmEXlleVlZ4nhlGM8SiE4I/vQ3fpNwey5QwJj7pKUJFpnTE1EhAUMOyMJ1 qmU2wCIYHQWN5CG7s20cCwjvuXXALyrVAuMK2LqGzHkuoYW6ZxUSYiHn/E41v62qvXt4 iIfc1xsPdmcG8MXnsrLqP7WPs0wad9k+oNYIeYehKC1+x7OaDglcNScxq6jaxpaEFXdi DcaHSMVZght1PD//pzQT3O41/PWcRzhrwxUct5qe2cAiAX+enrplEG+xW1tWrOmAh6uo UrAg== X-Gm-Message-State: AOJu0Yz3wsdEuQFTmBFKWEQg6/N4w+g6nR0VePuLR3LdEnzl7gRT03/0 HNWQ6LqMg5nTNOfPxQJN8T2ZPk8L1q72ofDxEgJf+RJU70QxbjZNi47UNYLyOPjPoTbIY0oLUIh 5/Ns= X-Google-Smtp-Source: AGHT+IESxH3LVe7TrKN7BENR7voaifbARLmTsdyOhFIvFpdn6nBlZfs6cwdj42L17vK8YD2SncAjkQ== X-Received: by 2002:a05:6000:2c5:b0:366:e89c:342b with SMTP id ffacd0b85a97d-366e89c34bcmr13353327f8f.52.1719505535283; Thu, 27 Jun 2024 09:25:35 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Laurent Vivier , Tyrone Ting , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Bin Meng , Hao Wu , Francisco Iglesias , Paolo Bonzini , Thomas Huth , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-arm@nongnu.org, Joel Stanley , Sai Pavan Boddu , devel@lists.libvirt.org, Luc Michel , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v3 14/17] hw/sd/sdcard: Extract sd_blk_len() helper Date: Thu, 27 Jun 2024 18:22:29 +0200 Message-ID: <20240627162232.80428-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627162232.80428-1-philmd@linaro.org> References: <20240627162232.80428-1-philmd@linaro.org> MIME-Version: 1.0 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::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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=unavailable 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1719505552914100009 From: Philippe Mathieu-Daud=C3=A9 Extract sd_blk_len() helper, use definitions instead of magic values. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index aaa50ab2c5..5997e13107 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -603,6 +603,14 @@ static void sd_response_r7_make(SDState *sd, uint8_t *= response) stl_be_p(response, sd->vhs); } =20 +static uint32_t sd_blk_len(SDState *sd) +{ + if (FIELD_EX32(sd->ocr, OCR, CARD_CAPACITY)) { + return 1 << HWBLOCK_SHIFT; + } + return sd->blk_len; +} + static uint64_t sd_req_get_address(SDState *sd, SDRequest req) { uint64_t addr; @@ -2076,7 +2084,7 @@ uint8_t sd_read_byte(SDState *sd) if (sd->card_status & (ADDRESS_ERROR | WP_VIOLATION)) return 0x00; =20 - io_len =3D (sd->ocr & (1 << 30)) ? 512 : sd->blk_len; + io_len =3D sd_blk_len(sd); =20 trace_sdcard_read_data(sd->proto->name, sd->last_cmd_name, --=20 2.41.0