From: "David E. Box" <david.e.box@linux.intel.com>
To: linux-kernel@vger.kernel.org,
platform-driver-x86@vger.kernel.org, david.e.box@linux.intel.com,
srinivas.pandruvada@linux.intel.com,
andriy.shevchenko@linux.intel.com, ilpo.jarvinen@linux.intel.com,
tony.luck@intel.com, xi.pardee@linux.intel.com
Cc: hdegoede@redhat.com
Subject: [PATCH V3 03/15] platform/x86/intel/vsec: Create wrapper to walk PCI config space
Date: Wed, 2 Jul 2025 19:28:18 -0700 [thread overview]
Message-ID: <20250703022832.1302928-4-david.e.box@linux.intel.com> (raw)
In-Reply-To: <20250703022832.1302928-1-david.e.box@linux.intel.com>
Combine three PCI config space walkers — intel_vsec_walk_dvsec(),
intel_vsec_walk_vsec(), and intel_vsec_walk_header() — into a new wrapper
function, intel_vsec_feature_walk(). This refactoring simplifies the probe
logic and lays the groundwork for future patches that will loop over these
calls. No functional changes.
Signed-off-by: David E. Box <david.e.box@linux.intel.com>
---
Changes in v3:
- Rename intel_vsec_feature_walk() to intel_vsec_get_features() and
have it return bool instead of passing as an argument
Changes in v2:
- No changes
drivers/platform/x86/intel/vsec.c | 38 +++++++++++++++++++++----------
1 file changed, 26 insertions(+), 12 deletions(-)
diff --git a/drivers/platform/x86/intel/vsec.c b/drivers/platform/x86/intel/vsec.c
index 59fb6568a855..8bdb74d86f24 100644
--- a/drivers/platform/x86/intel/vsec.c
+++ b/drivers/platform/x86/intel/vsec.c
@@ -349,11 +349,35 @@ int intel_vsec_register(struct pci_dev *pdev,
}
EXPORT_SYMBOL_NS_GPL(intel_vsec_register, "INTEL_VSEC");
+static bool intel_vsec_get_features(struct pci_dev *pdev,
+ struct intel_vsec_platform_info *info)
+{
+ bool found = false;
+
+ /*
+ * Both DVSEC and VSEC capabilities can exist on the same device,
+ * so both intel_vsec_walk_dvsec() and intel_vsec_walk_vsec() must be
+ * called independently. Additionally, intel_vsec_walk_header() is
+ * needed for devices that do not have VSEC/DVSEC but provide the
+ * information via device_data.
+ */
+ if (intel_vsec_walk_dvsec(pdev, info))
+ found = true;
+
+ if (intel_vsec_walk_vsec(pdev, info))
+ found = true;
+
+ if (info && (info->quirks & VSEC_QUIRK_NO_DVSEC) &&
+ intel_vsec_walk_header(pdev, info))
+ found = true;
+
+ return found;
+}
+
static int intel_vsec_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct intel_vsec_platform_info *info;
struct vsec_priv *priv;
- bool have_devices = false;
int ret;
ret = pcim_enable_device(pdev);
@@ -372,17 +396,7 @@ static int intel_vsec_pci_probe(struct pci_dev *pdev, const struct pci_device_id
priv->info = info;
pci_set_drvdata(pdev, priv);
- if (intel_vsec_walk_dvsec(pdev, info))
- have_devices = true;
-
- if (intel_vsec_walk_vsec(pdev, info))
- have_devices = true;
-
- if (info && (info->quirks & VSEC_QUIRK_NO_DVSEC) &&
- intel_vsec_walk_header(pdev, info))
- have_devices = true;
-
- if (!have_devices)
+ if (!intel_vsec_get_features(pdev, info))
return -ENODEV;
return 0;
--
2.43.0
next prev parent reply other threads:[~2025-07-03 2:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-03 2:28 [PATCH V3 00/15] Intel VSEC/PMT: Introduce Discovery Driver David E. Box
2025-07-03 2:28 ` [PATCH V3 01/15] MAINTAINERS: Add link to documentation of Intel PMT ABI David E. Box
2025-07-03 2:28 ` [PATCH V3 02/15] platform/x86/intel/vsec: Add private data for per-device data David E. Box
2025-07-03 2:28 ` David E. Box [this message]
2025-07-03 2:28 ` [PATCH V3 04/15] platform/x86/intel/vsec: Add device links to enforce dependencies David E. Box
2025-07-03 2:28 ` [PATCH V3 05/15] platform/x86/intel/vsec: Skip absent features during initialization David E. Box
2025-07-03 2:28 ` [PATCH V3 06/15] platform/x86/intel/vsec: Skip driverless features David E. Box
2025-07-03 2:28 ` [PATCH V3 07/15] platform/x86/intel/vsec: Add new Discovery feature David E. Box
2025-07-03 2:28 ` [PATCH V3 08/15] platform/x86/intel/pmt: Add PMT Discovery driver David E. Box
2025-07-03 2:28 ` [PATCH V3 09/15] docs: Add ABI documentation for intel_pmt feature directories David E. Box
2025-07-03 2:28 ` [PATCH V3 10/15] platform/x86/intel/tpmi: Relocate platform info to intel_vsec.h David E. Box
2025-07-03 2:28 ` [PATCH V3 11/15] platform/x86/intel/vsec: Set OOBMSM to CPU mapping David E. Box
2025-07-03 2:28 ` [PATCH V3 12/15] platform/x86/intel/tpmi: Get OOBMSM CPU mapping from TPMI David E. Box
2025-07-03 2:28 ` [PATCH V3 13/15] platform/x86/intel/pmt/discovery: Get telemetry attributes David E. Box
2025-07-03 2:28 ` [PATCH V3 14/15] platform/x86/intel/pmt/telemetry: Add API to retrieve telemetry regions by feature David E. Box
2025-07-03 2:28 ` [PATCH V3 15/15] platform/x86/intel/pmt: KUNIT test for PMT Enhanced Discovery API David E. Box
2025-07-03 8:10 ` [PATCH V3 00/15] Intel VSEC/PMT: Introduce Discovery Driver Ilpo Järvinen
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=20250703022832.1302928-4-david.e.box@linux.intel.com \
--to=david.e.box@linux.intel.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=tony.luck@intel.com \
--cc=xi.pardee@linux.intel.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
all inboxes | Powered by JetHome®