mirror of
https://github.com/torvalds/linux
synced 2024-11-05 18:23:50 +00:00
9722c3b66e
The of_property_for_each_u32() macro needs five parameters, two of which are primarily meant as internal variables for the macro itself (in the for() clause). Yet these two parameters are used by a few drivers, and this can be considered misuse or at least bad practice. Now that the kernel uses C11 to build, these two parameters can be avoided by declaring them internally, thus changing this pattern: struct property *prop; const __be32 *p; u32 val; of_property_for_each_u32(np, "xyz", prop, p, val) { ... } to this: u32 val; of_property_for_each_u32(np, "xyz", val) { ... } However two variables cannot be declared in the for clause even with C11, so declare one struct that contain the two variables we actually need. As the variables inside this struct are not meant to be used by users of this macro, give the struct instance the noticeable name "_it" so it is visible during code reviews, helping to avoid new code to use it directly. Most usages are trivially converted as they do not use those two parameters, as expected. The non-trivial cases are: - drivers/clk/clk.c, of_clk_get_parent_name(): easily doable anyway - drivers/clk/clk-si5351.c, si5351_dt_parse(): this is more complex as the checks had to be replicated in a different way, making code more verbose and somewhat uglier, but I refrained from a full rework to keep as much of the original code untouched having no hardware to test my changes All the changes have been build tested. The few for which I have the hardware have been runtime-tested too. Reviewed-by: Andre Przywara <andre.przywara@arm.com> # drivers/clk/sunxi/clk-simple-gates.c, drivers/clk/sunxi/clk-sun8i-bus-gates.c Acked-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> # drivers/gpio/gpio-brcmstb.c Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com> # drivers/irqchip/irq-atmel-aic-common.c Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> # drivers/iio/adc/ti_am335x_adc.c Acked-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> # drivers/pwm/pwm-samsung.c Acked-by: Richard Leitner <richard.leitner@linux.dev> # drivers/usb/misc/usb251xb.c Acked-by: Mark Brown <broonie@kernel.org> # sound/soc/codecs/arizona.c Reviewed-by: Richard Fitzgerald <rf@opensource.cirrus.com> # sound/soc/codecs/arizona.c Acked-by: Michael Ellerman <mpe@ellerman.id.au> # arch/powerpc/sysdev/xive/spapr.c Acked-by: Stephen Boyd <sboyd@kernel.org> # clk Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com> Acked-by: Lee Jones <lee@kernel.org> Link: https://lore.kernel.org/r/20240724-of_property_for_each_u32-v3-1-bea82ce429e2@bootlin.com Signed-off-by: Rob Herring (Arm) <robh@kernel.org> |
||
---|---|---|
.. | ||
acpi_pm.c | ||
arc_timer.c | ||
arm_arch_timer.c | ||
arm_global_timer.c | ||
armv7m_systick.c | ||
asm9260_timer.c | ||
bcm2835_timer.c | ||
bcm_kona_timer.c | ||
clksrc-dbx500-prcmu.c | ||
clksrc_st_lpc.c | ||
clps711x-timer.c | ||
dummy_timer.c | ||
dw_apb_timer.c | ||
dw_apb_timer_of.c | ||
em_sti.c | ||
exynos_mct.c | ||
hyperv_timer.c | ||
i8253.c | ||
ingenic-ost.c | ||
ingenic-sysost.c | ||
ingenic-timer.c | ||
jcore-pit.c | ||
Kconfig | ||
Makefile | ||
mips-gic-timer.c | ||
mmio.c | ||
mps2-timer.c | ||
mxs_timer.c | ||
nomadik-mtu.c | ||
numachip.c | ||
renesas-ostm.c | ||
samsung_pwm_timer.c | ||
scx200_hrt.c | ||
sh_cmt.c | ||
sh_mtu2.c | ||
sh_tmu.c | ||
timer-armada-370-xp.c | ||
timer-atmel-pit.c | ||
timer-atmel-st.c | ||
timer-atmel-tcb.c | ||
timer-cadence-ttc.c | ||
timer-clint.c | ||
timer-cs5535.c | ||
timer-davinci.c | ||
timer-digicolor.c | ||
timer-ep93xx.c | ||
timer-fsl-ftm.c | ||
timer-fttmr010.c | ||
timer-goldfish.c | ||
timer-gx6605s.c | ||
timer-gxp.c | ||
timer-imx-gpt.c | ||
timer-imx-sysctr.c | ||
timer-imx-tpm.c | ||
timer-integrator-ap.c | ||
timer-ixp4xx.c | ||
timer-keystone.c | ||
timer-loongson1-pwm.c | ||
timer-lpc32xx.c | ||
timer-mediatek-cpux.c | ||
timer-mediatek.c | ||
timer-meson6.c | ||
timer-microchip-pit64b.c | ||
timer-milbeaut.c | ||
timer-mp-csky.c | ||
timer-msc313e.c | ||
timer-npcm7xx.c | ||
timer-of.c | ||
timer-of.h | ||
timer-orion.c | ||
timer-owl.c | ||
timer-pistachio.c | ||
timer-probe.c | ||
timer-pxa.c | ||
timer-qcom.c | ||
timer-rda.c | ||
timer-riscv.c | ||
timer-rockchip.c | ||
timer-rtl-otto.c | ||
timer-sp.h | ||
timer-sp804.c | ||
timer-sprd.c | ||
timer-stm32-lp.c | ||
timer-stm32.c | ||
timer-sun4i.c | ||
timer-sun5i.c | ||
timer-tegra.c | ||
timer-tegra186.c | ||
timer-ti-32k.c | ||
timer-ti-dm-systimer.c | ||
timer-ti-dm.c | ||
timer-versatile.c | ||
timer-vf-pit.c | ||
timer-vt8500.c | ||
timer-zevio.c |