linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] thermal: Constify struct thermal_zone_device_ops
@ 2025-05-25  9:40 Christophe JAILLET
  2025-05-25 10:19 ` Niklas Söderlund
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Christophe JAILLET @ 2025-05-25  9:40 UTC (permalink / raw)
  To: Miquel Raynal, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui,
	Lukasz Luba, Support Opensource, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Niklas Söderlund,
	Geert Uytterhoeven, Magnus Damm, Matthias Brugger,
	AngeloGioacchino Del Regno
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-pm, imx,
	linux-arm-kernel, linux-renesas-soc, linux-mediatek

'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>
---
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(-)

diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
index 9bff21068721..c2fbdb534f61 100644
--- a/drivers/thermal/armada_thermal.c
+++ b/drivers/thermal/armada_thermal.c
@@ -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,
 };
 
diff --git a/drivers/thermal/da9062-thermal.c b/drivers/thermal/da9062-thermal.c
index 2077e85ef5ca..a8d4b766ba21 100644
--- a/drivers/thermal/da9062-thermal.c
+++ b/drivers/thermal/da9062-thermal.c
@@ -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,
 };
 
diff --git a/drivers/thermal/dove_thermal.c b/drivers/thermal/dove_thermal.c
index f9157a47156b..723bc72f0626 100644
--- a/drivers/thermal/dove_thermal.c
+++ b/drivers/thermal/dove_thermal.c
@@ -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,
 };
 
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index bab52e6b3b15..38c993d1bcb3 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -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,
diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
index 0e07693ecf59..5736638c586b 100644
--- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
+++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
@@ -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,
 };
diff --git a/drivers/thermal/kirkwood_thermal.c b/drivers/thermal/kirkwood_thermal.c
index 7c2265231668..4619e090f756 100644
--- a/drivers/thermal/kirkwood_thermal.c
+++ b/drivers/thermal/kirkwood_thermal.c
@@ -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,
 };
 
diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
index 985925147ac0..acce8fde2cba 100644
--- a/drivers/thermal/mediatek/lvts_thermal.c
+++ b/drivers/thermal/mediatek/lvts_thermal.c
@@ -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,
 };
diff --git a/drivers/thermal/renesas/rcar_thermal.c b/drivers/thermal/renesas/rcar_thermal.c
index 00a66ee0a5b0..fdd7afdc4ff6 100644
--- a/drivers/thermal/renesas/rcar_thermal.c
+++ b/drivers/thermal/renesas/rcar_thermal.c
@@ -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,
 };
 
diff --git a/drivers/thermal/spear_thermal.c b/drivers/thermal/spear_thermal.c
index bb96be947521..603dadcd3df5 100644
--- a/drivers/thermal/spear_thermal.c
+++ b/drivers/thermal/spear_thermal.c
@@ -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,
 };
 
diff --git a/drivers/thermal/st/st_thermal.c b/drivers/thermal/st/st_thermal.c
index a14a37d54698..1470ca519def 100644
--- a/drivers/thermal/st/st_thermal.c
+++ b/drivers/thermal/st/st_thermal.c
@@ -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,
 };
 
diff --git a/drivers/thermal/testing/zone.c b/drivers/thermal/testing/zone.c
index 1f4e450100e2..4257d813d572 100644
--- a/drivers/thermal/testing/zone.c
+++ b/drivers/thermal/testing/zone.c
@@ -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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] thermal: Constify struct thermal_zone_device_ops
  2025-05-25  9:40 [PATCH] thermal: Constify struct thermal_zone_device_ops Christophe JAILLET
@ 2025-05-25 10:19 ` Niklas Söderlund
  2025-05-26  7:29 ` Miquel Raynal
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Niklas Söderlund @ 2025-05-25 10:19 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Miquel Raynal, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui,
	Lukasz Luba, Support Opensource, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Geert Uytterhoeven,
	Magnus Damm, Matthias Brugger, AngeloGioacchino Del Regno,
	linux-kernel, kernel-janitors, linux-pm, imx, linux-arm-kernel,
	linux-renesas-soc, linux-mediatek

Hi Christophe,

Thanks for your work.

On 2025-05-25 11:40:04 +0200, Christophe JAILLET wrote:
> '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>
> ---
> 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 +-

For R-Car,

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

>  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(-)
> 
> diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> index 9bff21068721..c2fbdb534f61 100644
> --- a/drivers/thermal/armada_thermal.c
> +++ b/drivers/thermal/armada_thermal.c
> @@ -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,
>  };
>  
> diff --git a/drivers/thermal/da9062-thermal.c b/drivers/thermal/da9062-thermal.c
> index 2077e85ef5ca..a8d4b766ba21 100644
> --- a/drivers/thermal/da9062-thermal.c
> +++ b/drivers/thermal/da9062-thermal.c
> @@ -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,
>  };
>  
> diff --git a/drivers/thermal/dove_thermal.c b/drivers/thermal/dove_thermal.c
> index f9157a47156b..723bc72f0626 100644
> --- a/drivers/thermal/dove_thermal.c
> +++ b/drivers/thermal/dove_thermal.c
> @@ -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,
>  };
>  
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index bab52e6b3b15..38c993d1bcb3 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -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,
> diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> index 0e07693ecf59..5736638c586b 100644
> --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> @@ -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,
>  };
> diff --git a/drivers/thermal/kirkwood_thermal.c b/drivers/thermal/kirkwood_thermal.c
> index 7c2265231668..4619e090f756 100644
> --- a/drivers/thermal/kirkwood_thermal.c
> +++ b/drivers/thermal/kirkwood_thermal.c
> @@ -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,
>  };
>  
> diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
> index 985925147ac0..acce8fde2cba 100644
> --- a/drivers/thermal/mediatek/lvts_thermal.c
> +++ b/drivers/thermal/mediatek/lvts_thermal.c
> @@ -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,
>  };
> diff --git a/drivers/thermal/renesas/rcar_thermal.c b/drivers/thermal/renesas/rcar_thermal.c
> index 00a66ee0a5b0..fdd7afdc4ff6 100644
> --- a/drivers/thermal/renesas/rcar_thermal.c
> +++ b/drivers/thermal/renesas/rcar_thermal.c
> @@ -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,
>  };
>  
> diff --git a/drivers/thermal/spear_thermal.c b/drivers/thermal/spear_thermal.c
> index bb96be947521..603dadcd3df5 100644
> --- a/drivers/thermal/spear_thermal.c
> +++ b/drivers/thermal/spear_thermal.c
> @@ -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,
>  };
>  
> diff --git a/drivers/thermal/st/st_thermal.c b/drivers/thermal/st/st_thermal.c
> index a14a37d54698..1470ca519def 100644
> --- a/drivers/thermal/st/st_thermal.c
> +++ b/drivers/thermal/st/st_thermal.c
> @@ -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,
>  };
>  
> diff --git a/drivers/thermal/testing/zone.c b/drivers/thermal/testing/zone.c
> index 1f4e450100e2..4257d813d572 100644
> --- a/drivers/thermal/testing/zone.c
> +++ b/drivers/thermal/testing/zone.c
> @@ -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
> 

-- 
Kind Regards,
Niklas Söderlund

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] thermal: Constify struct thermal_zone_device_ops
  2025-05-25  9:40 [PATCH] thermal: Constify struct thermal_zone_device_ops Christophe JAILLET
  2025-05-25 10:19 ` Niklas Söderlund
@ 2025-05-26  7:29 ` Miquel Raynal
  2025-05-28 16:00 ` Frank Li
  2025-07-15 13:26 ` Daniel Lezcano
  3 siblings, 0 replies; 5+ messages in thread
From: Miquel Raynal @ 2025-05-26  7:29 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Rafael J. Wysocki, Daniel Lezcano, Zhang Rui, Lukasz Luba,
	Support Opensource, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Niklas Söderlund,
	Geert Uytterhoeven, Magnus Damm, Matthias Brugger,
	AngeloGioacchino Del Regno, linux-kernel, kernel-janitors,
	linux-pm, imx, linux-arm-kernel, linux-renesas-soc,
	linux-mediatek

Hello,

On 25/05/2025 at 11:40:04 +02, Christophe JAILLET <christophe.jaillet@wanadoo.fr> wrote:

> '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>
> ---
> Compile tested only
> ---
>  drivers/thermal/armada_thermal.c                        | 2 +-

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> # For Armada

Thanks,
Miquèl

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] thermal: Constify struct thermal_zone_device_ops
  2025-05-25  9:40 [PATCH] thermal: Constify struct thermal_zone_device_ops Christophe JAILLET
  2025-05-25 10:19 ` Niklas Söderlund
  2025-05-26  7:29 ` Miquel Raynal
@ 2025-05-28 16:00 ` Frank Li
  2025-07-15 13:26 ` Daniel Lezcano
  3 siblings, 0 replies; 5+ messages in thread
From: Frank Li @ 2025-05-28 16:00 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Miquel Raynal, Rafael J. Wysocki, Daniel Lezcano, Zhang Rui,
	Lukasz Luba, Support Opensource, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Niklas Söderlund,
	Geert Uytterhoeven, Magnus Damm, Matthias Brugger,
	AngeloGioacchino Del Regno, linux-kernel, kernel-janitors,
	linux-pm, imx, linux-arm-kernel, linux-renesas-soc,
	linux-mediatek

On Sun, May 25, 2025 at 11:40:04AM +0200, Christophe JAILLET wrote:
> '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>
> ---
> 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

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  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(-)
>
> diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c
> index 9bff21068721..c2fbdb534f61 100644
> --- a/drivers/thermal/armada_thermal.c
> +++ b/drivers/thermal/armada_thermal.c
> @@ -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,
>  };
>
> diff --git a/drivers/thermal/da9062-thermal.c b/drivers/thermal/da9062-thermal.c
> index 2077e85ef5ca..a8d4b766ba21 100644
> --- a/drivers/thermal/da9062-thermal.c
> +++ b/drivers/thermal/da9062-thermal.c
> @@ -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,
>  };
>
> diff --git a/drivers/thermal/dove_thermal.c b/drivers/thermal/dove_thermal.c
> index f9157a47156b..723bc72f0626 100644
> --- a/drivers/thermal/dove_thermal.c
> +++ b/drivers/thermal/dove_thermal.c
> @@ -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,
>  };
>
> diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
> index bab52e6b3b15..38c993d1bcb3 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -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,
> diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> index 0e07693ecf59..5736638c586b 100644
> --- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> +++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
> @@ -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,
>  };
> diff --git a/drivers/thermal/kirkwood_thermal.c b/drivers/thermal/kirkwood_thermal.c
> index 7c2265231668..4619e090f756 100644
> --- a/drivers/thermal/kirkwood_thermal.c
> +++ b/drivers/thermal/kirkwood_thermal.c
> @@ -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,
>  };
>
> diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
> index 985925147ac0..acce8fde2cba 100644
> --- a/drivers/thermal/mediatek/lvts_thermal.c
> +++ b/drivers/thermal/mediatek/lvts_thermal.c
> @@ -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,
>  };
> diff --git a/drivers/thermal/renesas/rcar_thermal.c b/drivers/thermal/renesas/rcar_thermal.c
> index 00a66ee0a5b0..fdd7afdc4ff6 100644
> --- a/drivers/thermal/renesas/rcar_thermal.c
> +++ b/drivers/thermal/renesas/rcar_thermal.c
> @@ -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,
>  };
>
> diff --git a/drivers/thermal/spear_thermal.c b/drivers/thermal/spear_thermal.c
> index bb96be947521..603dadcd3df5 100644
> --- a/drivers/thermal/spear_thermal.c
> +++ b/drivers/thermal/spear_thermal.c
> @@ -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,
>  };
>
> diff --git a/drivers/thermal/st/st_thermal.c b/drivers/thermal/st/st_thermal.c
> index a14a37d54698..1470ca519def 100644
> --- a/drivers/thermal/st/st_thermal.c
> +++ b/drivers/thermal/st/st_thermal.c
> @@ -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,
>  };
>
> diff --git a/drivers/thermal/testing/zone.c b/drivers/thermal/testing/zone.c
> index 1f4e450100e2..4257d813d572 100644
> --- a/drivers/thermal/testing/zone.c
> +++ b/drivers/thermal/testing/zone.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] thermal: Constify struct thermal_zone_device_ops
  2025-05-25  9:40 [PATCH] thermal: Constify struct thermal_zone_device_ops Christophe JAILLET
                   ` (2 preceding siblings ...)
  2025-05-28 16:00 ` Frank Li
@ 2025-07-15 13:26 ` Daniel Lezcano
  3 siblings, 0 replies; 5+ messages in thread
From: Daniel Lezcano @ 2025-07-15 13:26 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Miquel Raynal, Rafael J. Wysocki, Zhang Rui, Lukasz Luba,
	Support Opensource, Shawn Guo, Sascha Hauer,
	Pengutronix Kernel Team, Fabio Estevam, Niklas Söderlund,
	Geert Uytterhoeven, Magnus Damm, Matthias Brugger,
	AngeloGioacchino Del Regno, linux-kernel, kernel-janitors,
	linux-pm, imx, linux-arm-kernel, linux-renesas-soc,
	linux-mediatek

On Sun, May 25, 2025 at 11:40:04AM +0200, Christophe JAILLET wrote:
> '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>
> ---
> Compile tested only
> ---

Applied, thanks

-- 

 <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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-07-15 13:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-25  9:40 [PATCH] thermal: Constify struct thermal_zone_device_ops Christophe JAILLET
2025-05-25 10:19 ` Niklas Söderlund
2025-05-26  7:29 ` Miquel Raynal
2025-05-28 16:00 ` Frank Li
2025-07-15 13:26 ` Daniel Lezcano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).