From nobody Mon Nov 25 02:00:48 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=1719506146; cv=none; d=zohomail.com; s=zohoarc; b=ig0czZIqcJEBEA+iMj8zD5aAOfF1SlGkQsvqLj7opgWyoXZRw9QoSf4UfdWLHuvLGvMB9HfK+sBvUfKAHo+QmzrbQYvc60eMIzgRhYce+ZJznbUSYCGTGHzb21mp/sSGMoP/OBuXd9+mDEUDCTU2493G6uZMSZnASwTSSi6N7ig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1719506146; 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=6OC5ZZTN2g0zXo+PgkNXxQ15/x/Un0F32fTNODaUpCo=; b=Qw6TLpot8yBTC35CK5onaBUfd9jtRNlGU9YpcjedFKLVE8Sq/ZiVZ8ZO+sM4WEQZYU1ms3KreWyH8Uvmh/ROWJLaSQYQA63MyusT3QOQXWaZ/mL9lYs9YmHFmdFPE9bLu3zWZ94Z5+73Y9AmzL+GGZvWslxJQ9ZzDoYCB3dX+vo= 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 1719506146252633.2619713220532; Thu, 27 Jun 2024 09:35:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sMs57-0001cV-4x; Thu, 27 Jun 2024 12:34:45 -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 1sMs55-0001bX-HB for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:34:43 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMs53-0004Xp-TF for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:34:43 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4256788e13bso4476365e9.2 for ; Thu, 27 Jun 2024 09:34:41 -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 5b1f17b1804b1-42564bb6cccsm34736665e9.35.2024.06.27.09.34.36 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:34:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506080; x=1720110880; 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=6OC5ZZTN2g0zXo+PgkNXxQ15/x/Un0F32fTNODaUpCo=; b=rcf8ox58YZWChJUnHR7hZr1l7eWrvp2bxXw+qa2eBeZGkfQOGudn3z6+fv53un/lER o+gxM4IXreEbzLuFLMQlc+SM7fTPObaPgXAlEnJoc0wQ7zAd80+HVTMl64/+crlae/t/ ID+uZi+dbxnn0BQ8y3oqOek6310yMZyiEz6lEUaVS4N+g3UeEhwyFlizPVjgujbG/KYs vEQKzrnlOijrixlsCdO1EOnjZDbwlukWbsU3OHW9MxfcMFxsMvZjwnDa44G8nau++y/B MZZONam8Z+QOln9UJL+5KpdrP5gx4Xf6JvcHdscCpzfPhYJ88bSLd+Xw2U0iFbsdqLay 5p5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506080; x=1720110880; 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=6OC5ZZTN2g0zXo+PgkNXxQ15/x/Un0F32fTNODaUpCo=; b=lt/L5QcZ2xYXcyRTL7PM1ItPQytaUbVQExrf5z/QGkOOW2XTSo+r/EeAW04mjGPIgr yEFlhhgl2BnRkGd2dH+0fPHeZFDL63VSpVk3aWtbWd5HE7dOhY3xmLhn0EMblLyKosUy VeRbZ4GEAFgKqT/hl/w/zTT7flnNXkwSxbz5OK39Y1JxYUmP5osephX/ZnKci8KQFyHH 5ijSCiCMjwQfl6z078nIpwqmKtdn/NBdHMtxOzK0/eyyRozLkCgDah2HJy4rnWD2b3oL HZe/ZmRfaKWe3BY8tFJ9w/rNd1SFMBHoUpPGROmO1G95EAz0OCmJ6VJ3XYGMFA/vzFHc TVFA== X-Gm-Message-State: AOJu0YzrYXXtVWFWR3sAMkfXB8ZftOzbaWNwlKroejo5Z1oASP2zpFF9 6Z+lNP627Rz5eU42b4VXv5iiMh9UX4ToGiComRkrropcBP1osXbkZlfi/bU2WRIgt9M6HC1g2cC 9phA= X-Google-Smtp-Source: AGHT+IHmWB9cBJ6kB0a4Z7vpIdBao1tKUnFDosAx5eK6F3ndMypCrF/ked2M8wQLRrLDQAtC7/LUlQ== X-Received: by 2002:a05:600c:6b16:b0:424:a3d7:2a89 with SMTP id 5b1f17b1804b1-424a3d72b27mr54802075e9.4.1719506080055; Thu, 27 Jun 2024 09:34:40 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Sai Pavan Boddu , Luc Michel , Francisco Iglesias , Bin Meng , qemu-block@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Joel Stanley Subject: [PATCH v2 3/7] hw/sd/sdcard: Convert WRITE_SINGLE_BLOCK to generic_write_byte (CMD24) Date: Thu, 27 Jun 2024 18:33:59 +0200 Message-ID: <20240627163403.81220-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240627163403.81220-1-philmd@linaro.org> References: <20240627163403.81220-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::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.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: 1719506147881100003 Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- hw/sd/sd.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 5dbfc8000b..4a03f41086 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1101,7 +1101,6 @@ static sd_rsp_type_t sd_cmd_unimplemented(SDState *sd= , SDRequest req) } =20 /* Configure fields for following sd_generic_write_byte() calls */ -__attribute__((unused)) static sd_rsp_type_t sd_cmd_to_receivingdata(SDState *sd, SDRequest req, uint64_t start, size_t size) { @@ -1470,10 +1469,6 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, = SDRequest req) return sd_r1; } =20 - sd->state =3D sd_receivingdata_state; - sd->data_start =3D addr; - sd->data_offset =3D 0; - if (sd->size <=3D SDSC_MAX_CAPACITY) { if (sd_wp_addr(sd, sd->data_start)) { sd->card_status |=3D WP_VIOLATION; @@ -1483,7 +1478,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, S= DRequest req) sd->card_status |=3D WP_VIOLATION; } sd->blk_written =3D 0; - return sd_r1; + return sd_cmd_to_receivingdata(sd, req, addr, sd->blk_len); =20 default: break; @@ -1999,7 +1994,6 @@ send_response: } =20 /* Return true if buffer is consumed. Configured by sd_cmd_to_receivingdat= a() */ -__attribute__((unused)) static bool sd_generic_write_byte(SDState *sd, uint8_t value) { sd->data[sd->data_offset] =3D value; @@ -2045,8 +2039,7 @@ void sd_write_byte(SDState *sd, uint8_t value) sd->current_cmd, sd->data_offset, value); switch (sd->current_cmd) { case 24: /* CMD24: WRITE_SINGLE_BLOCK */ - sd->data[sd->data_offset ++] =3D value; - if (sd->data_offset >=3D sd->blk_len) { + if (sd_generic_write_byte(sd, value)) { /* TODO: Check CRC before committing */ sd->state =3D sd_programming_state; sd_blk_write(sd, sd->data_start, sd->data_offset); --=20 2.41.0