@@ -865,24 +865,23 @@ static struct viommu_dev *viommu_get_by_fwnode(struct fwnode_handle *fwnode)
865
865
return dev ? dev_to_virtio (dev )-> priv : NULL ;
866
866
}
867
867
868
- static int viommu_add_device (struct device * dev )
868
+ static struct iommu_device * viommu_probe_device (struct device * dev )
869
869
{
870
870
int ret ;
871
- struct iommu_group * group ;
872
871
struct viommu_endpoint * vdev ;
873
872
struct viommu_dev * viommu = NULL ;
874
873
struct iommu_fwspec * fwspec = dev_iommu_fwspec_get (dev );
875
874
876
875
if (!fwspec || fwspec -> ops != & viommu_ops )
877
- return - ENODEV ;
876
+ return ERR_PTR ( - ENODEV ) ;
878
877
879
878
viommu = viommu_get_by_fwnode (fwspec -> iommu_fwnode );
880
879
if (!viommu )
881
- return - ENODEV ;
880
+ return ERR_PTR ( - ENODEV ) ;
882
881
883
882
vdev = kzalloc (sizeof (* vdev ), GFP_KERNEL );
884
883
if (!vdev )
885
- return - ENOMEM ;
884
+ return ERR_PTR ( - ENOMEM ) ;
886
885
887
886
vdev -> dev = dev ;
888
887
vdev -> viommu = viommu ;
@@ -896,45 +895,25 @@ static int viommu_add_device(struct device *dev)
896
895
goto err_free_dev ;
897
896
}
898
897
899
- ret = iommu_device_link (& viommu -> iommu , dev );
900
- if (ret )
901
- goto err_free_dev ;
898
+ return & viommu -> iommu ;
902
899
903
- /*
904
- * Last step creates a default domain and attaches to it. Everything
905
- * must be ready.
906
- */
907
- group = iommu_group_get_for_dev (dev );
908
- if (IS_ERR (group )) {
909
- ret = PTR_ERR (group );
910
- goto err_unlink_dev ;
911
- }
912
-
913
- iommu_group_put (group );
914
-
915
- return PTR_ERR_OR_ZERO (group );
916
-
917
- err_unlink_dev :
918
- iommu_device_unlink (& viommu -> iommu , dev );
919
900
err_free_dev :
920
901
generic_iommu_put_resv_regions (dev , & vdev -> resv_regions );
921
902
kfree (vdev );
922
903
923
- return ret ;
904
+ return ERR_PTR ( ret ) ;
924
905
}
925
906
926
- static void viommu_remove_device (struct device * dev )
907
+ static void viommu_release_device (struct device * dev )
927
908
{
928
- struct viommu_endpoint * vdev ;
929
909
struct iommu_fwspec * fwspec = dev_iommu_fwspec_get (dev );
910
+ struct viommu_endpoint * vdev ;
930
911
931
912
if (!fwspec || fwspec -> ops != & viommu_ops )
932
913
return ;
933
914
934
915
vdev = dev_iommu_priv_get (dev );
935
916
936
- iommu_group_remove_device (dev );
937
- iommu_device_unlink (& vdev -> viommu -> iommu , dev );
938
917
generic_iommu_put_resv_regions (dev , & vdev -> resv_regions );
939
918
kfree (vdev );
940
919
}
@@ -960,8 +939,8 @@ static struct iommu_ops viommu_ops = {
960
939
.unmap = viommu_unmap ,
961
940
.iova_to_phys = viommu_iova_to_phys ,
962
941
.iotlb_sync = viommu_iotlb_sync ,
963
- .add_device = viommu_add_device ,
964
- .remove_device = viommu_remove_device ,
942
+ .probe_device = viommu_probe_device ,
943
+ .release_device = viommu_release_device ,
965
944
.device_group = viommu_device_group ,
966
945
.get_resv_regions = viommu_get_resv_regions ,
967
946
.put_resv_regions = generic_iommu_put_resv_regions ,
0 commit comments