[PATCH v10 02/18] virt: coco: tsm: Require PCI operations when registering a TSM
Aneesh Kumar K.V (Arm)
aneesh.kumar at kernel.org
Wed Nov 25 00:11:05 PST 2026
Reject a NULL pci_ops argument in tsm_register(). Every registered TSM
now has PCI operations, so registration no longer needs separate paths
for TSMs without them.
Registration guarantees pci_ops is set, so call pci_tsm_unregister()
without testing that pointer again.
Cc: Alexey Kardashevskiy <aik at amd.com>
Cc: Jason Gunthorpe <jgg at ziepe.ca>
Cc: Lukas Wunner <lukas at wunner.de>
Cc: linux-coco at lists.linux.dev
Reviewed-by: Lu Baolu <baolu.lu at linux.intel.com>
Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar at kernel.org>
---
drivers/virt/coco/tsm-core.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/virt/coco/tsm-core.c b/drivers/virt/coco/tsm-core.c
index e784993353d8..3e45b58183e2 100644
--- a/drivers/virt/coco/tsm-core.c
+++ b/drivers/virt/coco/tsm-core.c
@@ -61,9 +61,6 @@ static struct tsm_dev *tsm_register_pci_or_reset(struct tsm_dev *tsm_dev,
{
int rc;
- if (!pci_ops)
- return tsm_dev;
-
tsm_dev->pci_ops = pci_ops;
rc = pci_tsm_register(tsm_dev);
if (rc) {
@@ -84,6 +81,9 @@ struct tsm_dev *tsm_register(struct device *parent, struct pci_tsm_ops *pci_ops)
struct device *dev;
int rc;
+ if (!pci_ops)
+ return ERR_PTR(-EINVAL);
+
if (IS_ERR(tsm_dev))
return tsm_dev;
@@ -102,8 +102,7 @@ EXPORT_SYMBOL_GPL(tsm_register);
void tsm_unregister(struct tsm_dev *tsm_dev)
{
- if (tsm_dev->pci_ops)
- pci_tsm_unregister(tsm_dev);
+ pci_tsm_unregister(tsm_dev);
device_unregister(&tsm_dev->dev);
}
EXPORT_SYMBOL_GPL(tsm_unregister);
--
2.43.0
More information about the linux-arm-kernel
mailing list