Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iommu/omap: Convert to generic_single_device_group()

Use the new helper.

For some reason omap will probe its driver even if it doesn't load an
iommu driver. Keep this working by keeping a bool to track if the iommu
driver was started.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/7-v1-c869a95191f2+5e8-iommu_single_grp_jgg@nvidia.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>

authored by

Jason Gunthorpe and committed by
Joerg Roedel
ebfdc456 8f68911e

+5 -27
+4 -26
drivers/iommu/omap-iommu.c
··· 1225 1225 platform_set_drvdata(pdev, obj); 1226 1226 1227 1227 if (omap_iommu_can_register(pdev)) { 1228 - obj->group = iommu_group_alloc(); 1229 - if (IS_ERR(obj->group)) 1230 - return PTR_ERR(obj->group); 1231 - 1232 1228 err = iommu_device_sysfs_add(&obj->iommu, obj->dev, NULL, 1233 1229 obj->name); 1234 1230 if (err) 1235 - goto out_group; 1231 + return err; 1236 1232 1237 1233 err = iommu_device_register(&obj->iommu, &omap_iommu_ops, &pdev->dev); 1238 1234 if (err) 1239 1235 goto out_sysfs; 1236 + obj->has_iommu_driver = true; 1240 1237 } 1241 1238 1242 1239 pm_runtime_enable(obj->dev); ··· 1249 1252 1250 1253 out_sysfs: 1251 1254 iommu_device_sysfs_remove(&obj->iommu); 1252 - out_group: 1253 - iommu_group_put(obj->group); 1254 1255 return err; 1255 1256 } 1256 1257 ··· 1256 1261 { 1257 1262 struct omap_iommu *obj = platform_get_drvdata(pdev); 1258 1263 1259 - if (obj->group) { 1260 - iommu_group_put(obj->group); 1261 - obj->group = NULL; 1262 - 1264 + if (obj->has_iommu_driver) { 1263 1265 iommu_device_sysfs_remove(&obj->iommu); 1264 1266 iommu_device_unregister(&obj->iommu); 1265 1267 } ··· 1721 1729 1722 1730 } 1723 1731 1724 - static struct iommu_group *omap_iommu_device_group(struct device *dev) 1725 - { 1726 - struct omap_iommu_arch_data *arch_data = dev_iommu_priv_get(dev); 1727 - struct iommu_group *group = ERR_PTR(-EINVAL); 1728 - 1729 - if (!arch_data) 1730 - return ERR_PTR(-ENODEV); 1731 - 1732 - if (arch_data->iommu_dev) 1733 - group = iommu_group_ref_get(arch_data->iommu_dev->group); 1734 - 1735 - return group; 1736 - } 1737 - 1738 1732 static const struct iommu_ops omap_iommu_ops = { 1739 1733 .identity_domain = &omap_iommu_identity_domain, 1740 1734 .domain_alloc_paging = omap_iommu_domain_alloc_paging, 1741 1735 .probe_device = omap_iommu_probe_device, 1742 1736 .release_device = omap_iommu_release_device, 1743 - .device_group = omap_iommu_device_group, 1737 + .device_group = generic_single_device_group, 1744 1738 .pgsize_bitmap = OMAP_IOMMU_PGSIZES, 1745 1739 .default_domain_ops = &(const struct iommu_domain_ops) { 1746 1740 .attach_dev = omap_iommu_attach_dev,
+1 -1
drivers/iommu/omap-iommu.h
··· 80 80 u32 id; 81 81 82 82 struct iommu_device iommu; 83 - struct iommu_group *group; 83 + bool has_iommu_driver; 84 84 85 85 u8 pwrst; 86 86 };