[PATCH 0/2] iommu/arm-smmu: Use FIELD_MODIFY() for bitfield operations

Hans Zhang posted 2 patches 1 month, 2 weeks ago
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(-)
[PATCH 0/2] iommu/arm-smmu: Use FIELD_MODIFY() for bitfield operations
Posted by Hans Zhang 1 month, 2 weeks ago
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
Re: [PATCH 0/2] iommu/arm-smmu: Use FIELD_MODIFY() for bitfield operations
Posted by Will Deacon 1 month ago
On Fri, May 01, 2026 at 12:45:43AM +0800, Hans Zhang wrote:
> Replace open-coded bitfield modifications with the standard FIELD_MODIFY()
> macro. This improves code readability and adds type/range checking without
> functional changes.

Does it _really_ improve the readability? '&=' and '|=' patterns are
pretty idiomatic C code, if you ask me.

> 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.

I don't really mind the code either way, so I think I'd prefer to leave
it as-is unless somebody wants to convince me otherwise...

Will
Re: [PATCH 0/2] iommu/arm-smmu: Use FIELD_MODIFY() for bitfield operations
Posted by Hans Zhang 1 month ago

On 5/19/26 18:51, Will Deacon wrote:
> On Fri, May 01, 2026 at 12:45:43AM +0800, Hans Zhang wrote:
>> Replace open-coded bitfield modifications with the standard FIELD_MODIFY()
>> macro. This improves code readability and adds type/range checking without
>> functional changes.
> 
> Does it _really_ improve the readability? '&=' and '|=' patterns are
> pretty idiomatic C code, if you ask me.
> 
>> 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.
> 
> I don't really mind the code either way, so I think I'd prefer to leave
> it as-is unless somebody wants to convince me otherwise...
> 
> Will

Hi Will,

It's not like that. Please take a look at the accepted patch below.



https://lore.kernel.org/linux-pci/20260505165436.GA737933@bhelgaas/

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=42ec65b46a4fc7565d48daa42bf025fdc67800eb

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=5fd6f2154734f447e83b6de9a08d16848605191e


Best regards,
Hans