power: supply: 88pm860x: make fsm_state array static const, simplify usage
authorColin Ian King <colin.i.king@gmail.com>
Thu, 7 Aug 2025 12:13:49 +0000 (13:13 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Sat, 6 Sep 2025 21:24:23 +0000 (23:24 +0200)
commitcb03556acf83b235dfb2e9f86e14f5e5b8a5f1e7
tree90859e57497827a1f5cf1e46c3961d1dbbcb982a
parent32f350d58544e2529dc8798275684e97f0a2df6f
power: supply: 88pm860x: make fsm_state array static const, simplify usage

Don't populate the read-only array fsm_state on the stack at run time,
instead make it static const, this reduces the object code size as
the data is placed on the data segment and this removes the need to
have code to set the array up on each call.

Note that making the size of the strings to a more optimal 11 bytes long
does not seem to reduce the overall size. Making the array an array of
pointers to the strings increases the code size due to the dereferencing
overhead.

Simplify the array access with &fsm_state[info->state][0] with the simpler
expression fsm_state[info->state] to clean up the code.

Original:
   text    data     bss     dec     hex filename
  22884    8272      64   31220    79f4 drivers/power/supply/88pm860x_charger.o

Patched:
   text    data     bss     dec     hex filename
  22695    8368      64   31127    7997 drivers/power/supply/88pm860x_charger.o

Difference:
   text    data     bss     dec
  -189     +96        0     -93

Reduction of 93 bytes total.

gcc version 14.2.0 (x86-64)

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/88pm860x_charger.c