]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
iommu/riscv: Simplify maximum determination in riscv_iommu_init_check()
authorMarkus Elfring <elfring@users.sourceforge.net>
Mon, 26 Jan 2026 04:09:52 +0000 (21:09 -0700)
committerPaul Walmsley <pjw@kernel.org>
Mon, 26 Jan 2026 04:09:52 +0000 (21:09 -0700)
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@users.sourceforge.net>
Link: https://patch.msgid.link/d1a384c9-f154-4537-94d6-c3613f4167bc@web.de
Signed-off-by: Paul Walmsley <pjw@kernel.org>
drivers/iommu/riscv/iommu.c

index d9429097a2b51bc2ec5283333b1aa1df14c1fad1..2d8fb0859f30fc938ca797f72300ea8279301c02 100644 (file)
@@ -1593,10 +1593,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;