From patchwork Tue Jun 25 07:34:41 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: 807264 Delivered-To: patch@linaro.org Received: by 2002:a5d:508d:0:b0:362:4979:7f74 with SMTP id a13csp2222566wrt; Tue, 25 Jun 2024 00:35:39 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXQdJC0pkfT/05NQlCaIoGeQ1IFRvLF2OwpUfxSzYwsOLRzCcwGM1hAsqZImRsnrVglD2sYw5zXOXXqizstLweD X-Google-Smtp-Source: AGHT+IEYAmsjz4ah12+UQ65IyXj/n/g8i2VW1G9h/ibaBQnAonFiX+bXr96sYxrsmdiniRg/6fEw X-Received: by 2002:a0c:f349:0:b0:6b2:a5ee:4911 with SMTP id 6a1803df08f44-6b53bccbd0cmr81156566d6.20.1719300938865; Tue, 25 Jun 2024 00:35:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719300938; cv=none; d=google.com; s=arc-20160816; b=PeVgR+VHyy41wqfTdo0HetSTA+bgem/vZyRn4d1DsD9wDFQ/BWZYBYox3p7+eGo6FP KptK7OwKj9Da/ZeZh/1HhBTE1tz/1GIFDoyF8BPtiRgZRrxqiqiR1KmB5WoxL6OaPCqs jH+rER23Zz7H390hWQffaWXBu7C42qaGNk5cWnDp/vrD9GVcQ1MXeCpOnBiWs3CmkSQm xi3ZPaTccE52vpHHkITIhmRpz5ulS5c6UD1/WPKH6xzFqKCRYW+m0fx6TsB0zbFVgdD9 yDuxcBWL0j+oN3DjqVkMDc+rH4IjQDdXuyfqje2+Q4/jaBa4rAn9ixUb6bHl54o3xZos iTpQ== 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=dkL+F609blkCP7YhkbDtjFQ52Ff3yQ68oguPONbJIG8=; fh=RCxNUJwt/amfcWvs/lXDf/JmxshGBXr892O+ARTFYyU=; b=t1avHIuu2NGNZ5QNBPtjgHjbeKDZz0yytwfJKhj1eD1yE/OG3AjsHC7Qk7J/HPDb4q f2QO7amQ4Wsvj3Idw+vhsKot8PRQc1pyFmIzzCvxrTm8nbtA+XNR1TDX1strOfBxtTz5 po2sdxtj6gi4ukaKfHu1k1Jyo3lMJap6WEW2c0o/G9TWeF+f0H4NweJm/Ezju2f8Sxgi LnK2ELpPEHSxoVHS8ZqdPKqLFbjbyPV61vLiUxUfN/70CjqEV7ID/Xpp7fHZy/eYM+o/ VeL01EH0AfYYWn8yXbhQ05DMqVGRpmCRdJxoss9cqoRPQnF5U7fjRhYQjcCh8zDOJuIX 7h0A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XhjLj5bR; 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 6a1803df08f44-6b51eedcfc9si98248896d6.396.2024.06.25.00.35.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Jun 2024 00:35:38 -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=XhjLj5bR; 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 1sM0i8-0004sT-OM; Tue, 25 Jun 2024 03:35:28 -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 1sM0i7-0004r7-7i for qemu-devel@nongnu.org; Tue, 25 Jun 2024 03:35:27 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sM0i5-00042o-M9 for qemu-devel@nongnu.org; Tue, 25 Jun 2024 03:35:26 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-424798859dfso43620855e9.0 for ; Tue, 25 Jun 2024 00:35:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719300924; x=1719905724; 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=dkL+F609blkCP7YhkbDtjFQ52Ff3yQ68oguPONbJIG8=; b=XhjLj5bRAIS9pow3Ewos9Vqixrh/KdJ3/zW010ce7gV05yssSWIg15Wow+eYIQj73R soQKvnhLNK9Me9MawxbuHlVfxvDbdo8Is9RzbtXEZHvdE1Wvn7ej7c8KUHVgBAksIH5L MvfrrUszAAnAf/yrS/YWKyDUNcxD9KNugFT1z6ds1aEf/yzTS94etiLaLOxkqlm9T4qg ftGD7yYzurTfQvcqGcwCRLxeERngqQqSFdMcKAtp7zpmxHh0TO8T8XTtIF4aM8iEOXj9 ATwxKmRuUUsDo9P34S5ulQHXwGMPBdSB9EjMyCBz2X4EbW8vsGHFiXBObgJs+8tG07Zz Aygg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719300924; x=1719905724; 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=dkL+F609blkCP7YhkbDtjFQ52Ff3yQ68oguPONbJIG8=; b=RWDB/HbLe+odQMZiGMWDK6w73Llr3/mYEyq+/lQKXv+gjLN0LfCeeirdtJiBIUOkE/ Ezl5cBNNG8VIHUyxINyn7bCIsDiqf5/J+6GAJlTRh/MgPcCsdgMymUBCyW2slWoQKc49 aSavk4kVkNez4okKyHH1yOtqH03oiVGSo3HCg7XjuIyPwc5Ytn1Pqo7nCLFEpP4u6eSz oiv0GiqY2LVzdppXCpcgoNVLcelRLq4Hdz67HrhGb3TRrI+AGHm0Z7dae7bJXPVSknDi zctcBRrWQSJ5fH+r2omILOk5f9Im428Wo0y7NSbZQqyXqhBpe0BNBDxTfwERuSau/fBN 1WUA== X-Gm-Message-State: AOJu0YwgpPzl/e2vtAHGUQdX6kS6I5hSCiOm4TkgQ2cj/aTjbPT5MSbv f0RPjGkn8KbHiN6+2pI4qOF0Y0ViOGjoLDO73uCt1Kg1GMx1DHra7MSxiLr/gnU4X3i/1OcpVB5 t X-Received: by 2002:a05:600c:470a:b0:421:7fb6:511e with SMTP id 5b1f17b1804b1-4248cc5931bmr43876865e9.30.1719300923941; Tue, 25 Jun 2024 00:35:23 -0700 (PDT) Received: from m1x-phil.lan (mau49-h01-176-184-41-129.dsl.sta.abo.bbox.fr. [176.184.41.129]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4247d208e13sm198393945e9.36.2024.06.25.00.35.22 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 25 Jun 2024 00:35:23 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Bin Meng , =?utf-8?q?C=C3=A9dric_Le_Goater?= Subject: [PATCH 7/7] hw/sd/sdcard: Convert GEN_CMD to generic_write_byte (CMD56) Date: Tue, 25 Jun 2024 09:34:41 +0200 Message-ID: <20240625073441.34203-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240625073441.34203-1-philmd@linaro.org> References: <20240625073441.34203-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Signed-off-by: Philippe Mathieu-Daudé --- hw/sd/sd.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 82b44b65e0..fe2210d65a 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1633,14 +1633,12 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) case 56: /* CMD56: GEN_CMD */ switch (sd->state) { case sd_transfer_state: - sd->data_offset = 0; if (req.arg & 1) { return sd_cmd_to_sendingdata(sd, req, 0, sd->vendor_data, sizeof(sd->vendor_data)); } - sd->state = sd_receivingdata_state; - return sd_r1; + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->vendor_data)); default: break; @@ -2085,9 +2083,8 @@ void sd_write_byte(SDState *sd, uint8_t value) break; case 56: /* CMD56: GEN_CMD */ - sd->vendor_data[sd->data_offset ++] = value; - if (sd->data_offset >= sizeof(sd->vendor_data)) { - sd->state = sd_transfer_state; + if (sd_generic_write_byte(sd, value)) { + memcpy(sd->vendor_data, sd->data, sizeof(sd->vendor_data)); } break;