[PATCH v2 19/19] platform/x86/intel/tpmi: Describe the device creation policy on the function
From: Kuppuswamy Sathyanarayanan
Date: Thu Sep 24 2026 - 14:33:06 EST
The comment explaining the error policy of tpmi_create_devices() sits
inside the loop, between the call and the check it describes. Move it
above the function, where it describes the policy as a whole.
Also split the check into its two cases, skipping unsupported features
and failing on any other error, so that each reads on its own.
No functional change intended.
Suggested-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxx>
Suggested-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>
Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@xxxxxxxxxxxxxxx>
---
drivers/platform/x86/intel/tpmi_common.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/drivers/platform/x86/intel/tpmi_common.c b/drivers/platform/x86/intel/tpmi_common.c
index 0ef2642bd920..9a650053de0a 100644
--- a/drivers/platform/x86/intel/tpmi_common.c
+++ b/drivers/platform/x86/intel/tpmi_common.c
@@ -603,6 +603,14 @@ static int tpmi_create_device(struct intel_tpmi_info *tpmi_info,
return intel_vsec_add_aux(tpmi_info->tpmi_dev, feature_vsec_dev, name);
}
+/*
+ * Create a device for every feature in the PFS that has one.
+ *
+ * A feature that is not supported is reported as -EOPNOTSUPP and skipped.
+ * Any other error fails the driver load. intel_vsec_add_aux() is resource
+ * managed, so the devices created before such a failure need no clean up
+ * here.
+ */
static int tpmi_create_devices(struct intel_tpmi_info *tpmi_info)
{
int ret;
@@ -610,14 +618,9 @@ static int tpmi_create_devices(struct intel_tpmi_info *tpmi_info)
for (int i = 0; i < tpmi_info->feature_count; i++) {
ret = tpmi_create_device(tpmi_info, &tpmi_info->tpmi_features[i],
tpmi_info->pfs_start);
- /*
- * Fail, if the supported features fails to create device,
- * otherwise, continue. Even if one device failed to create,
- * fail the loading of driver. Since intel_vsec_add_aux()
- * is resource managed, no clean up is required for the
- * successfully created devices.
- */
- if (ret && ret != -EOPNOTSUPP)
+ if (ret == -EOPNOTSUPP)
+ continue;
+ if (ret)
return ret;
}
--
2.43.0