diff mbox

[v8,12/12] iommu/exynos: return 0 if iommu_attach_device() successes

Message ID 004201ce89f3$9b849a20$d28dce60$@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Cho KyongHo July 26, 2013, 11:31 a.m. UTC
iommu_attach_device() against exynos-iommu positive integer on success
if the caller calls iommu_attach_device() with the same iommu_domain
multiple times without call to iommu_detach_device() to inform the
caller how many calls to iommu_detach_device() to really detach iommu.

However the convention of the return value of success of common API is
zero, this patch makes iommu_attach_device() call against exynos-iommu
always return zero if the given device is successfully attached to
the given iommu_domain even though it is already attached to the same
iommu_domain.

Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
---
 drivers/iommu/exynos-iommu.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

Comments

Grant Grundler July 26, 2013, 5:23 p.m. UTC | #1
On Fri, Jul 26, 2013 at 4:31 AM, Cho KyongHo <pullip.cho@samsung.com> wrote:
> iommu_attach_device() against exynos-iommu positive integer on success
> if the caller calls iommu_attach_device() with the same iommu_domain
> multiple times without call to iommu_detach_device() to inform the
> caller how many calls to iommu_detach_device() to really detach iommu.
>
> However the convention of the return value of success of common API is
> zero, this patch makes iommu_attach_device() call against exynos-iommu
> always return zero if the given device is successfully attached to
> the given iommu_domain even though it is already attached to the same
> iommu_domain.
>
> Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>

Reviewed-by: Grant Grundler <grundler@chromium.org>

cheers,
grant

> ---
>  drivers/iommu/exynos-iommu.c |   13 +++++++------
>  1 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
> index 51e5b35..6eed6d6 100644
> --- a/drivers/iommu/exynos-iommu.c
> +++ b/drivers/iommu/exynos-iommu.c
> @@ -882,15 +882,16 @@ static int exynos_iommu_attach_device(struct iommu_domain *domain,
>
>         spin_unlock_irqrestore(&priv->lock, flags);
>
> -       if (ret < 0)
> +       if (ret < 0) {
>                 dev_err(dev, "%s: Failed to attach IOMMU with pgtable %#lx\n",
>                                 __func__, __pa(priv->pgtable));
> -       else
> -               dev_dbg(dev, "%s: Attached IOMMU with pgtable 0x%lx%s\n",
> -                                       __func__, __pa(priv->pgtable),
> -                                       (ret == 0) ? "" : ", again");
> +               return ret;
> +       }
>
> -       return ret;
> +       dev_dbg(dev, "%s: Attached IOMMU with pgtable 0x%lx%s\n",
> +               __func__, __pa(priv->pgtable), (ret == 0) ? "" : ", again");
> +
> +       return 0;
>  }
>
>  static void exynos_iommu_detach_device(struct iommu_domain *domain,
> --
> 1.7.2.5
>
>
diff mbox

Patch

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index 51e5b35..6eed6d6 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -882,15 +882,16 @@  static int exynos_iommu_attach_device(struct iommu_domain *domain,
 
 	spin_unlock_irqrestore(&priv->lock, flags);
 
-	if (ret < 0)
+	if (ret < 0) {
 		dev_err(dev, "%s: Failed to attach IOMMU with pgtable %#lx\n",
 				__func__, __pa(priv->pgtable));
-	else
-		dev_dbg(dev, "%s: Attached IOMMU with pgtable 0x%lx%s\n",
-					__func__, __pa(priv->pgtable),
-					(ret == 0) ? "" : ", again");
+		return ret;
+	}
 
-	return ret;
+	dev_dbg(dev, "%s: Attached IOMMU with pgtable 0x%lx%s\n",
+		__func__, __pa(priv->pgtable), (ret == 0) ? "" : ", again");
+
+	return 0;
 }
 
 static void exynos_iommu_detach_device(struct iommu_domain *domain,