[<prev] [next>] [day] [month] [year] [list]
Message-ID: <d1a384c9-f154-4537-94d6-c3613f4167bc@web.de>
Date: Fri, 28 Feb 2025 19:02:43 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: linux-riscv@...ts.infradead.org, iommu@...ts.linux.dev,
Albert Ou <aou@...s.berkeley.edu>, Alexandre Ghiti <alex@...ti.fr>,
Jörg Rödel <joro@...tes.org>,
Palmer Dabbelt <palmer@...belt.com>, Paul Walmsley
<paul.walmsley@...ive.com>, Robin Murphy <robin.murphy@....com>,
Tomasz Jeznach <tjeznach@...osinc.com>, Will Deacon <will@...nel.org>
Cc: LKML <linux-kernel@...r.kernel.org>, kernel-janitors@...r.kernel.org,
Qasim Ijaz <qasdev00@...il.com>
Subject: [PATCH] iommu/riscv: Simplify maximum determination in
riscv_iommu_init_check()
From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Fri, 28 Feb 2025 18:56:00 +0100
Reduce nested max() calls by a single max3() call in this
function implementation.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
drivers/iommu/riscv/iommu.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/iommu/riscv/iommu.c b/drivers/iommu/riscv/iommu.c
index 8f049d4a0e2c..31d20016a0df 100644
--- a/drivers/iommu/riscv/iommu.c
+++ b/drivers/iommu/riscv/iommu.c
@@ -1588,10 +1588,10 @@ static int riscv_iommu_init_check(struct riscv_iommu_device *iommu)
FIELD_PREP(RISCV_IOMMU_ICVEC_PMIV, 3 % iommu->irqs_count);
riscv_iommu_writeq(iommu, RISCV_IOMMU_REG_ICVEC, iommu->icvec);
iommu->icvec = riscv_iommu_readq(iommu, RISCV_IOMMU_REG_ICVEC);
- if (max(max(FIELD_GET(RISCV_IOMMU_ICVEC_CIV, iommu->icvec),
- FIELD_GET(RISCV_IOMMU_ICVEC_FIV, iommu->icvec)),
- max(FIELD_GET(RISCV_IOMMU_ICVEC_PIV, iommu->icvec),
- FIELD_GET(RISCV_IOMMU_ICVEC_PMIV, iommu->icvec))) >= iommu->irqs_count)
+ if (max3(FIELD_GET(RISCV_IOMMU_ICVEC_CIV, iommu->icvec),
+ FIELD_GET(RISCV_IOMMU_ICVEC_FIV, iommu->icvec),
+ max(FIELD_GET(RISCV_IOMMU_ICVEC_PIV, iommu->icvec),
+ FIELD_GET(RISCV_IOMMU_ICVEC_PMIV, iommu->icvec))) >= iommu->irqs_count)
return -EINVAL;
return 0;
--
2.48.1
Powered by blists - more mailing lists