]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
thermal: Constify struct thermal_zone_device_ops
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 25 May 2025 09:40:04 +0000 (11:40 +0200)
committerDaniel Lezcano <daniel.lezcano@linaro.org>
Tue, 15 Jul 2025 13:26:04 +0000 (15:26 +0200)
'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>
drivers/thermal/armada_thermal.c
drivers/thermal/da9062-thermal.c
drivers/thermal/dove_thermal.c
drivers/thermal/imx_thermal.c
drivers/thermal/intel/int340x_thermal/int3400_thermal.c
drivers/thermal/kirkwood_thermal.c
drivers/thermal/mediatek/lvts_thermal.c
drivers/thermal/renesas/rcar_thermal.c
drivers/thermal/spear_thermal.c
drivers/thermal/st/st_thermal.c
drivers/thermal/testing/zone.c

index 9bff21068721cb1f405f7e80a7a0865d37e1c234..c2fbdb534f61e2fdc63677987c0936ab3134ee27 100644 (file)
@@ -408,7 +408,7 @@ static int armada_get_temp_legacy(struct thermal_zone_device *thermal,
        return ret;
 }
 
-static struct thermal_zone_device_ops legacy_ops = {
+static const struct thermal_zone_device_ops legacy_ops = {
        .get_temp = armada_get_temp_legacy,
 };
 
index 2077e85ef5caecb93617d261217740b6e121329b..a8d4b766ba21b8506e96704f6a641e20cfc536bc 100644 (file)
@@ -137,7 +137,7 @@ static int da9062_thermal_get_temp(struct thermal_zone_device *z,
        return 0;
 }
 
-static struct thermal_zone_device_ops da9062_thermal_ops = {
+static const struct thermal_zone_device_ops da9062_thermal_ops = {
        .get_temp       = da9062_thermal_get_temp,
 };
 
index f9157a47156b08a3524b0b9f6557fcae18e127d9..723bc72f06264b88f12bda3823f33da77a743809 100644 (file)
@@ -106,7 +106,7 @@ static int dove_get_temp(struct thermal_zone_device *thermal,
        return 0;
 }
 
-static struct thermal_zone_device_ops ops = {
+static const struct thermal_zone_device_ops ops = {
        .get_temp = dove_get_temp,
 };
 
index bab52e6b3b1558bbd0ed28b6008d824fc299be3d..38c993d1bcb32c9a47a7c1b5b2996321cedc89da 100644 (file)
@@ -361,7 +361,7 @@ static bool imx_should_bind(struct thermal_zone_device *tz,
        return trip->type == THERMAL_TRIP_PASSIVE;
 }
 
-static struct thermal_zone_device_ops imx_tz_ops = {
+static const struct thermal_zone_device_ops imx_tz_ops = {
        .should_bind = imx_should_bind,
        .get_temp = imx_get_temp,
        .change_mode = imx_change_mode,
index 0e07693ecf59e29495be1ed68d39922de40f6d7c..5736638c586b28945277b1e5736e17d2636068b8 100644 (file)
@@ -515,7 +515,7 @@ eval_odvp:
        return result;
 }
 
-static struct thermal_zone_device_ops int3400_thermal_ops = {
+static const struct thermal_zone_device_ops int3400_thermal_ops = {
        .get_temp = int3400_thermal_get_temp,
        .change_mode = int3400_thermal_change_mode,
 };
index 7c22652316688b82694299186bc4fa8b98cdf6f6..4619e090f756196ace4e8facfcbc0cc7a21c83ae 100644 (file)
@@ -48,7 +48,7 @@ static int kirkwood_get_temp(struct thermal_zone_device *thermal,
        return 0;
 }
 
-static struct thermal_zone_device_ops ops = {
+static const struct thermal_zone_device_ops ops = {
        .get_temp = kirkwood_get_temp,
 };
 
index 985925147ac06835111afc686f5e7a4770485097..acce8fde2cbad6484557d9b276666c796df7cc97 100644 (file)
@@ -571,7 +571,7 @@ static irqreturn_t lvts_irq_handler(int irq, void *data)
        return iret;
 }
 
-static struct thermal_zone_device_ops lvts_ops = {
+static const struct thermal_zone_device_ops lvts_ops = {
        .get_temp = lvts_get_temp,
        .set_trips = lvts_set_trips,
 };
index 00a66ee0a5b00c5f240c52087817ade7a17c0c72..fdd7afdc4ff69217f7e6a1c9220e2560a5c3869c 100644 (file)
@@ -277,7 +277,7 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
        return rcar_thermal_get_current_temp(priv, temp);
 }
 
-static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
+static const struct thermal_zone_device_ops rcar_thermal_zone_ops = {
        .get_temp       = rcar_thermal_get_temp,
 };
 
index bb96be9475213839a9e3e7e588346f5aca2f9c21..603dadcd3df5833988e9cb0a6ab57f8348fdd9a8 100644 (file)
@@ -41,7 +41,7 @@ static inline int thermal_get_temp(struct thermal_zone_device *thermal,
        return 0;
 }
 
-static struct thermal_zone_device_ops ops = {
+static const struct thermal_zone_device_ops ops = {
        .get_temp = thermal_get_temp,
 };
 
index a14a37d546982e95782ffc53f941a075bd1202e5..1470ca519def4668352e0fc2615bb7ce15027a35 100644 (file)
@@ -132,7 +132,7 @@ static int st_thermal_get_temp(struct thermal_zone_device *th, int *temperature)
        return 0;
 }
 
-static struct thermal_zone_device_ops st_tz_ops = {
+static const struct thermal_zone_device_ops st_tz_ops = {
        .get_temp       = st_thermal_get_temp,
 };
 
index 1f4e450100e2f179ca84846c22d1d11a7557acc7..4257d813d572d15f76f18eda0b7928d740c6a554 100644 (file)
@@ -381,7 +381,7 @@ static int tt_zone_get_temp(struct thermal_zone_device *tz, int *temp)
        return 0;
 }
 
-static struct thermal_zone_device_ops tt_zone_ops = {
+static const struct thermal_zone_device_ops tt_zone_ops = {
        .get_temp = tt_zone_get_temp,
 };