* [PATCH 0/2] iommu/arm-smmu: Use FIELD_MODIFY() for bitfield operations
@ 2026-04-30 16:45 Hans Zhang
2026-04-30 16:45 ` [PATCH 1/2] iommu/arm-smmu-qcom: Use FIELD_MODIFY() Hans Zhang
2026-04-30 16:45 ` [PATCH 2/2] iommu/arm-smmu-v3: " Hans Zhang
0 siblings, 2 replies; 3+ messages in thread
From: Hans Zhang @ 2026-04-30 16:45 UTC (permalink / raw)
To: will, robin.murphy, joro
Cc: iommu, linux-arm-msm, linux-kernel, linux-arm-kernel, Hans Zhang
Replace open-coded bitfield modifications with the standard FIELD_MODIFY()
macro. This improves code readability and adds type/range checking without
functional changes.
FIELD_MODIFY() internally performs the same mask-clear + set operation but
eliminates repetitive boilerplate.
---
Hi, If the Maintainers think it's not necessary, please ignore it.
---
Hans Zhang (2):
iommu/arm-smmu-qcom: Use FIELD_MODIFY()
iommu/arm-smmu-v3: Use FIELD_MODIFY()
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 5 ++---
drivers/iommu/arm/arm-smmu/arm-smmu-qcom-debug.c | 3 +--
2 files changed, 3 insertions(+), 5 deletions(-)
base-commit: 3b3bea6d4b9c162f9e555905d96b8c1da67ecd5b
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] iommu/arm-smmu-qcom: Use FIELD_MODIFY()
2026-04-30 16:45 [PATCH 0/2] iommu/arm-smmu: Use FIELD_MODIFY() for bitfield operations Hans Zhang
@ 2026-04-30 16:45 ` Hans Zhang
2026-04-30 16:45 ` [PATCH 2/2] iommu/arm-smmu-v3: " Hans Zhang
1 sibling, 0 replies; 3+ messages in thread
From: Hans Zhang @ 2026-04-30 16:45 UTC (permalink / raw)
To: will, robin.murphy, joro
Cc: iommu, linux-arm-msm, linux-kernel, linux-arm-kernel, Hans Zhang
Use FIELD_MODIFY() to remove open-coded bit manipulation.
No functional change intended.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/iommu/arm/arm-smmu/arm-smmu-qcom-debug.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom-debug.c b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom-debug.c
index 65e0ef6539fe..99469c4ebac2 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu-qcom-debug.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu-qcom-debug.c
@@ -208,8 +208,7 @@ static phys_addr_t qcom_tbu_trigger_atos(struct arm_smmu_domain *smmu_domain,
/* Set address and stream-id */
val = readq_relaxed(tbu->base + DEBUG_SID_HALT_REG);
- val &= ~DEBUG_SID_HALT_SID;
- val |= FIELD_PREP(DEBUG_SID_HALT_SID, sid);
+ FIELD_MODIFY(DEBUG_SID_HALT_SID, &val, sid);
writeq_relaxed(val, tbu->base + DEBUG_SID_HALT_REG);
writeq_relaxed(iova, tbu->base + DEBUG_VA_ADDR_REG);
val = FIELD_PREP(DEBUG_AXUSER_CDMID, DEBUG_AXUSER_CDMID_VAL);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] iommu/arm-smmu-v3: Use FIELD_MODIFY()
2026-04-30 16:45 [PATCH 0/2] iommu/arm-smmu: Use FIELD_MODIFY() for bitfield operations Hans Zhang
2026-04-30 16:45 ` [PATCH 1/2] iommu/arm-smmu-qcom: Use FIELD_MODIFY() Hans Zhang
@ 2026-04-30 16:45 ` Hans Zhang
1 sibling, 0 replies; 3+ messages in thread
From: Hans Zhang @ 2026-04-30 16:45 UTC (permalink / raw)
To: will, robin.murphy, joro
Cc: iommu, linux-arm-msm, linux-kernel, linux-arm-kernel, Hans Zhang
Use FIELD_MODIFY() to remove open-coded bit manipulation.
No functional change intended.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c
index ddae0b07c76b..b62e91e4781d 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c
@@ -330,8 +330,7 @@ static int arm_vsmmu_convert_user_cmd(struct arm_vsmmu *vsmmu,
case CMDQ_OP_TLBI_NH_VAA:
case CMDQ_OP_TLBI_NH_ALL:
case CMDQ_OP_TLBI_NH_ASID:
- cmd->cmd[0] &= ~CMDQ_TLBI_0_VMID;
- cmd->cmd[0] |= FIELD_PREP(CMDQ_TLBI_0_VMID, vsmmu->vmid);
+ FIELD_MODIFY(CMDQ_TLBI_0_VMID, &cmd->cmd[0], vsmmu->vmid);
break;
case CMDQ_OP_ATC_INV:
case CMDQ_OP_CFGI_CD:
@@ -340,8 +339,7 @@ static int arm_vsmmu_convert_user_cmd(struct arm_vsmmu *vsmmu,
if (arm_vsmmu_vsid_to_sid(vsmmu, vsid, &sid))
return -EIO;
- cmd->cmd[0] &= ~CMDQ_CFGI_0_SID;
- cmd->cmd[0] |= FIELD_PREP(CMDQ_CFGI_0_SID, sid);
+ FIELD_MODIFY(CMDQ_CFGI_0_SID, &cmd->cmd[0], sid);
break;
}
default:
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-30 16:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-30 16:45 [PATCH 0/2] iommu/arm-smmu: Use FIELD_MODIFY() for bitfield operations Hans Zhang
2026-04-30 16:45 ` [PATCH 1/2] iommu/arm-smmu-qcom: Use FIELD_MODIFY() Hans Zhang
2026-04-30 16:45 ` [PATCH 2/2] iommu/arm-smmu-v3: " Hans Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox