From: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
To: qemu-devel@nongnu.org
Cc: "Daniel Henrique Barboza" <dbarboza@ventanamicro.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Bin Meng" <bin.meng@windriver.com>
Subject: [RFC PATCH 1/2] hw/sd/sd.c: add sd_card_powered_up()
Date: Fri, 20 Jan 2023 09:01:32 -0300 [thread overview]
Message-ID: <20230120120133.666993-2-dbarboza@ventanamicro.com> (raw)
In-Reply-To: <20230120120133.666993-1-dbarboza@ventanamicro.com>
We're going to add another verification with CARD_POWER_UP. Do a helper
to make the code easier to follow.
Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com>
---
hw/sd/sd.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index da5bdd134a..bd88c1a8f0 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -289,12 +289,17 @@ FIELD(OCR, CARD_POWER_UP, 31, 1)
| R_OCR_CARD_CAPACITY_MASK \
| R_OCR_CARD_POWER_UP_MASK)
+static bool sd_card_powered_up(SDState *sd)
+{
+ return FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP);
+}
+
static void sd_ocr_powerup(void *opaque)
{
SDState *sd = opaque;
trace_sdcard_powerup();
- assert(!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP));
+ assert(!sd_card_powered_up(sd));
/* card power-up OK */
sd->ocr = FIELD_DP32(sd->ocr, OCR, CARD_POWER_UP, 1);
@@ -640,7 +645,7 @@ static bool sd_ocr_vmstate_needed(void *opaque)
SDState *sd = opaque;
/* Include the OCR state (and timer) if it is not yet powered up */
- return !FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP);
+ return !sd_card_powered_up(sd);
}
static const VMStateDescription sd_ocr_vmstate = {
@@ -1616,7 +1621,7 @@ static sd_rsp_type_t sd_app_command(SDState *sd,
* UEFI, which sends an initial enquiry ACMD41, but
* assumes that the card is in ready state as soon as it
* sees the power up bit set. */
- if (!FIELD_EX32(sd->ocr, OCR, CARD_POWER_UP)) {
+ if (!sd_card_powered_up(sd)) {
if ((req.arg & ACMD41_ENQUIRY_MASK) != 0) {
timer_del(sd->ocr_power_timer);
sd_ocr_powerup(sd);
--
2.39.0
next prev parent reply other threads:[~2023-01-20 12:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-20 12:01 [RFC PATCH 0/2] fix SD card migration Daniel Henrique Barboza
2023-01-20 12:01 ` Daniel Henrique Barboza [this message]
2023-01-20 12:01 ` [RFC PATCH 2/2] hw/sd: skip double power-up in sd_vmstate_pre_load() Daniel Henrique Barboza
2023-01-20 12:38 ` Philippe Mathieu-Daudé
2023-01-23 12:09 ` Dr. David Alan Gilbert
2023-02-01 20:52 ` Juan Quintela
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230120120133.666993-2-dbarboza@ventanamicro.com \
--to=dbarboza@ventanamicro.com \
--cc=bin.meng@windriver.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.