Skip to content

Commit 992e2ed

Browse files
tititiou36dlezcano
authored andcommitted
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>
1 parent eb51476 commit 992e2ed

File tree

11 files changed

+11
-11
lines changed

11 files changed

+11
-11
lines changed

drivers/thermal/armada_thermal.c

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

411-
static struct thermal_zone_device_ops legacy_ops = {
411+
static const struct thermal_zone_device_ops legacy_ops = {
412412
.get_temp = armada_get_temp_legacy,
413413
};
414414

drivers/thermal/da9062-thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static int da9062_thermal_get_temp(struct thermal_zone_device *z,
137137
return 0;
138138
}
139139

140-
static struct thermal_zone_device_ops da9062_thermal_ops = {
140+
static const struct thermal_zone_device_ops da9062_thermal_ops = {
141141
.get_temp = da9062_thermal_get_temp,
142142
};
143143

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
@@ -361,7 +361,7 @@ static bool imx_should_bind(struct thermal_zone_device *tz,
361361
return trip->type == THERMAL_TRIP_PASSIVE;
362362
}
363363

364-
static struct thermal_zone_device_ops imx_tz_ops = {
364+
static const struct thermal_zone_device_ops imx_tz_ops = {
365365
.should_bind = imx_should_bind,
366366
.get_temp = imx_get_temp,
367367
.change_mode = imx_change_mode,

drivers/thermal/intel/int340x_thermal/int3400_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ static int int3400_thermal_change_mode(struct thermal_zone_device *thermal,
515515
return result;
516516
}
517517

518-
static struct thermal_zone_device_ops int3400_thermal_ops = {
518+
static const struct thermal_zone_device_ops int3400_thermal_ops = {
519519
.get_temp = int3400_thermal_get_temp,
520520
.change_mode = int3400_thermal_change_mode,
521521
};

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/mediatek/lvts_thermal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ static irqreturn_t lvts_irq_handler(int irq, void *data)
571571
return iret;
572572
}
573573

574-
static struct thermal_zone_device_ops lvts_ops = {
574+
static const struct thermal_zone_device_ops lvts_ops = {
575575
.get_temp = lvts_get_temp,
576576
.set_trips = lvts_set_trips,
577577
};

drivers/thermal/renesas/rcar_thermal.c

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

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

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
@@ -132,7 +132,7 @@ static int st_thermal_get_temp(struct thermal_zone_device *th, int *temperature)
132132
return 0;
133133
}
134134

135-
static struct thermal_zone_device_ops st_tz_ops = {
135+
static const struct thermal_zone_device_ops st_tz_ops = {
136136
.get_temp = st_thermal_get_temp,
137137
};
138138

0 commit comments

Comments
 (0)