@@ -1640,15 +1640,13 @@ static phys_addr_t omap_iommu_iova_to_phys(struct iommu_domain *domain,
1640
1640
return ret ;
1641
1641
}
1642
1642
1643
- static int omap_iommu_add_device (struct device * dev )
1643
+ static struct iommu_device * omap_iommu_probe_device (struct device * dev )
1644
1644
{
1645
1645
struct omap_iommu_arch_data * arch_data , * tmp ;
1646
+ struct platform_device * pdev ;
1646
1647
struct omap_iommu * oiommu ;
1647
- struct iommu_group * group ;
1648
1648
struct device_node * np ;
1649
- struct platform_device * pdev ;
1650
1649
int num_iommus , i ;
1651
- int ret ;
1652
1650
1653
1651
/*
1654
1652
* Allocate the archdata iommu structure for DT-based devices.
@@ -1657,7 +1655,7 @@ static int omap_iommu_add_device(struct device *dev)
1657
1655
* IOMMU users.
1658
1656
*/
1659
1657
if (!dev -> of_node )
1660
- return 0 ;
1658
+ return ERR_PTR ( - ENODEV ) ;
1661
1659
1662
1660
/*
1663
1661
* retrieve the count of IOMMU nodes using phandle size as element size
@@ -1670,27 +1668,27 @@ static int omap_iommu_add_device(struct device *dev)
1670
1668
1671
1669
arch_data = kcalloc (num_iommus + 1 , sizeof (* arch_data ), GFP_KERNEL );
1672
1670
if (!arch_data )
1673
- return - ENOMEM ;
1671
+ return ERR_PTR ( - ENOMEM ) ;
1674
1672
1675
1673
for (i = 0 , tmp = arch_data ; i < num_iommus ; i ++ , tmp ++ ) {
1676
1674
np = of_parse_phandle (dev -> of_node , "iommus" , i );
1677
1675
if (!np ) {
1678
1676
kfree (arch_data );
1679
- return - EINVAL ;
1677
+ return ERR_PTR ( - EINVAL ) ;
1680
1678
}
1681
1679
1682
1680
pdev = of_find_device_by_node (np );
1683
1681
if (!pdev ) {
1684
1682
of_node_put (np );
1685
1683
kfree (arch_data );
1686
- return - ENODEV ;
1684
+ return ERR_PTR ( - ENODEV ) ;
1687
1685
}
1688
1686
1689
1687
oiommu = platform_get_drvdata (pdev );
1690
1688
if (!oiommu ) {
1691
1689
of_node_put (np );
1692
1690
kfree (arch_data );
1693
- return - EINVAL ;
1691
+ return ERR_PTR ( - EINVAL ) ;
1694
1692
}
1695
1693
1696
1694
tmp -> iommu_dev = oiommu ;
@@ -1699,46 +1697,25 @@ static int omap_iommu_add_device(struct device *dev)
1699
1697
of_node_put (np );
1700
1698
}
1701
1699
1700
+ dev -> archdata .iommu = arch_data ;
1701
+
1702
1702
/*
1703
1703
* use the first IOMMU alone for the sysfs device linking.
1704
1704
* TODO: Evaluate if a single iommu_group needs to be
1705
1705
* maintained for both IOMMUs
1706
1706
*/
1707
1707
oiommu = arch_data -> iommu_dev ;
1708
- ret = iommu_device_link (& oiommu -> iommu , dev );
1709
- if (ret ) {
1710
- kfree (arch_data );
1711
- return ret ;
1712
- }
1713
-
1714
- dev -> archdata .iommu = arch_data ;
1715
-
1716
- /*
1717
- * IOMMU group initialization calls into omap_iommu_device_group, which
1718
- * needs a valid dev->archdata.iommu pointer
1719
- */
1720
- group = iommu_group_get_for_dev (dev );
1721
- if (IS_ERR (group )) {
1722
- iommu_device_unlink (& oiommu -> iommu , dev );
1723
- dev -> archdata .iommu = NULL ;
1724
- kfree (arch_data );
1725
- return PTR_ERR (group );
1726
- }
1727
- iommu_group_put (group );
1728
1708
1729
- return 0 ;
1709
+ return & oiommu -> iommu ;
1730
1710
}
1731
1711
1732
- static void omap_iommu_remove_device (struct device * dev )
1712
+ static void omap_iommu_release_device (struct device * dev )
1733
1713
{
1734
1714
struct omap_iommu_arch_data * arch_data = dev -> archdata .iommu ;
1735
1715
1736
1716
if (!dev -> of_node || !arch_data )
1737
1717
return ;
1738
1718
1739
- iommu_device_unlink (& arch_data -> iommu_dev -> iommu , dev );
1740
- iommu_group_remove_device (dev );
1741
-
1742
1719
dev -> archdata .iommu = NULL ;
1743
1720
kfree (arch_data );
1744
1721
@@ -1763,8 +1740,8 @@ static const struct iommu_ops omap_iommu_ops = {
1763
1740
.map = omap_iommu_map ,
1764
1741
.unmap = omap_iommu_unmap ,
1765
1742
.iova_to_phys = omap_iommu_iova_to_phys ,
1766
- .add_device = omap_iommu_add_device ,
1767
- .remove_device = omap_iommu_remove_device ,
1743
+ .probe_device = omap_iommu_probe_device ,
1744
+ .release_device = omap_iommu_release_device ,
1768
1745
.device_group = omap_iommu_device_group ,
1769
1746
.pgsize_bitmap = OMAP_IOMMU_PGSIZES ,
1770
1747
};
0 commit comments