thermal: Constify struct thermal_zone_device_ops
Subsystems (8)
PATCH 1/1 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
---
Compile tested only
--- drivers/thermal/armada_thermal.c | 2 +- drivers/thermal/da9062-thermal.c | 2 +- drivers/thermal/dove_thermal.c | 2 +- drivers/thermal/imx_thermal.c | 2 +- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 2 +- drivers/thermal/kirkwood_thermal.c | 2 +- drivers/thermal/mediatek/lvts_thermal.c | 2 +- drivers/thermal/renesas/rcar_thermal.c | 2 +- drivers/thermal/spear_thermal.c | 2 +- drivers/thermal/st/st_thermal.c | 2 +- drivers/thermal/testing/zone.c | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-)
drivers/thermal/armada_thermal.c +1 -1
@@ -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, };
drivers/thermal/da9062-thermal.c +1 -1
@@ -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, };
drivers/thermal/dove_thermal.c +1 -1
@@ -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, };
drivers/thermal/imx_thermal.c +1 -1
@@ -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,
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +1 -1
@@ -515,7 +515,7 @@ static int int3400_thermal_change_mode(struct thermal_zone_device *thermal,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, };
drivers/thermal/kirkwood_thermal.c +1 -1
@@ -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, };
drivers/thermal/mediatek/lvts_thermal.c +1 -1
@@ -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, };
drivers/thermal/renesas/rcar_thermal.c +1 -1
@@ -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, };
drivers/thermal/spear_thermal.c +1 -1
@@ -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, };
drivers/thermal/st/st_thermal.c +1 -1
@@ -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, };
drivers/thermal/testing/zone.c +1 -1
@@ -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, };
Signature · 1 line
2.49.0
Hi Christophe,
Thanks for your work.
Quoted 20 lines · Christophe JAILLET
'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.oAfter:
=====text data bss dec hex filename 28244 5040 128 33412 8284 drivers/thermal/armada_thermal.oSigned-off-by Christophe JAILLET <[email protected]>---
Compile tested only
Quoted 9 lines
--- drivers/thermal/armada_thermal.c | 2 +- drivers/thermal/da9062-thermal.c | 2 +- drivers/thermal/dove_thermal.c | 2 +- drivers/thermal/imx_thermal.c | 2 +- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 2 +- drivers/thermal/kirkwood_thermal.c | 2 +- drivers/thermal/mediatek/lvts_thermal.c | 2 +- drivers/thermal/renesas/rcar_thermal.c | 2 +-
For R-Car,
Quoted 151 lines
drivers/thermal/spear_thermal.c | 2 +- drivers/thermal/st/st_thermal.c | 2 +- drivers/thermal/testing/zone.c | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-)drivers/thermal/armada_thermal.c +1
-1@@ -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, };drivers/thermal/da9062-thermal.c +1
-1@@ -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, };drivers/thermal/dove_thermal.c +1
-1@@ -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, };drivers/thermal/imx_thermal.c +1
-1@@ -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,drivers/thermal/intel/int340x_thermal/int3400_thermal.c +1
-1@@ -515,7 +515,7 @@ static int int3400_thermal_change_mode(struct thermal_zone_device *thermal,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, };drivers/thermal/kirkwood_thermal.c +1
-1@@ -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, };drivers/thermal/mediatek/lvts_thermal.c +1
-1@@ -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, };drivers/thermal/renesas/rcar_thermal.c +1
-1@@ -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, };drivers/thermal/spear_thermal.c +1
-1@@ -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, };drivers/thermal/st/st_thermal.c +1
-1@@ -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, };drivers/thermal/testing/zone.c +1
-1@@ -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, };Signature · 1 line
2.49.0
Signature · 2 lines
Kind Regards, Niklas Söderlund
Hello,
Quoted 14 lines · Christophe JAILLET
'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.oAfter:
=====
Quoted 8 lines
text data bss dec hex filename 28244 5040 128 33412 8284 drivers/thermal/armada_thermal.oSigned-off-by Christophe JAILLET <[email protected]>---
Compile tested only--- drivers/thermal/armada_thermal.c | 2 +-
Thanks,
Miquèl
Quoted 17 lines · Christophe JAILLET
'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.oAfter:
=====text data bss dec hex filename 28244 5040 128 33412 8284 drivers/thermal/armada_thermal.o
Quoted 8 lines
Signed-off-by Christophe JAILLET <[email protected]>---
Compile tested only--- drivers/thermal/armada_thermal.c | 2 +- drivers/thermal/da9062-thermal.c | 2 +- drivers/thermal/dove_thermal.c | 2 +- drivers/thermal/imx_thermal.c | 2 +-
for imx thermal part
Quoted 155 lines
drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 2 +- drivers/thermal/kirkwood_thermal.c | 2 +- drivers/thermal/mediatek/lvts_thermal.c | 2 +- drivers/thermal/renesas/rcar_thermal.c | 2 +- drivers/thermal/spear_thermal.c | 2 +- drivers/thermal/st/st_thermal.c | 2 +- drivers/thermal/testing/zone.c | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-)drivers/thermal/armada_thermal.c +1
-1@@ -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, };drivers/thermal/da9062-thermal.c +1
-1@@ -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, };drivers/thermal/dove_thermal.c +1
-1@@ -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, };drivers/thermal/imx_thermal.c +1
-1@@ -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,drivers/thermal/intel/int340x_thermal/int3400_thermal.c +1
-1@@ -515,7 +515,7 @@ static int int3400_thermal_change_mode(struct thermal_zone_device *thermal,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, };drivers/thermal/kirkwood_thermal.c +1
-1@@ -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, };drivers/thermal/mediatek/lvts_thermal.c +1
-1@@ -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, };drivers/thermal/renesas/rcar_thermal.c +1
-1@@ -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, };drivers/thermal/spear_thermal.c +1
-1@@ -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, };drivers/thermal/st/st_thermal.c +1
-1@@ -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, };drivers/thermal/testing/zone.c +1
-2@@ -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, }; --2.49.0
Daniel Lezcano
AppliedQuoted 14 lines · Christophe JAILLET
'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.oAfter:
=====
Quoted 7 lines
text data bss dec hex filename 28244 5040 128 33412 8284 drivers/thermal/armada_thermal.oSigned-off-by Christophe JAILLET <[email protected]>---
Compile tested only
---
Applied, thanks
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog