From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@akeo-ie.20150623.gappssmtp.com header.s=20150623 header.b=o+t6yvL8; spf=none, err=permanent DNS error (domain: akeo.ie, ip: 209.85.128.65, mailfrom: pete@akeo.ie) Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by groups.io with SMTP; Wed, 17 Jul 2019 04:47:03 -0700 Received: by mail-wm1-f65.google.com with SMTP id v15so21863148wml.0 for ; Wed, 17 Jul 2019 04:47:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=akeo-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/7AVRCtPWhsKgTfEiBNQ/ULXyhi6vz65TAsHo2X4wxY=; b=o+t6yvL8mXAcuQTuVZPFXcRnWXt/u9YX+118ZqXUK7upx6b8JBI66eh5vAc0LJcbYT fUlXvJFWdv7/UMPn4564YxH2Y7XIAB+/pgfmDEHm2TNqYmpzSomQOahoT8ENWNIiNAWP rk9BO0n7GVinFmux9/6EKgOtL3nglybelrVJPJ3zWs6E2eJfzJL3zH17P0bBdOP2F1wR kO4/0OryRBU7unnett5GVepS7w+IXw5DTqxeu8dVPb50+rAGj7Z/kFySOByYEyLQiUAP W2nOqNWd8NHgWLu5pm0Aw7PbnIs/NWnuFUkBHP/TTnqyjwSVJrlIWhHw+8qlSKr1CyUs hohQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/7AVRCtPWhsKgTfEiBNQ/ULXyhi6vz65TAsHo2X4wxY=; b=is2vAEPgqAgVr19muKJOVDqp0aOEkHrgt4vBZADU6GemCxHZ+ts5wSIEFCz+48+Nlo mM3a6etCwvSE9ctZPBQ3e+XUTXqr66oMMyxwuttoCrosgE/RCsSRGv5A4qJD+5KTwH97 9J1Q86wD7/Onar3Pm4/6gHc6HY/A3U872XSjxhfijYpMoCqg+pfZ9rOoTTgN9g2K2HVW zYIk+25v4vS6iVzO7JlxIr0Xj2jfQQow9m0d2BiBRumpbBD24HoGi4+2ACGwsWzg+0zn 9pgGq6U1RBU1HTvhhMtpxVMvoOKfaF6jiNr0WLd+a16U5RzYh/tUdIAxZS9n4AQ+ox5R jROw== X-Gm-Message-State: APjAAAUafa+d/lSLuRDhxXPBFVJ61C7tTq883f69krHiWC976ZTWUssh kk30X3gta+zgs8R4hmnb67nKJc33 X-Google-Smtp-Source: APXvYqyRhFqc+riPm0MXiwsfJ32bEHNN8VcPxHKOorn/wMP5xYofmLrzk4rOIwXXJXEX3ga1JKbMUA== X-Received: by 2002:a1c:1d4f:: with SMTP id d76mr38171578wmd.127.1563364021284; Wed, 17 Jul 2019 04:47:01 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([84.203.61.230]) by smtp.gmail.com with ESMTPSA id c3sm26885778wrx.19.2019.07.17.04.46.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Jul 2019 04:47:00 -0700 (PDT) From: "Pete Batard" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, leif.lindholm@linaro.org Subject: [edk2-platforms: PATCH 1/3] Platform/RPi3: Use Wait4Bit return value consistently Date: Wed, 17 Jul 2019 12:46:43 +0100 Message-Id: <20190717114645.7776-2-pete@akeo.ie> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20190717114645.7776-1-pete@akeo.ie> References: <20190717114645.7776-1-pete@akeo.ie> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Michael Brown There are multiple points in the existing code that take the UINT32 value returned by Wait4Bit and return it directly as an EFI_STATUS value. If Wait4Bit fails, this will result in a spurious EFI_STATUS value of 0x1 (EFI_WARN_UNKNOWN_GLYPH) being returned to the caller. A caller treating any non-zero value as an error will see this as a failure, but a caller using the EFI_ERROR macro will incorrectly see it as a success. Fix by defining the return type of Wait4Bit as EFI_STATUS and ensuring that a valid EFI_STATUS value is always returned. Signed-off-by: Michael Brown Signed-off-by: Pete Batard --- Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c index 59120b9d8564..c1e1229f858e 100644 --- a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c +++ b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c @@ -53,7 +53,7 @@ DwCoreInit ( IN EFI_EVENT Timeout ); -UINT32 +EFI_STATUS Wait4Bit ( IN EFI_EVENT Timeout, IN UINT32 Reg, @@ -70,14 +70,14 @@ Wait4Bit ( } if ((Value & Mask) == Mask) { - return 0; + return EFI_SUCCESS; } } while (EFI_ERROR (gBS->CheckEvent (Timeout))); DEBUG ((DEBUG_ERROR, "Wait4Bit: %a timeout (reg:0x%x, value:0x%x, mask:0x%x)\n", Set ? "set" : "clear", Reg, Set ? Value : ~Value, Mask)); - return 1; + return EFI_TIMEOUT; } CHANNEL_HALT_REASON @@ -91,13 +91,14 @@ Wait4Chhltd ( IN SPLIT_CONTROL *Split ) { - INT32 Ret; + EFI_STATUS Status; UINT32 Hcint, Hctsiz; UINT32 HcintCompHltAck = DWC2_HCINT_XFERCOMP; MicroSecondDelay (100); - Ret = Wait4Bit (Timeout, DwHc->DwUsbBase + HCINT (Channel), DWC2_HCINT_CHHLTD, 1); - if (Ret) { + Status = Wait4Bit (Timeout, DwHc->DwUsbBase + HCINT (Channel), + DWC2_HCINT_CHHLTD, 1); + if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "Channel %u did not halt\n", Channel)); return XFER_NOT_HALTED; } @@ -204,7 +205,7 @@ DwCoreReset ( IN EFI_EVENT Timeout ) { - UINT32 Status; + EFI_STATUS Status; Status = Wait4Bit (Timeout, DwHc->DwUsbBase + GRSTCTL, DWC2_GRSTCTL_AHBIDLE, 1); if (Status) { @@ -1261,7 +1262,7 @@ DwFlushTxFifo ( IN INT32 Num ) { - UINT32 Status; + EFI_STATUS Status; MmioWrite32 (DwHc->DwUsbBase + GRSTCTL, DWC2_GRSTCTL_TXFFLSH | (Num << DWC2_GRSTCTL_TXFNUM_OFFSET)); @@ -1279,7 +1280,7 @@ DwFlushRxFifo ( IN EFI_EVENT Timeout ) { - UINT32 Status; + EFI_STATUS Status; MmioWrite32 (DwHc->DwUsbBase + GRSTCTL, DWC2_GRSTCTL_RXFFLSH); -- 2.21.0.windows.1