Skip to content

Commit 2300edf

Browse files
committed
thermal: Constify struct thermal_zone_device_ops
JIRA: https://issues.redhat.com/browse/RHEL-85463 Conflicts: RHEL doesn't have all of the upstream files commit 992e2ed Author: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Date: Sun May 25 11:40:04 2025 +0200 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> Signed-off-by: David Arcari <darcari@redhat.com>
1 parent e59c6d4 commit 2300edf

File tree

9 files changed

+9
-9
lines changed

9 files changed

+9
-9
lines changed

drivers/thermal/armada_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ static int armada_get_temp_legacy(struct thermal_zone_device *thermal,
410410
return ret;
411411
}
412412

413-
static struct thermal_zone_device_ops legacy_ops = {
413+
static const struct thermal_zone_device_ops legacy_ops = {
414414
.get_temp = armada_get_temp_legacy,
415415
};
416416

drivers/thermal/da9062-thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static int da9062_thermal_get_temp(struct thermal_zone_device *z,
170170
return 0;
171171
}
172172

173-
static struct thermal_zone_device_ops da9062_thermal_ops = {
173+
static const struct thermal_zone_device_ops da9062_thermal_ops = {
174174
.get_temp = da9062_thermal_get_temp,
175175
.get_trip_type = da9062_thermal_get_trip_type,
176176
.get_trip_temp = da9062_thermal_get_trip_temp,

drivers/thermal/dove_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ static int dove_get_temp(struct thermal_zone_device *thermal,
106106
return 0;
107107
}
108108

109-
static struct thermal_zone_device_ops ops = {
109+
static const struct thermal_zone_device_ops ops = {
110110
.get_temp = dove_get_temp,
111111
};
112112

drivers/thermal/imx_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static int imx_unbind(struct thermal_zone_device *tz,
396396
return 0;
397397
}
398398

399-
static struct thermal_zone_device_ops imx_tz_ops = {
399+
static const struct thermal_zone_device_ops imx_tz_ops = {
400400
.bind = imx_bind,
401401
.unbind = imx_unbind,
402402
.get_temp = imx_get_temp,

drivers/thermal/intel/int340x_thermal/int3400_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ static int int3400_thermal_change_mode(struct thermal_zone_device *thermal,
522522
return result;
523523
}
524524

525-
static struct thermal_zone_device_ops int3400_thermal_ops = {
525+
static const struct thermal_zone_device_ops int3400_thermal_ops = {
526526
.get_temp = int3400_thermal_get_temp,
527527
.change_mode = int3400_thermal_change_mode,
528528
};

drivers/thermal/kirkwood_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static int kirkwood_get_temp(struct thermal_zone_device *thermal,
4848
return 0;
4949
}
5050

51-
static struct thermal_zone_device_ops ops = {
51+
static const struct thermal_zone_device_ops ops = {
5252
.get_temp = kirkwood_get_temp,
5353
};
5454

drivers/thermal/rcar_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ static int rcar_thermal_get_temp(struct thermal_zone_device *zone, int *temp)
278278
return rcar_thermal_get_current_temp(priv, temp);
279279
}
280280

281-
static struct thermal_zone_device_ops rcar_thermal_zone_ops = {
281+
static const struct thermal_zone_device_ops rcar_thermal_zone_ops = {
282282
.get_temp = rcar_thermal_get_temp,
283283
};
284284

drivers/thermal/spear_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static inline int thermal_get_temp(struct thermal_zone_device *thermal,
4141
return 0;
4242
}
4343

44-
static struct thermal_zone_device_ops ops = {
44+
static const struct thermal_zone_device_ops ops = {
4545
.get_temp = thermal_get_temp,
4646
};
4747

drivers/thermal/st/st_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ static int st_thermal_get_trip_temp(struct thermal_zone_device *th,
167167
return 0;
168168
}
169169

170-
static struct thermal_zone_device_ops st_tz_ops = {
170+
static const struct thermal_zone_device_ops st_tz_ops = {
171171
.get_temp = st_thermal_get_temp,
172172
.get_trip_type = st_thermal_get_trip_type,
173173
.get_trip_temp = st_thermal_get_trip_temp,

0 commit comments

Comments
 (0)