arch/rp23xx: Fix six register/bit macro name clashes - #19535
Merged
Conversation
The rp23xx hardware headers define a register address macro for every register, then a block of register bit definitions. In three headers a bit definition reuses the name of a register address macro, so the register address is silently redefined as a bit mask: RP23XX_POWMAN_BADPASSWD address 0x40100000 -> (1 << 0) RP23XX_POWMAN_BOD_CTRL address 0x40100018 -> (1 << 12) RP23XX_POWMAN_DBG_PWRCFG address 0x401000a4 -> (1 << 0) RP23XX_BUSCTRL_BUS_PRIORITY_ACK address 0x40068004 -> (1 << 0) RP23XX_BUSCTRL_PERFCTR_EN address 0x40068008 -> (1 << 0) RP23XX_PADS_QSPI_VOLTAGE_SELECT address 0x40040000 -> (1 << 0) None of these headers has an in-tree user yet, which is why this has gone unnoticed; each clash appears as a "macro redefined" warning as soon as a driver includes the header. Code that included one of them and used the register by name would have dereferenced 1 or 0x1000 instead of the register. Two of the POWMAN clashes were plain duplicates. Per the RP2350 datasheet BOD_CTRL bit 12 is ISOLATE and DBG_PWRCFG bit 0 is IGNORE, and the correctly named RP23XX_POWMAN_BOD_CTRL_ISOLATE and RP23XX_POWMAN_DBG_PWRCFG_IGNORE were already defined with the same values on the following lines, so the bare names are simply removed. The blank line separating the VREG_LP_EXIT and BOD_CTRL groups is restored at the same time; its absence is what let the duplicate hide inside the preceding group. The other four are single field registers whose field carries no separate name (the datasheet and the SDK describe each as a one bit register), so their bit definitions are renamed to <REGISTER>_MASK, following the _MASK spelling these headers already use for a field extent, and written in hex like their peers. The rp23xx-rv copies of the three headers are identical to the arm ones and carry the same clashes, so they get the same change and stay in sync. No functional change: none of the six names has any user in the tree. Assisted-by: Claude Code:claude-opus-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
casaroli
force-pushed
the
rp23xx-powman-macro-clash
branch
from
July 25, 2026 14:22
0fbef7b to
9a6e708
Compare
xiaoxiang781216
approved these changes
Jul 25, 2026
Contributor
Author
|
The failing The The fixes are tracked separately:
The two fixes were validated together with the CI-equivalent |
xiaoxiang781216
approved these changes
Jul 26, 2026
acassis
approved these changes
Jul 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The rp23xx hardware headers define a register address macro for every register,
then a block of register bit definitions. In three headers a bit definition
reuses the name of a register address macro, so that register address is
silently redefined as a bit mask:
RP23XX_POWMAN_BADPASSWD0x40100000(1 << 0)RP23XX_POWMAN_BOD_CTRL0x40100018(1 << 12)RP23XX_POWMAN_DBG_PWRCFG0x401000a4(1 << 0)RP23XX_BUSCTRL_BUS_PRIORITY_ACK0x40068004(1 << 0)RP23XX_BUSCTRL_PERFCTR_EN0x40068008(1 << 0)RP23XX_PADS_QSPI_VOLTAGE_SELECT0x40040000(1 << 0)None of these headers has an in-tree consumer yet, which is why this has gone
unnoticed; each clash surfaces as a
"..." redefinedwarning the moment adriver includes the header. Code that included one of them and used the
register by name would dereference
1or0x1000rather than the register.Changes
Two of the POWMAN clashes were plain duplicates. Per the RP2350 datasheet
BOD_CTRLbit 12 isISOLATEandDBG_PWRCFGbit 0 isIGNORE, andRP23XX_POWMAN_BOD_CTRL_ISOLATE/RP23XX_POWMAN_DBG_PWRCFG_IGNOREwerealready defined with those exact values on the immediately following lines. The
bare names are therefore removed, with no loss of information.
While removing the
BOD_CTRLline, the blank line separating theVREG_LP_EXITgroup from theBOD_CTRLgroup is restored — its absence iswhat allowed the duplicate to hide inside the preceding group.
The other four are single-field registers whose field carries no separate
name; the datasheet and the SDK describe each as a one-bit register (the SDK
exposes only the register-level
_BITS,0x1). Their bit definitions arerenamed to
<REGISTER>_MASK, matching the_MASKspelling these headersalready use for a field extent, and written in hex like their peers.
The
rp23xx-rvcopies of all three headers are byte-identical to the armones apart from the include guard and carry the same clashes, so they receive
the same change. All three pairs are verified to remain in sync.
Impact
No functional change: none of the six names has a single user anywhere in the
tree, so nothing can change behaviour. This is a latent-bug and warning fix.
Testing
grepthat none of the six macro names is referenced anywherein the tree outside the headers themselves, so the renames and the two
removals cannot break any caller.
rp2350/hardware_regs) thatBOD_CTRLbit 12 isISOLATE,DBG_PWRCFGbit 0 isIGNORE, and thatBADPASSWD,BUS_PRIORITY_ACK,PERFCTR_ENandVOLTAGE_SELECTare each aone-bit register with no separately named field.
#definename remains in any of thesix files, and that each arm/risc-v pair is still identical apart from its
include guard.
were temporarily included from an always-built translation unit and
raspberrypi-pico-2:nshbuilt both ways:redefinedwarnings, exactly the six above;The temporary include was then reverted and is not part of this PR.
raspberrypi-pico-2:nshwas built with a real POWMAN consumer(the RTC driver in arch/arm/rp23xx: Add RTC using the POWMAN always-on timer #19526): the three POWMAN warnings before, clean after,
with the driver still linking.
tools/checkpatch.sh -gclean.Note for reviewers
Two further duplicate definitions exist in these headers but are deliberately
left alone, as they are harmless rather than bugs — both redefine a name to the
identical token sequence, which is legal C and raises no warning:
RP23XX_OTP_BASEinrp23xx_memorymap.h(both arches), same value twiceRP23XX_DMA_SECCFG_MISC_TIMER3_Sinrp23xx_dma.h(both arches), same valuetwice, differing only in a trailing comment
They are redundant lines rather than shadowed registers. Happy to remove them
too if reviewers would like this PR to leave the headers entirely
duplicate-free.
(
RP23XX_IDLESTACK_BASEin the risc-vrp23xx_memorymap.halso appears twice,but correctly so — the two definitions are in mutually exclusive
#ifndef __ASSEMBLY__/#elsebranches.)