[PATCH 2/2] iommu/amd: Return a literal in init_gcr3_table()

Dan Carpenter posted 2 patches 9 months ago
[PATCH 2/2] iommu/amd: Return a literal in init_gcr3_table()
Posted by Dan Carpenter 9 months ago
This code intentionally returns zero but it does it as "return ret;"
Returning ret looks like an error path where return 0 is more
clear and looks more intentional.

Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 drivers/iommu/amd/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
index ce2626801ddf..7cbcc4933c8b 100644
--- a/drivers/iommu/amd/iommu.c
+++ b/drivers/iommu/amd/iommu.c
@@ -2150,7 +2150,7 @@ static int init_gcr3_table(struct iommu_dev_data *dev_data,
 
 	/* Setup GCR3[0] only if domain is setup with v2 page table mode */
 	if (!pdom_is_v2_pgtbl_mode(pdom))
-		return ret;
+		return 0;
 
 	ret = update_gcr3(dev_data, 0, iommu_virt_to_phys(pdom->iop.pgd), true);
 	if (ret)
-- 
2.47.2
Re: [PATCH 2/2] iommu/amd: Return a literal in init_gcr3_table()
Posted by Joerg Roedel 9 months ago
On Mon, Mar 17, 2025 at 09:43:32AM +0300, Dan Carpenter wrote:
> This code intentionally returns zero but it does it as "return ret;"
> Returning ret looks like an error path where return 0 is more
> clear and looks more intentional.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
>  drivers/iommu/amd/iommu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index ce2626801ddf..7cbcc4933c8b 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -2150,7 +2150,7 @@ static int init_gcr3_table(struct iommu_dev_data *dev_data,
>  
>  	/* Setup GCR3[0] only if domain is setup with v2 page table mode */
>  	if (!pdom_is_v2_pgtbl_mode(pdom))
> -		return ret;
> +		return 0;

There is another case of this a couple lines above in the same function.
Mind changing that as well?

Regards,

	Joerg
Re: [PATCH 2/2] iommu/amd: Return a literal in init_gcr3_table()
Posted by Dan Carpenter 9 months ago
On Thu, Mar 20, 2025 at 09:03:05AM +0100, Joerg Roedel wrote:
> On Mon, Mar 17, 2025 at 09:43:32AM +0300, Dan Carpenter wrote:
> > This code intentionally returns zero but it does it as "return ret;"
> > Returning ret looks like an error path where return 0 is more
> > clear and looks more intentional.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> > ---
> >  drivers/iommu/amd/iommu.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> > index ce2626801ddf..7cbcc4933c8b 100644
> > --- a/drivers/iommu/amd/iommu.c
> > +++ b/drivers/iommu/amd/iommu.c
> > @@ -2150,7 +2150,7 @@ static int init_gcr3_table(struct iommu_dev_data *dev_data,
> >  
> >  	/* Setup GCR3[0] only if domain is setup with v2 page table mode */
> >  	if (!pdom_is_v2_pgtbl_mode(pdom))
> > -		return ret;
> > +		return 0;
> 
> There is another case of this a couple lines above in the same function.
> Mind changing that as well?

Thanks.  Happy to.  I'll resend.

regards,
dan carpenter