[PATCH 00/10] spi: Use FIELD_MODIFY() for bitfield operations

Hans Zhang posted 10 patches 1 month, 2 weeks ago
drivers/spi/spi-amlogic-spifc-a1.c |  5 ++---
drivers/spi/spi-amlogic-spisg.c    | 13 +++++--------
drivers/spi/spi-cadence-xspi.c     |  3 +--
drivers/spi/spi-meson-spicc.c      |  5 ++---
drivers/spi/spi-nxp-xspi.c         | 12 ++++--------
drivers/spi/spi-sn-f-ospi.c        |  5 ++---
drivers/spi/spi-stm32-ospi.c       |  7 +++----
drivers/spi/spi-stm32-qspi.c       |  5 ++---
drivers/spi/spi-sunplus-sp7021.c   |  3 +--
drivers/spi/spi-uniphier.c         | 13 +++++--------
10 files changed, 27 insertions(+), 44 deletions(-)
[PATCH 00/10] spi: 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 across multiple SPI controller drivers. This improves readability and
adds compile-time checking without functional changes.

Each patch modifies a single driver, allowing independent review and
application.

Hans Zhang (10):
  spi: amlogic-spifc-a1: Use FIELD_MODIFY()
  spi: amlogic-spisg: Use FIELD_MODIFY()
  spi: cadence-xspi: Use FIELD_MODIFY()
  spi: meson-spicc: Use FIELD_MODIFY()
  spi: nxp-xspi: Use FIELD_MODIFY()
  spi: sn-f-ospi: Use FIELD_MODIFY()
  spi: stm32-ospi: Use FIELD_MODIFY()
  spi: stm32-qspi: Use FIELD_MODIFY()
  spi: sunplus-sp7021: Use FIELD_MODIFY()
  spi: uniphier: Use FIELD_MODIFY()

 drivers/spi/spi-amlogic-spifc-a1.c |  5 ++---
 drivers/spi/spi-amlogic-spisg.c    | 13 +++++--------
 drivers/spi/spi-cadence-xspi.c     |  3 +--
 drivers/spi/spi-meson-spicc.c      |  5 ++---
 drivers/spi/spi-nxp-xspi.c         | 12 ++++--------
 drivers/spi/spi-sn-f-ospi.c        |  5 ++---
 drivers/spi/spi-stm32-ospi.c       |  7 +++----
 drivers/spi/spi-stm32-qspi.c       |  5 ++---
 drivers/spi/spi-sunplus-sp7021.c   |  3 +--
 drivers/spi/spi-uniphier.c         | 13 +++++--------
 10 files changed, 27 insertions(+), 44 deletions(-)


base-commit: 3b3bea6d4b9c162f9e555905d96b8c1da67ecd5b
-- 
2.34.1
Re: [PATCH 00/10] spi: Use FIELD_MODIFY() for bitfield operations
Posted by David Laight 1 month, 2 weeks ago
On Thu, 30 Apr 2026 23:54:46 +0800
Hans Zhang <18255117159@163.com> wrote:

> Replace open-coded bitfield modifications with the standard FIELD_MODIFY()
> macro across multiple SPI controller drivers. This improves readability and
> adds compile-time checking without functional changes.

I don't think these changes are worth the effort.
The readability doesn't change much - you need to know what a slightly
more obscure 'helper' does.
The extra compile-time checks are pretty unlikely to ever find a problem
and mostly just slow down the compile.
The generated code is likely be slightly worse.
And, with the best will in the world, it is easy to make silly mistakes.

	David

> 
> Each patch modifies a single driver, allowing independent review and
> application.
> 
> Hans Zhang (10):
>   spi: amlogic-spifc-a1: Use FIELD_MODIFY()
>   spi: amlogic-spisg: Use FIELD_MODIFY()
>   spi: cadence-xspi: Use FIELD_MODIFY()
>   spi: meson-spicc: Use FIELD_MODIFY()
>   spi: nxp-xspi: Use FIELD_MODIFY()
>   spi: sn-f-ospi: Use FIELD_MODIFY()
>   spi: stm32-ospi: Use FIELD_MODIFY()
>   spi: stm32-qspi: Use FIELD_MODIFY()
>   spi: sunplus-sp7021: Use FIELD_MODIFY()
>   spi: uniphier: Use FIELD_MODIFY()
> 
>  drivers/spi/spi-amlogic-spifc-a1.c |  5 ++---
>  drivers/spi/spi-amlogic-spisg.c    | 13 +++++--------
>  drivers/spi/spi-cadence-xspi.c     |  3 +--
>  drivers/spi/spi-meson-spicc.c      |  5 ++---
>  drivers/spi/spi-nxp-xspi.c         | 12 ++++--------
>  drivers/spi/spi-sn-f-ospi.c        |  5 ++---
>  drivers/spi/spi-stm32-ospi.c       |  7 +++----
>  drivers/spi/spi-stm32-qspi.c       |  5 ++---
>  drivers/spi/spi-sunplus-sp7021.c   |  3 +--
>  drivers/spi/spi-uniphier.c         | 13 +++++--------
>  10 files changed, 27 insertions(+), 44 deletions(-)
> 
> 
> base-commit: 3b3bea6d4b9c162f9e555905d96b8c1da67ecd5b
Re: [PATCH 00/10] spi: Use FIELD_MODIFY() for bitfield operations
Posted by Hans Zhang 1 month, 2 weeks ago

On 5/1/26 16:30, David Laight wrote:
> On Thu, 30 Apr 2026 23:54:46 +0800
> Hans Zhang <18255117159@163.com> wrote:
> 
>> Replace open-coded bitfield modifications with the standard FIELD_MODIFY()
>> macro across multiple SPI controller drivers. This improves readability and
>> adds compile-time checking without functional changes.
> 
> I don't think these changes are worth the effort.
> The readability doesn't change much - you need to know what a slightly
> more obscure 'helper' does.
> The extra compile-time checks are pretty unlikely to ever find a problem
> and mostly just slow down the compile.
> The generated code is likely be slightly worse.
> And, with the best will in the world, it is easy to make silly mistakes.
> 
> 	David

Hi David,

FIELD_MODIFY() is a standard kernel helper (bitfield.h), not an obscure
one. My recent power domain series using similar patterns was accepted:

https://patchwork.kernel.org/project/linux-pm/cover/20260430163213.44695-1-18255117159@163.com/

The PCIe maintainer also values this kind of code simplification, which
encouraged me to send these SPI patches.

The macro offers compile-time overflow checks, and I've verified the
generated assembly is identical (GCC/Clang). I believe the trade‑off
favours readability and safety.

If you still prefer to keep the open‑coded versions, I'll drop the
series. Please let me know.


Best regards,
Hans

> 
>>
>> Each patch modifies a single driver, allowing independent review and
>> application.
>>
>> Hans Zhang (10):
>>    spi: amlogic-spifc-a1: Use FIELD_MODIFY()
>>    spi: amlogic-spisg: Use FIELD_MODIFY()
>>    spi: cadence-xspi: Use FIELD_MODIFY()
>>    spi: meson-spicc: Use FIELD_MODIFY()
>>    spi: nxp-xspi: Use FIELD_MODIFY()
>>    spi: sn-f-ospi: Use FIELD_MODIFY()
>>    spi: stm32-ospi: Use FIELD_MODIFY()
>>    spi: stm32-qspi: Use FIELD_MODIFY()
>>    spi: sunplus-sp7021: Use FIELD_MODIFY()
>>    spi: uniphier: Use FIELD_MODIFY()
>>
>>   drivers/spi/spi-amlogic-spifc-a1.c |  5 ++---
>>   drivers/spi/spi-amlogic-spisg.c    | 13 +++++--------
>>   drivers/spi/spi-cadence-xspi.c     |  3 +--
>>   drivers/spi/spi-meson-spicc.c      |  5 ++---
>>   drivers/spi/spi-nxp-xspi.c         | 12 ++++--------
>>   drivers/spi/spi-sn-f-ospi.c        |  5 ++---
>>   drivers/spi/spi-stm32-ospi.c       |  7 +++----
>>   drivers/spi/spi-stm32-qspi.c       |  5 ++---
>>   drivers/spi/spi-sunplus-sp7021.c   |  3 +--
>>   drivers/spi/spi-uniphier.c         | 13 +++++--------
>>   10 files changed, 27 insertions(+), 44 deletions(-)
>>
>>
>> base-commit: 3b3bea6d4b9c162f9e555905d96b8c1da67ecd5b

Re: [PATCH 00/10] spi: Use FIELD_MODIFY() for bitfield operations
Posted by Mark Brown 1 month, 1 week ago
On Thu, 30 Apr 2026 23:54:46 +0800, Hans Zhang wrote:
> spi: Use FIELD_MODIFY() for bitfield operations
> 
> Replace open-coded bitfield modifications with the standard FIELD_MODIFY()
> macro across multiple SPI controller drivers. This improves readability and
> adds compile-time checking without functional changes.
> 
> Each patch modifies a single driver, allowing independent review and
> application.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.2

Thanks!

[01/10] spi: amlogic-spifc-a1: Use FIELD_MODIFY()
        https://git.kernel.org/broonie/spi/c/8262b1421ddd
[02/10] spi: amlogic-spisg: Use FIELD_MODIFY()
        https://git.kernel.org/broonie/spi/c/b69bfa593329
[03/10] spi: cadence-xspi: Use FIELD_MODIFY()
        https://git.kernel.org/broonie/spi/c/6fa473f4c5dc
[04/10] spi: meson-spicc: Use FIELD_MODIFY()
        https://git.kernel.org/broonie/spi/c/cfdab17cd2d7
[05/10] spi: nxp-xspi: Use FIELD_MODIFY()
        https://git.kernel.org/broonie/spi/c/0f2efc6d4938
[06/10] spi: sn-f-ospi: Use FIELD_MODIFY()
        https://git.kernel.org/broonie/spi/c/579fcc06576d
[07/10] spi: stm32-ospi: Use FIELD_MODIFY()
        https://git.kernel.org/broonie/spi/c/21ee6902a576
[08/10] spi: stm32-qspi: Use FIELD_MODIFY()
        https://git.kernel.org/broonie/spi/c/3e0530c087a9
[09/10] spi: sunplus-sp7021: Use FIELD_MODIFY()
        https://git.kernel.org/broonie/spi/c/673214ac9bcd
[10/10] spi: uniphier: Use FIELD_MODIFY()
        https://git.kernel.org/broonie/spi/c/ce7984bea2a1

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark