Skip to content

Commit 54e7d90

Browse files
krzkjoergroedel
authored andcommitted
iommu: Use str_enable_disable-like helpers
Replace ternary (condition ? "enable" : "disable") syntax with helpers from string_choices.h because: 1. Simple function call with one argument is easier to read. Ternary operator has three arguments and with wrapping might lead to quite long code. 2. Is slightly shorter thus also easier to read. 3. It brings uniformity in the text - same string. 4. Allows deduping by the linker, which results in a smaller binary file. Signed-off-by: Krzysztof Kozlowski <[email protected]> Acked-by: Heiko Stuebner <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Acked-by: Pranjal Shrivastava <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Joerg Roedel <[email protected]>
1 parent 647b7aa commit 54e7d90

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/pci.h>
2727
#include <linux/pci-ats.h>
2828
#include <linux/platform_device.h>
29+
#include <linux/string_choices.h>
2930
#include <kunit/visibility.h>
3031
#include <uapi/linux/iommufd.h>
3132

@@ -4239,7 +4240,7 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
42394240
*/
42404241
if (!!(reg & IDR0_COHACC) != coherent)
42414242
dev_warn(smmu->dev, "IDR0.COHACC overridden by FW configuration (%s)\n",
4242-
coherent ? "true" : "false");
4243+
str_true_false(coherent));
42434244

42444245
switch (FIELD_GET(IDR0_STALL_MODEL, reg)) {
42454246
case IDR0_STALL_MODEL_FORCE:

drivers/iommu/arm/arm-smmu/arm-smmu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/pm_runtime.h>
3535
#include <linux/ratelimit.h>
3636
#include <linux/slab.h>
37+
#include <linux/string_choices.h>
3738

3839
#include <linux/fsl/mc.h>
3940

@@ -2117,7 +2118,7 @@ static void arm_smmu_rmr_install_bypass_smr(struct arm_smmu_device *smmu)
21172118
}
21182119

21192120
dev_notice(smmu->dev, "\tpreserved %d boot mapping%s\n", cnt,
2120-
cnt == 1 ? "" : "s");
2121+
str_plural(cnt));
21212122
iort_put_rmr_sids(dev_fwnode(smmu->dev), &rmr_list);
21222123
}
21232124

drivers/iommu/mtk_iommu.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/spinlock.h>
3030
#include <linux/soc/mediatek/infracfg.h>
3131
#include <linux/soc/mediatek/mtk_sip_svc.h>
32+
#include <linux/string_choices.h>
3233
#include <asm/barrier.h>
3334
#include <soc/mediatek/smi.h>
3435

@@ -510,7 +511,7 @@ static irqreturn_t mtk_iommu_isr(int irq, void *dev_id)
510511
bank->parent_dev,
511512
"fault type=0x%x iova=0x%llx pa=0x%llx master=0x%x(larb=%d port=%d) layer=%d %s\n",
512513
int_state, fault_iova, fault_pa, regval, fault_larb, fault_port,
513-
layer, write ? "write" : "read");
514+
layer, str_write_read(write));
514515
}
515516

516517
/* Interrupt clear */
@@ -602,7 +603,7 @@ static int mtk_iommu_config(struct mtk_iommu_data *data, struct device *dev,
602603
larb_mmu->bank[portid] = upper_32_bits(region->iova_base);
603604

604605
dev_dbg(dev, "%s iommu for larb(%s) port 0x%lx region %d rgn-bank %d.\n",
605-
enable ? "enable" : "disable", dev_name(larb_mmu->dev),
606+
str_enable_disable(enable), dev_name(larb_mmu->dev),
606607
portid_msk, regionid, upper_32_bits(region->iova_base));
607608

608609
if (enable)
@@ -630,8 +631,8 @@ static int mtk_iommu_config(struct mtk_iommu_data *data, struct device *dev,
630631
}
631632
if (ret)
632633
dev_err(dev, "%s iommu(%s) inframaster 0x%lx fail(%d).\n",
633-
enable ? "enable" : "disable",
634-
dev_name(data->dev), portid_msk, ret);
634+
str_enable_disable(enable), dev_name(data->dev),
635+
portid_msk, ret);
635636
}
636637
return ret;
637638
}

drivers/iommu/mtk_iommu_v1.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/platform_device.h>
2626
#include <linux/slab.h>
2727
#include <linux/spinlock.h>
28+
#include <linux/string_choices.h>
2829
#include <asm/barrier.h>
2930
#include <asm/dma-iommu.h>
3031
#include <dt-bindings/memory/mtk-memory-port.h>
@@ -243,7 +244,7 @@ static void mtk_iommu_v1_config(struct mtk_iommu_v1_data *data,
243244
larb_mmu = &data->larb_imu[larbid];
244245

245246
dev_dbg(dev, "%s iommu port: %d\n",
246-
enable ? "enable" : "disable", portid);
247+
str_enable_disable(enable), portid);
247248

248249
if (enable)
249250
larb_mmu->mmu |= MTK_SMI_MMU_EN(portid);

drivers/iommu/rockchip-iommu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/pm_runtime.h>
2626
#include <linux/slab.h>
2727
#include <linux/spinlock.h>
28+
#include <linux/string_choices.h>
2829

2930
#include "iommu-pages.h"
3031

@@ -611,7 +612,7 @@ static irqreturn_t rk_iommu_irq(int irq, void *dev_id)
611612

612613
dev_err(iommu->dev, "Page fault at %pad of type %s\n",
613614
&iova,
614-
(flags == IOMMU_FAULT_WRITE) ? "write" : "read");
615+
str_write_read(flags == IOMMU_FAULT_WRITE));
615616

616617
log_iova(iommu, i, iova);
617618

0 commit comments

Comments
 (0)