[PATCH v8 04/15] virt: coco: tsm: Require PCI operations when registering a TSM

From: Aneesh Kumar K.V (Arm)

Date: Wed Nov 04 2026 - 11:31:25 EST


Reject a NULL pci_ops argument in tsm_register(). Every registered TSM
then has PCI operations, so registration no longer needs separate paths
for TSMs without them.

Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@xxxxxxxxxx>
---
drivers/virt/coco/tsm-core.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/virt/coco/tsm-core.c b/drivers/virt/coco/tsm-core.c
index e370806d8436..e7807dc94807 100644
--- a/drivers/virt/coco/tsm-core.c
+++ b/drivers/virt/coco/tsm-core.c
@@ -60,9 +60,6 @@ static int tsm_register_pci(struct tsm_dev *tsm_dev, struct pci_tsm_ops *pci_ops
{
int rc;

- if (!pci_ops)
- return 0;
-
tsm_dev->pci_ops = pci_ops;
rc = pci_tsm_register(tsm_dev);
if (rc) {
@@ -80,6 +77,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;

@@ -95,14 +95,12 @@ struct tsm_dev *tsm_register(struct device *parent, struct pci_tsm_ops *pci_ops)

rc = device_add(dev);
if (rc) {
- if (pci_ops)
- pci_tsm_unregister(tsm_dev);
+ pci_tsm_unregister(tsm_dev);
return ERR_PTR(rc);
}

/* Notify TSM userspace that PCI/TSM operations are now possible. */
- if (pci_ops)
- kobject_uevent(&dev->kobj, KOBJ_CHANGE);
+ kobject_uevent(&dev->kobj, KOBJ_CHANGE);

return no_free_ptr(tsm_dev);
}
--
2.43.0