iommu/mtk: Constrain return value of ->attach_dev()
Subsystems (3)
PATCH v2 8/13 iommu/mtk: Constrain return value of ->attach_dev()
Ensure attach_dev() callback functions only return errno values expected from the attach_dev() op. In particular, only return -EINVAL when we are sure that the device is incompatible with the domain.
Also drop any dev_err next to -EINVAL, following the attach_dev op kdocs.
Signed-off-by Nicolin Chen <[email protected]>
--- drivers/iommu/mtk_iommu.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/iommu/mtk_iommu.c +7 -2
@@ -655,7 +655,7 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain, region_id =mtk_iommu_get_iova_region_id (dev, data->plat_data);if (region_id <0 ) -return region_id; +return -ENODEV ; bankid =mtk_iommu_get_bank_id (dev, data->plat_data);mutex_lock (&dom->mutex);
@@ -678,12 +678,14 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain, ret =pm_runtime_resume_and_get (m4udev);if (ret <0 ) {dev_err (m4udev,"pm get fail(%d) in attach.\n" , ret); + ret = -ENODEV ; goto err_unlock; } ret =mtk_iommu_hw_init (data, bankid);if (ret) {pm_runtime_put (m4udev); + ret = -ENODEV ; goto err_unlock; } bank->m4u_dom = dom;
@@ -693,7 +695,10 @@ static int mtk_iommu_attach_device(struct iommu_domain *domain, }mutex_unlock (&data->mutex); -return mtk_iommu_config (data, dev, true, region_id); + ret =mtk_iommu_config (data, dev, true, region_id); +if (ret) + ret = -ENODEV ; +return ret; err_unlock:mutex_unlock (&data->mutex);
Signature · 1 line
2.17.1