Commit 48a7c508 authored by Robin Murphy's avatar Robin Murphy Committed by Joerg Roedel
Browse files

iommu/tegra-smmu: Clean up bus_set_iommu()



Stop calling bus_set_iommu() since it's now unnecessary, and simplify
the probe failure path accordingly.

Signed-off-by: default avatarRobin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/13bb6baa6c4d74e95a12529e4eb1ddfb3885c3b5.1660572783.git.robin.murphy@arm.com


Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent a2409086
Loading
Loading
Loading
Loading
+6 −23
Original line number Diff line number Diff line
@@ -1083,8 +1083,8 @@ struct tegra_smmu *tegra_smmu_probe(struct device *dev,

	/*
	 * This is a bit of a hack. Ideally we'd want to simply return this
	 * value. However the IOMMU registration process will attempt to add
	 * all devices to the IOMMU when bus_set_iommu() is called. In order
	 * value. However iommu_device_register() will attempt to add
	 * all devices to the IOMMU before we get that far. In order
	 * not to rely on global variables to track the IOMMU instance, we
	 * set it here so that it can be looked up from the .probe_device()
	 * callback via the IOMMU device's .drvdata field.
@@ -1138,32 +1138,15 @@ struct tegra_smmu *tegra_smmu_probe(struct device *dev,
		return ERR_PTR(err);

	err = iommu_device_register(&smmu->iommu, &tegra_smmu_ops, dev);
	if (err)
		goto remove_sysfs;

	err = bus_set_iommu(&platform_bus_type, &tegra_smmu_ops);
	if (err < 0)
		goto unregister;

#ifdef CONFIG_PCI
	err = bus_set_iommu(&pci_bus_type, &tegra_smmu_ops);
	if (err < 0)
		goto unset_platform_bus;
#endif
	if (err) {
		iommu_device_sysfs_remove(&smmu->iommu);
		return ERR_PTR(err);
	}

	if (IS_ENABLED(CONFIG_DEBUG_FS))
		tegra_smmu_debugfs_init(smmu);

	return smmu;

unset_platform_bus: __maybe_unused;
	bus_set_iommu(&platform_bus_type, NULL);
unregister:
	iommu_device_unregister(&smmu->iommu);
remove_sysfs:
	iommu_device_sysfs_remove(&smmu->iommu);

	return ERR_PTR(err);
}

void tegra_smmu_remove(struct tegra_smmu *smmu)