From: Heiner Kallweit <hkallweit1@gmail.com>
To: Bjorn Helgaas <bhelgaas@google.com>
Cc: "linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>
Subject: [PATCH 3/3] PCI/VPD: Improve and simplify pci_vpd_find_tag
Date: Thu, 1 Apr 2021 18:44:15 +0200 [thread overview]
Message-ID: <3f63f06f-734f-8fff-9518-27fe1faf903d@gmail.com> (raw)
In-Reply-To: <1a0155ce-6c20-b653-d319-58e6505a1a40@gmail.com>
Only SRDT tag is the end tag, and no caller is interested in it.
This allows to remove all SRDT tag handling.
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
drivers/pci/vpd.c | 31 ++++++-------------------------
1 file changed, 6 insertions(+), 25 deletions(-)
diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c
index 5b80db02d..45f1d73f8 100644
--- a/drivers/pci/vpd.c
+++ b/drivers/pci/vpd.c
@@ -369,33 +369,14 @@ void pci_vpd_release(struct pci_dev *dev)
int pci_vpd_find_tag(const u8 *buf, unsigned int len, u8 rdt)
{
- int i;
-
- for (i = 0; i < len; ) {
- u8 val = buf[i];
-
- if (val & PCI_VPD_LRDT) {
- /* Don't return success of the tag isn't complete */
- if (i + PCI_VPD_LRDT_TAG_SIZE > len)
- break;
+ int i = 0;
- if (val == rdt)
- return i;
-
- i += PCI_VPD_LRDT_TAG_SIZE +
- pci_vpd_lrdt_size(&buf[i]);
- } else {
- u8 tag = val & ~PCI_VPD_SRDT_LEN_MASK;
-
- if (tag == rdt)
- return i;
-
- if (tag == PCI_VPD_SRDT_END)
- break;
+ /* look for LRDT tags only, end tag is the only SRDT tag */
+ while (i + PCI_VPD_LRDT_TAG_SIZE <= len && buf[i] & PCI_VPD_LRDT) {
+ if (buf[i] == rdt)
+ return i;
- i += PCI_VPD_SRDT_TAG_SIZE +
- pci_vpd_srdt_size(&buf[i]);
- }
+ i += PCI_VPD_LRDT_TAG_SIZE + pci_vpd_lrdt_size(buf + i);
}
return -ENOENT;
--
2.31.1
next prev parent reply other threads:[~2021-04-01 18:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-01 16:35 [PATCH 0/3] PCI/VPD: Some improvements Heiner Kallweit
2021-04-01 16:37 ` [PATCH 1/3] PCI/VPD: Change pci_vpd_init return type to void Heiner Kallweit
2021-04-01 16:43 ` [PATCH 2/3] PCI/VPD: Remove argument off from pci_vpd_find_tag Heiner Kallweit
2021-04-01 16:44 ` Heiner Kallweit [this message]
2021-04-01 16:48 ` [PATCH 0/3] PCI/VPD: Some improvements Heiner Kallweit
2021-04-16 19:14 ` Bjorn Helgaas
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=3f63f06f-734f-8fff-9518-27fe1faf903d@gmail.com \
--to=hkallweit1@gmail.com \
--cc=bhelgaas@google.com \
--cc=linux-pci@vger.kernel.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.