Skip to contentSkip to conversation

thermal: intel_powerclamp: Constify static thermal_cooling_device_ops

PATCH Applied Rikard Falkeborn 3 participants 3 messages Nov 28, 2021 – Dec 12, 2021 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal: intel_powerclamp: Constify static thermal_cooling_device_ops

The only usage of powerclamp_cooling_ops is to pass its address to thermal_cooling_device_register(), which takes a pointer to const struct thermal_cooling_device_ops. Make it const to allow the compiler to put it in read-only memory.

---
 drivers/thermal/intel/intel_powerclamp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/intel/intel_powerclamp.c +1 -1
index 9b68489a2356..14256421d98c 100644
@@ -641,7 +641,7 @@ static int powerclamp_set_cur_state(struct thermal_cooling_device *cdev,
 }
 
 /* bind to generic thermal layer as cooling device*/
-static struct thermal_cooling_device_ops powerclamp_cooling_ops = {
+static const struct thermal_cooling_device_ops powerclamp_cooling_ops = {
 	.get_max_state = powerclamp_get_max_state,
 	.get_cur_state = powerclamp_get_cur_state,
 	.set_cur_state = powerclamp_set_cur_state,
Signature · 1 line
2.34.1
#1 lore raw
Quoted 6 lines · Rikard Falkeborn

The only usage of powerclamp_cooling_ops is to pass its address to thermal_cooling_device_register(), which takes a pointer to const struct thermal_cooling_device_ops. Make it const to allow the compiler to put it in read-only memory.

Applied, thanks

Quoted 18 lines
---
 drivers/thermal/intel/intel_powerclamp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/intel/intel_powerclamp.c +1 -1
index 9b68489a2356..14256421d98c 100644
@@ -641,7 +641,7 @@ static int powerclamp_set_cur_state(struct thermal_cooling_device *cdev,
 }
 
 /* bind to generic thermal layer as cooling device*/
-static struct thermal_cooling_device_ops powerclamp_cooling_ops = {
+static const struct thermal_cooling_device_ops powerclamp_cooling_ops = {
 	.get_max_state = powerclamp_get_max_state,
 	.get_cur_state = powerclamp_get_cur_state,
 	.set_cur_state = powerclamp_set_cur_state,
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
#2 lore raw

[thermal: thermal/next] thermal/drivers/intel_powerclamp: Constify static thermal_cooling_device_ops

In reply to Rikard Falkeborn
The following commit has been merged into the thermal/next branch of thermal:

The following commit has been merged into the thermal/next branch of thermal:

Commit-ID:     8152d2a9e73deb2b483bef9035d53ded27f50317
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//8152d2a9e73deb2b483bef9035d53ded27f50317
Author:        Rikard Falkeborn <[email protected]>
AuthorDate:    Sun, 28 Nov 2021 22:46:41 +01:00
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Tue, 30 Nov 2021 15:42:39 +01:00

thermal/drivers/intel_powerclamp: Constify static thermal_cooling_device_ops

The only usage of powerclamp_cooling_ops is to pass its address to thermal_cooling_device_register(), which takes a pointer to const struct thermal_cooling_device_ops. Make it const to allow the compiler to put it in read-only memory.

---
 drivers/thermal/intel/intel_powerclamp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/intel/intel_powerclamp.c +1 -1
index 9b68489..1425642 100644
@@ -641,7 +641,7 @@ exit_set:
 }
 
 /* bind to generic thermal layer as cooling device*/
-static struct thermal_cooling_device_ops powerclamp_cooling_ops = {
+static const struct thermal_cooling_device_ops powerclamp_cooling_ops = {
 	.get_max_state = powerclamp_get_max_state,
 	.get_cur_state = powerclamp_get_cur_state,
 	.set_cur_state = powerclamp_set_cur_state,