pwm-stm32: Make use of parametrised register definitions
authorUwe Kleine-König <u.kleine-koenig@baylibre.com>
Wed, 19 Jun 2024 10:11:46 +0000 (12:11 +0200)
committerUwe Kleine-König <ukleinek@kernel.org>
Wed, 10 Jul 2024 15:53:51 +0000 (17:53 +0200)
commit7cea05ae1d4ecbb7a6c3d28f9c483b1f9105526a
treeb4df02ffbba773d3da0e954a0fa05bba53b0e925
parent2b17a6eeb3e7bbae1194cbc070f19cddc7775034
pwm-stm32: Make use of parametrised register definitions

There is no semantic change, but it is a nicer on the eyes of a reader,
because

TIM_CCR1 + 4 * ch

encodes internal register knowledge, while

TIM_CCRx(ch + 1)

keeps that information completely in the header defining the registers.

While I expected this to not result in any changes in the binary, gcc 13
(as provided by Debian in the gcc-13-arm-linux-gnueabihf 13.2.0-12cross1
package) compiles the new version with an allmodconfig to more compact
code:

$ source/scripts/bloat-o-meter drivers/pwm/pwm-stm32.o-pre drivers/pwm/pwm-stm32.o
add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-488 (-488)
Function                                     old     new   delta
stm32_pwm_get_state                          968     936     -32
stm32_pwm_apply_locked                      1920    1464    -456

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/d7ef7a6158df4ba6687233b0e00d37796b069fb3.1718791090.git.u.kleine-koenig@baylibre.com
Signed-off-by: Uwe Kleine-König <ukleinek@kernel.org>
drivers/pwm/pwm-stm32.c