From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::22f; helo=mail-wm0-x22f.google.com; envelope-from=leif.lindholm@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com [IPv6:2a00:1450:400c:c09::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 4891B2222C229 for ; Tue, 30 Jan 2018 04:46:43 -0800 (PST) Received: by mail-wm0-x22f.google.com with SMTP id g1so903736wmg.2 for ; Tue, 30 Jan 2018 04:52:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=x1nhBxaaBQp1eVfvax8/vvguDnIreCzbo1JRyd7XiLw=; b=TAIhoe5WdNBA3qojIimH7+stAiLBUeaX3mGIdXqTLialB3BryGq3UKpsqLsIFMZPro OP/65H5Y179YXqfnuiP0fLH2UXi3Hx9fHEXoWWsr9ipW94PKn4Zq0W4OMKZwfsUhfbg6 Hs2M0UnnGf+dxvMize/yMvn/2qgldanuANX3k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=x1nhBxaaBQp1eVfvax8/vvguDnIreCzbo1JRyd7XiLw=; b=VmGjDn0DncXmVwkEsDLicpW+zwmxJ4hTrSesmhECGdw1f95hcIXHF8uqzpFfog+FPs VD9LSoiDp8W8T7XJqpu4a+4Z/fahgeRxaWXkFAK3sPT7J1QwiPVGUYDSB00hZicaZvJc jsd+qRuZNeRcHFRHJ09i+52G5/nj9tl8dU2Vc+PVy5m+ChiQIXudcGTmJwrJc5DhxR+y FqwwxEfvsU8M9cgLKsgxHJvQ67i0YA7qJ4xHS3v1HTNMiHA6uZ6RJqQBi/ZrEKaDXO3z RKZhD6+v7gpi/1shIyvLFEkhjd1hreiKH75BImer/FAAwvSqyTVSd8d7H2jT3VebwyEO bllg== X-Gm-Message-State: AKwxytcUn83x817aimgvNBKC+VIM8jstz4tfLO5BKtX7+MokWtr/Bdw9 ZljIEs/hka841Htt5wLu224i/fbaJkk= X-Google-Smtp-Source: AH8x226r4fDZuGIK4OY4CdTvbwRtAWisuP5L6hGEEmKt4eO2+zzBmnlKAgFWFj8oI/exnqbILAk6mQ== X-Received: by 10.28.109.10 with SMTP id i10mr22760681wmc.107.1517316736785; Tue, 30 Jan 2018 04:52:16 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id f5sm14451948wrh.28.2018.01.30.04.52.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Jan 2018 04:52:15 -0800 (PST) Date: Tue, 30 Jan 2018 12:52:14 +0000 From: Leif Lindholm To: Ard Biesheuvel Cc: "edk2-devel@lists.01.org" Message-ID: <20180130125213.gtyhz2nirprz4gjt@bivouac.eciton.net> References: <20180130103240.4669-1-ard.biesheuvel@linaro.org> <20180130110044.ftayhc37kfh6pw27@bivouac.eciton.net> <20180130114738.7m6e46bx2ug7fa63@bivouac.eciton.net> MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [PATCH edk2-platforms] Silicon/Socionext/SynQuacer: add configurable eMMC support X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jan 2018 12:46:43 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jan 30, 2018 at 11:52:41AM +0000, Ard Biesheuvel wrote: > >> >> +STATIC > >> >> +EFI_STATUS > >> >> +EFIAPI > >> >> +SynQuacerSdMmcCapability ( > >> >> + IN EFI_HANDLE ControllerHandle, > >> >> + IN UINT8 Slot, > >> >> + IN OUT VOID *SdMmcHcSlotCapability > >> >> + ) > >> >> +{ > >> >> + UINT64 Capability; > >> >> + > >> >> + if (ControllerHandle != mSdMmcControllerHandle || Slot != 0) { > >> > > >> > This test pattern repeats below, does it suggest a macro? > >> > > >> > >> I don't see how that would clear things up tbh, and the pattern occurs > >> only twice > >> > >> #define IS_OUR_QUIRKY_SDMMC_CONTROLLER(Handle, Slot) \ > >> ((Handle) == mSdMmcControllerHandle && (Slot) == 0) > >> > >> if (!IS_OUR_QUIRKY_SDMMC_CONTROLLER(ControllerHandle, Slot) { > >> return EFI_SUCCESS; > >> } > >> > >> I can change it if you want, or add a comment if the condition is not > >> self-explanatory enough. > > > > It's just an awful lot of logical operations on a single line. > > 'ControllerHandle != mSdMmcControllerHandle' is reasonably easy to > > figure out, but '|| Slot != 0' looks a bit random there. > > > > A comment would be sufficient. > > > > Another option would be to reduce the number of logical operations by > > two by doing > > if (ControllerHandle == mSdMmcControllerHandle && Slot == 0) { > > and doing the body inside the if-statement. > > > > That's a bit uglier in the next function, but I would expect it > > follows the paradigm of "handle most likely case first"? > > > > Actually, come to think of it, the slot number is completely > redundant. The non-discoverable SDHCI controller we expose only > implements a single slot, so something is terribly wrong if > ControllerHandle == mSdMmcControllerHandle && Slot != 0. > > So I will reduce the sequence to > > if (ControllerHandle != mSdMmcControllerHandle) { > return EFI_SUCCESS; > } > > ASSERT (Slot == 0); > > instead. Ok? Sure, that works for me. With that (in both places), and the indentation fix: Reviewed-by: Leif Lindholm