Skip to content

Commit 82fb5a3

Browse files
tititiou36kuba-moo
authored andcommitted
mlxsw: core_thermal: Constify struct thermal_zone_device_ops
'struct thermal_zone_device_ops' are not modified in this driver. Constifying these structures moves some data to a read-only section, so increases overall security, especially when the structure holds some function pointers. While at it, also constify a struct thermal_zone_params. On a x86_64, with allmodconfig: Before: ====== text data bss dec hex filename 24899 8036 0 32935 80a7 drivers/net/ethernet/mellanox/mlxsw/core_thermal.o After: ===== text data bss dec hex filename 25379 7556 0 32935 80a7 drivers/net/ethernet/mellanox/mlxsw/core_thermal.o Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://patch.msgid.link/4516676973f5adc1cdb76db1691c0f98b6fa6614.1748164348.git.christophe.jaillet@wanadoo.fr Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent a540ee7 commit 82fb5a3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/ethernet/mellanox/mlxsw/core_thermal.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,11 +205,11 @@ static int mlxsw_thermal_get_temp(struct thermal_zone_device *tzdev,
205205
return 0;
206206
}
207207

208-
static struct thermal_zone_params mlxsw_thermal_params = {
208+
static const struct thermal_zone_params mlxsw_thermal_params = {
209209
.no_hwmon = true,
210210
};
211211

212-
static struct thermal_zone_device_ops mlxsw_thermal_ops = {
212+
static const struct thermal_zone_device_ops mlxsw_thermal_ops = {
213213
.should_bind = mlxsw_thermal_should_bind,
214214
.get_temp = mlxsw_thermal_get_temp,
215215
};
@@ -252,7 +252,7 @@ static int mlxsw_thermal_module_temp_get(struct thermal_zone_device *tzdev,
252252
return 0;
253253
}
254254

255-
static struct thermal_zone_device_ops mlxsw_thermal_module_ops = {
255+
static const struct thermal_zone_device_ops mlxsw_thermal_module_ops = {
256256
.should_bind = mlxsw_thermal_module_should_bind,
257257
.get_temp = mlxsw_thermal_module_temp_get,
258258
};
@@ -280,7 +280,7 @@ static int mlxsw_thermal_gearbox_temp_get(struct thermal_zone_device *tzdev,
280280
return 0;
281281
}
282282

283-
static struct thermal_zone_device_ops mlxsw_thermal_gearbox_ops = {
283+
static const struct thermal_zone_device_ops mlxsw_thermal_gearbox_ops = {
284284
.should_bind = mlxsw_thermal_module_should_bind,
285285
.get_temp = mlxsw_thermal_gearbox_temp_get,
286286
};

0 commit comments

Comments
 (0)