Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal: Constify struct thermal_zone_device_ops

'struct thermal_zone_device_ops' are not modified in these drivers.

Constifying these structures moves some data to a read-only section, so
increases overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig, as an example:
Before:
======
text data bss dec hex filename
28116 5168 128 33412 8284 drivers/thermal/armada_thermal.o

After:
=====
text data bss dec hex filename
28244 5040 128 33412 8284 drivers/thermal/armada_thermal.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> # For Armada
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://lore.kernel.org/r/5bba3bf0139e2418b306a0f9a2f1f81ef49e88a6.1748165978.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

authored by

Christophe JAILLET and committed by
Daniel Lezcano
992e2ed0 eb514766

+11 -11
+1 -1
drivers/thermal/armada_thermal.c
··· 408 408 return ret; 409 409 } 410 410 411 - static struct thermal_zone_device_ops legacy_ops = { 411 + static const struct thermal_zone_device_ops legacy_ops = { 412 412 .get_temp = armada_get_temp_legacy, 413 413 }; 414 414
+1 -1
drivers/thermal/da9062-thermal.c
··· 137 137 return 0; 138 138 } 139 139 140 - static struct thermal_zone_device_ops da9062_thermal_ops = { 140 + static const struct thermal_zone_device_ops da9062_thermal_ops = { 141 141 .get_temp = da9062_thermal_get_temp, 142 142 }; 143 143
+1 -1
drivers/thermal/dove_thermal.c
··· 106 106 return 0; 107 107 } 108 108 109 - static struct thermal_zone_device_ops ops = { 109 + static const struct thermal_zone_device_ops ops = { 110 110 .get_temp = dove_get_temp, 111 111 }; 112 112
+1 -1
drivers/thermal/imx_thermal.c
··· 361 361 return trip->type == THERMAL_TRIP_PASSIVE; 362 362 } 363 363 364 - static struct thermal_zone_device_ops imx_tz_ops = { 364 + static const struct thermal_zone_device_ops imx_tz_ops = { 365 365 .should_bind = imx_should_bind, 366 366 .get_temp = imx_get_temp, 367 367 .change_mode = imx_change_mode,
+1 -1
drivers/thermal/intel/int340x_thermal/int3400_thermal.c
··· 515 515 return result; 516 516 } 517 517 518 - static struct thermal_zone_device_ops int3400_thermal_ops = { 518 + static const struct thermal_zone_device_ops int3400_thermal_ops = { 519 519 .get_temp = int3400_thermal_get_temp, 520 520 .change_mode = int3400_thermal_change_mode, 521 521 };
+1 -1
drivers/thermal/kirkwood_thermal.c
··· 48 48 return 0; 49 49 } 50 50 51 - static struct thermal_zone_device_ops ops = { 51 + static const struct thermal_zone_device_ops ops = { 52 52 .get_temp = kirkwood_get_temp, 53 53 }; 54 54
+1 -1
drivers/thermal/mediatek/lvts_thermal.c
··· 571 571 return iret; 572 572 } 573 573 574 - static struct thermal_zone_device_ops lvts_ops = { 574 + static const struct thermal_zone_device_ops lvts_ops = { 575 575 .get_temp = lvts_get_temp, 576 576 .set_trips = lvts_set_trips, 577 577 };
+1 -1
drivers/thermal/renesas/rcar_thermal.c
··· 277 277 return rcar_thermal_get_current_temp(priv, temp); 278 278 } 279 279 280 - static struct thermal_zone_device_ops rcar_thermal_zone_ops = { 280 + static const struct thermal_zone_device_ops rcar_thermal_zone_ops = { 281 281 .get_temp = rcar_thermal_get_temp, 282 282 }; 283 283
+1 -1
drivers/thermal/spear_thermal.c
··· 41 41 return 0; 42 42 } 43 43 44 - static struct thermal_zone_device_ops ops = { 44 + static const struct thermal_zone_device_ops ops = { 45 45 .get_temp = thermal_get_temp, 46 46 }; 47 47
+1 -1
drivers/thermal/st/st_thermal.c
··· 132 132 return 0; 133 133 } 134 134 135 - static struct thermal_zone_device_ops st_tz_ops = { 135 + static const struct thermal_zone_device_ops st_tz_ops = { 136 136 .get_temp = st_thermal_get_temp, 137 137 }; 138 138
+1 -1
drivers/thermal/testing/zone.c
··· 381 381 return 0; 382 382 } 383 383 384 - static struct thermal_zone_device_ops tt_zone_ops = { 384 + static const struct thermal_zone_device_ops tt_zone_ops = { 385 385 .get_temp = tt_zone_get_temp, 386 386 }; 387 387