public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: Leif Lindholm <leif.lindholm@linaro.org>
Cc: "edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Subject: Re: [PATCH edk2-platforms] Silicon/Socionext/SynQuacer: add configurable eMMC support
Date: Tue, 30 Jan 2018 13:04:06 +0000	[thread overview]
Message-ID: <CAKv+Gu9ShcZ2GWgB6Dp+x=gn9oCwAw5wrDkSST7J7idcGo+PSg@mail.gmail.com> (raw)
In-Reply-To: <20180130125213.gtyhz2nirprz4gjt@bivouac.eciton.net>

On 30 January 2018 at 12:52, Leif Lindholm <leif.lindholm@linaro.org> wrote:
> 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 <leif.lindholm@linaro.org>

Thanks. Pushed as c733b7ef291f


      reply	other threads:[~2018-01-30 12:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-30 10:32 [PATCH edk2-platforms] Silicon/Socionext/SynQuacer: add configurable eMMC support Ard Biesheuvel
2018-01-30 11:00 ` Leif Lindholm
2018-01-30 11:14   ` Ard Biesheuvel
2018-01-30 11:47     ` Leif Lindholm
2018-01-30 11:52       ` Ard Biesheuvel
2018-01-30 12:52         ` Leif Lindholm
2018-01-30 13:04           ` Ard Biesheuvel [this message]

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-list 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='CAKv+Gu9ShcZ2GWgB6Dp+x=gn9oCwAw5wrDkSST7J7idcGo+PSg@mail.gmail.com' \
    --to=devel@edk2.groups.io \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox