From patchwork Thu Jun 27 16:34:00 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: 807841 Delivered-To: patch@linaro.org Received: by 2002:adf:e842:0:b0:362:4979:7f74 with SMTP id d2csp894644wrn; Thu, 27 Jun 2024 09:35:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVnxpaFAzZhiIsYyRqRl2Z1U4PhfZn3CXK5js79Vm6S98VONd18uDwIP2eYmEzpdcmaTLpci19lPAs6WhAvaBwX X-Google-Smtp-Source: AGHT+IEBjpaZL6GfndwDsbyykzBig7EVrvuPUz28JM2R+IJvwiH64/eE3ZjTTwO2ApfiySSLQXxc X-Received: by 2002:a05:6102:366:b0:48f:8f72:ecf8 with SMTP id ada2fe7eead31-48f8f72ee22mr2113626137.8.1719506130424; Thu, 27 Jun 2024 09:35:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1719506130; cv=none; d=google.com; s=arc-20160816; b=Gp0q00TA8xyqGCgY8r9ZdFlHwV1onpHAWS6mfiUw7R9mygZDLKwU4sPb0Bbr/inMl8 PT7TMSvsNkUWBHrCqhECGx+3uajTYVQV120GRryLwigwU9Xf4PtVYyDFyHgYHfoM5URE U4ISHOKoYFg+QQ801LhIdQ1zj/xeXlzzOw6I46ge5aFKTnsgXxZjbYAQBejWwou/eQrL oBqZu4JmaWWzo1+Vd/nRhEX/Oh8feVsMp2lF2VPv4tizQC98qJIxxwkf6zje/mKSsAHF Zteijx1QCxH8V10prtV1MvevpCwYnoVcGCEGgGq7HQ4Ph6I5mTV5uFAxTepD9Mjfpgr0 +eKA== 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=wBDncTLnw5e5+FewhpyrEtD081BWahb+ptMB4QhJVa0=; fh=Nuz+xfBuPB+jr462hD/XUDJnYvP1a+fdu4WocHfEOYk=; b=iFCr1GBLB2liGAjs5fCa4eJLj1QfiCDjpdmex7Jf2v/kLhH4uYi6EEn32WUS5siK7f U8d4Rwp2/NpwcTfGF/mgIlWe2RogBZay8Mam6ZSN1vyONHrDJpX43vpWZ6ZoAQHhS9a5 CZmxf0JTkWqOlSngL0uLh2HzeQBiGeqA7lyw6+2mWe4kNDkPdMMLu7yn4P5mU4QX07eI apAHHo76hYnqU40d86Ao2toTrrJ6AbWIGaiFT/YcdN9E5b4SnWZiA6/oCe9lqlHoKx/E bv6hXtOXhRu5q72jvzn5CNiG4SvNSDvIJ3yPQ07BeD7/toHvTBpc2uC3bfPJ1BLZqI4a z/zw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SN24iFVg; 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 a1e0cc1a2514c-80fd1077511si260445241.22.2024.06.27.09.35.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Jun 2024 09:35:30 -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=SN24iFVg; 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 1sMs5G-0001lL-Je; Thu, 27 Jun 2024 12:34:54 -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 1sMs5F-0001iz-NB for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:34:53 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sMs5E-0004Yq-7G for qemu-devel@nongnu.org; Thu, 27 Jun 2024 12:34:53 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4256742f67fso5169205e9.3 for ; Thu, 27 Jun 2024 09:34:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1719506090; x=1720110890; 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=wBDncTLnw5e5+FewhpyrEtD081BWahb+ptMB4QhJVa0=; b=SN24iFVgfiw6f7qwlWKvnatbwKFQe2pfysgT03Bdn3W/bGZ1LQ5vIlBHqw6YQEJJuc +9y3umArY3lxpVjT+BZJUNmXapQVzh6vMIZXu8VjiuDDf+O3q2i78jQliEkaLA41DPjj EsKt5a8zgVS9U92BS0qLO1VEi4aFrikD65yp6PRKdQiNIrnXH4IjggNFahIoEzWve6UE QhumdqmmBTBQtXe8KgqzoVVzo6Yeqz8r1HyJrDcErhX8iboRKE4yIyysCf8f1Ttjsif3 XmxOxRr4x+6ASjNOB9fCL8gjOTjUDCV9AkRM3GRbbU1ZETp+VlygStDxzUARU480hBTc M7+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719506090; x=1720110890; 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=wBDncTLnw5e5+FewhpyrEtD081BWahb+ptMB4QhJVa0=; b=ieMiWCItWAvQFF0n/v/C3ib7Wn9hY9YXzFuWKAFEbS8KhCprwoZLjTzW0lsyodPzU6 c5I2uEIdSbuDzKVWpwzxTJg5tWjvlGCLyd/TA8JPbKzdZmz9OPnQe85sLSNbZMO+Xtqt q7XkH3yClXHS9yghU8ELz7cyb2Znv6N91zTVm12fLk/w+YHifAx1Z0hXpS016s8L9AKq kDPo16OL8KEw51VYMf9awixdvHlNbLhnWClrLH7vxUP7kKEr2mdqBfW/hkh1VRz+4awv Kdfd2JGaxrL41esp1wOPLSOrZLSjlS02t84FtndklIAdND/ZmH6DIL6011h4G9voGCS4 sAuw== X-Gm-Message-State: AOJu0YzsDCJJxU2MLtg/Fi2bzpiMVlFP64thRxHDxJa4r9k2YAVXdFLO x7dviyAphkmYWRCAbX0T5CKnRQ24O3yOrMiSb456skJsv/ap/s4IrMD4mysZwNL4Gt9UoMSMiyY Ytt8= X-Received: by 2002:a05:600c:22c9:b0:425:6275:f7a with SMTP id 5b1f17b1804b1-42562750fbemr28834225e9.15.1719506090468; Thu, 27 Jun 2024 09:34:50 -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-424c8280a87sm75720715e9.24.2024.06.27.09.34.46 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 27 Jun 2024 09:34:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-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_Ma?= =?utf-8?q?thieu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9dric_Le_?= =?utf-8?q?Goater?= , Joel Stanley Subject: [PATCH v2 4/7] hw/sd/sdcard: Convert PROGRAM_CID to generic_write_byte (CMD26) Date: Thu, 27 Jun 2024 18:34:00 +0200 Message-ID: <20240627163403.81220-5-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 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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=ham 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 | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 4a03f41086..b9c72a0128 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -1515,17 +1515,7 @@ static sd_rsp_type_t sd_normal_command(SDState *sd, SDRequest req) break; case 26: /* CMD26: PROGRAM_CID */ - switch (sd->state) { - case sd_transfer_state: - sd->state = sd_receivingdata_state; - sd->data_start = 0; - sd->data_offset = 0; - return sd_r1; - - default: - break; - } - break; + return sd_cmd_to_receivingdata(sd, req, 0, sizeof(sd->cid)); case 27: /* CMD27: PROGRAM_CSD */ switch (sd->state) { @@ -2088,8 +2078,7 @@ void sd_write_byte(SDState *sd, uint8_t value) break; case 26: /* CMD26: PROGRAM_CID */ - sd->data[sd->data_offset ++] = value; - if (sd->data_offset >= sizeof(sd->cid)) { + if (sd_generic_write_byte(sd, value)) { /* TODO: Check CRC before committing */ sd->state = sd_programming_state; for (i = 0; i < sizeof(sd->cid); i ++)