diff options
Diffstat (limited to 'drivers/iommu/omap-iommu.c')
-rw-r--r-- | drivers/iommu/omap-iommu.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 0553b0381e2a..ef44fc740da7 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c | |||
@@ -36,6 +36,8 @@ | |||
36 | #include "omap-iopgtable.h" | 36 | #include "omap-iopgtable.h" |
37 | #include "omap-iommu.h" | 37 | #include "omap-iommu.h" |
38 | 38 | ||
39 | static const struct iommu_ops omap_iommu_ops; | ||
40 | |||
39 | #define to_iommu(dev) \ | 41 | #define to_iommu(dev) \ |
40 | ((struct omap_iommu *)platform_get_drvdata(to_platform_device(dev))) | 42 | ((struct omap_iommu *)platform_get_drvdata(to_platform_device(dev))) |
41 | 43 | ||
@@ -941,6 +943,16 @@ static int omap_iommu_probe(struct platform_device *pdev) | |||
941 | return err; | 943 | return err; |
942 | platform_set_drvdata(pdev, obj); | 944 | platform_set_drvdata(pdev, obj); |
943 | 945 | ||
946 | err = iommu_device_sysfs_add(&obj->iommu, obj->dev, NULL, obj->name); | ||
947 | if (err) | ||
948 | return err; | ||
949 | |||
950 | iommu_device_set_ops(&obj->iommu, &omap_iommu_ops); | ||
951 | |||
952 | err = iommu_device_register(&obj->iommu); | ||
953 | if (err) | ||
954 | goto out_sysfs; | ||
955 | |||
944 | pm_runtime_irq_safe(obj->dev); | 956 | pm_runtime_irq_safe(obj->dev); |
945 | pm_runtime_enable(obj->dev); | 957 | pm_runtime_enable(obj->dev); |
946 | 958 | ||
@@ -948,12 +960,19 @@ static int omap_iommu_probe(struct platform_device *pdev) | |||
948 | 960 | ||
949 | dev_info(&pdev->dev, "%s registered\n", obj->name); | 961 | dev_info(&pdev->dev, "%s registered\n", obj->name); |
950 | return 0; | 962 | return 0; |
963 | |||
964 | out_sysfs: | ||
965 | iommu_device_sysfs_remove(&obj->iommu); | ||
966 | return err; | ||
951 | } | 967 | } |
952 | 968 | ||
953 | static int omap_iommu_remove(struct platform_device *pdev) | 969 | static int omap_iommu_remove(struct platform_device *pdev) |
954 | { | 970 | { |
955 | struct omap_iommu *obj = platform_get_drvdata(pdev); | 971 | struct omap_iommu *obj = platform_get_drvdata(pdev); |
956 | 972 | ||
973 | iommu_device_sysfs_remove(&obj->iommu); | ||
974 | iommu_device_unregister(&obj->iommu); | ||
975 | |||
957 | omap_iommu_debugfs_remove(obj); | 976 | omap_iommu_debugfs_remove(obj); |
958 | 977 | ||
959 | pm_runtime_disable(obj->dev); | 978 | pm_runtime_disable(obj->dev); |
@@ -1200,6 +1219,7 @@ static int omap_iommu_add_device(struct device *dev) | |||
1200 | struct omap_iommu *oiommu; | 1219 | struct omap_iommu *oiommu; |
1201 | struct device_node *np; | 1220 | struct device_node *np; |
1202 | struct platform_device *pdev; | 1221 | struct platform_device *pdev; |
1222 | int ret; | ||
1203 | 1223 | ||
1204 | /* | 1224 | /* |
1205 | * Allocate the archdata iommu structure for DT-based devices. | 1225 | * Allocate the archdata iommu structure for DT-based devices. |
@@ -1232,6 +1252,13 @@ static int omap_iommu_add_device(struct device *dev) | |||
1232 | return -ENOMEM; | 1252 | return -ENOMEM; |
1233 | } | 1253 | } |
1234 | 1254 | ||
1255 | ret = iommu_device_link(&oiommu->iommu, dev); | ||
1256 | if (ret) { | ||
1257 | kfree(arch_data); | ||
1258 | of_node_put(np); | ||
1259 | return ret; | ||
1260 | } | ||
1261 | |||
1235 | arch_data->iommu_dev = oiommu; | 1262 | arch_data->iommu_dev = oiommu; |
1236 | dev->archdata.iommu = arch_data; | 1263 | dev->archdata.iommu = arch_data; |
1237 | 1264 | ||
@@ -1247,8 +1274,11 @@ static void omap_iommu_remove_device(struct device *dev) | |||
1247 | if (!dev->of_node || !arch_data) | 1274 | if (!dev->of_node || !arch_data) |
1248 | return; | 1275 | return; |
1249 | 1276 | ||
1277 | iommu_device_unlink(&arch_data->iommu_dev->iommu, dev); | ||
1278 | |||
1250 | dev->archdata.iommu = NULL; | 1279 | dev->archdata.iommu = NULL; |
1251 | kfree(arch_data); | 1280 | kfree(arch_data); |
1281 | |||
1252 | } | 1282 | } |
1253 | 1283 | ||
1254 | static const struct iommu_ops omap_iommu_ops = { | 1284 | static const struct iommu_ops omap_iommu_ops = { |