From: Lukas Wunner <lukas@wunner.de>
To: Puranjay Mohan <puranjay12@gmail.com>
Cc: bhelgaas@google.com, linux-pci@vger.kernel.org
Subject: Re: [PATCH 1/2] PCI: Update BAR # and window messages
Date: Sat, 6 Nov 2021 12:58:31 +0100 [thread overview]
Message-ID: <20211106115831.GA7452@wunner.de> (raw)
In-Reply-To: <20211106112606.192563-2-puranjay12@gmail.com>
On Sat, Nov 06, 2021 at 04:56:05PM +0530, Puranjay Mohan wrote:
> + switch (i) {
> + case 0: return "BAR 0";
> + case 1: return "BAR 1";
> + case 2: return "BAR 2";
> + case 3: return "BAR 3";
> + case 4: return "BAR 4";
> + case 5: return "BAR 5";
> + case PCI_ROM_RESOURCE: return "ROM";
> + #ifdef CONFIG_PCI_IOV
> + case PCI_IOV_RESOURCES + 0: return "VF BAR 0";
> + case PCI_IOV_RESOURCES + 1: return "VF BAR 1";
> + case PCI_IOV_RESOURCES + 2: return "VF BAR 2";
> + case PCI_IOV_RESOURCES + 3: return "VF BAR 3";
> + case PCI_IOV_RESOURCES + 4: return "VF BAR 4";
> + case PCI_IOV_RESOURCES + 5: return "VF BAR 5";
> + #endif
> + }
Use a static const array of char * instead of a switch/case ladder
to reduce LoC count and improve performance.
See pcie_to_hpx3_type[] or state_conv[] in drivers/pci/pci-acpi.c
for an example.
Thanks,
Lukas
next prev parent reply other threads:[~2021-11-06 11:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-06 11:26 [PATCH 0/2] PCI: Update BAR #/window messages Puranjay Mohan
2021-11-06 11:26 ` [PATCH 1/2] PCI: Update BAR # and window messages Puranjay Mohan
2021-11-06 11:58 ` Lukas Wunner [this message]
2021-11-19 21:43 ` Bjorn Helgaas
2021-11-24 4:28 ` Lukas Wunner
2021-11-06 11:26 ` [PATCH 2/2] PCI: Use resource names in PCI log messages Puranjay Mohan
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=20211106115831.GA7452@wunner.de \
--to=lukas@wunner.de \
--cc=bhelgaas@google.com \
--cc=linux-pci@vger.kernel.org \
--cc=puranjay12@gmail.com \
/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;
as well as URLs for NNTP newsgroup(s).