Skip to contentSkip to conversation

thermal/intel_powerclamp: add const to thermal_cooling_device_ops structure

PATCH In review Bhumika Goyal 2 participants 6 messages Jun 21, 2017 – Jun 29, 2017 Thermal

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 thermal/intel_powerclamp: add const to thermal_cooling_device_ops structure

Declare thermal_cooling_device_ops structure as const as it is only passed as an argument to the function thermal_cooling_device_register and this argument is of type const. So, declare the structure as const.

---
 drivers/thermal/intel_powerclamp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/intel_powerclamp.c +1 -1
index d718cd1..e4c68b7 100644
@@ -659,7 +659,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.7.4
reviewer
#1 lore raw
Quoted 6 lines · Bhumika Goyal

Declare thermal_cooling_device_ops structure as const as it is only passed
as an argument to the function thermal_cooling_device_register and this
argument is of type const. So, declare the structure as const.

I checked the source and the code is written in this way as well in some other drivers, why not fix them altogether?

thanks,
rui

Quoted 21 lines

---
 drivers/thermal/intel_powerclamp.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/intel_powerclamp.c +0 -0
index d718cd1..e4c68b7 100644
@@ -659,7 +659,7 @@ static int powerclamp_set_cur_state(struct
 thermal_cooling_device *cdev,
  }


 /* bind to generic thermal layer as cooling device*/

drivers/thermal/intel_powerclamp.c +1 -1
-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,

#2 lore raw
Quoted 10 lines · Zhang Rui
Quoted 6 lines · Bhumika Goyal

Declare thermal_cooling_device_ops structure as const as it is only passed
as an argument to the function thermal_cooling_device_register and this
argument is of type const. So, declare the structure as const.

I checked the source and the code is written in this way as well in some other drivers, why not fix them altogether?

Hey,

I have already sent the patches for the drivers requiring this change. Some of them got applied as well.

Thanks,
Bhumika

Quoted 23 lines

thanks,
rui

Quoted 21 lines
---
 drivers/thermal/intel_powerclamp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/intel_powerclamp.c +1 -1
index d718cd1..e4c68b7 100644
@@ -659,7 +659,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,

reviewer
#3 lore raw
Quoted 13 lines · Bhumika Goyal
Quoted 11 lines · Zhang Rui
Quoted 9 lines · Bhumika Goyal

Declare thermal_cooling_device_ops structure as const as it is only
passed
as an argument to the function thermal_cooling_device_register and
this
argument is of type const. So, declare the structure as const.

Quoted 8 lines
Quoted 3 lines

I checked the source and the code is written in this way as well in some other drivers, why not fix them altogether?

Hey,

I have already sent the patches for the drivers requiring this change.
Some of them got applied as well.

I mean the other drivers that use thermal_cooling_device_ops.

Surely I can applied this patch, but still it would be nice if you can check the other places that defines thermal_cooling_device_ops and fix all of them in one time. :)

thanks,
rui

Quoted 30 lines

Thanks,
Bhumika

Quoted 26 lines

thanks,
rui

Quoted 23 lines

---
 drivers/thermal/intel_powerclamp.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/intel_powerclamp.c +1 -1
index d718cd1..e4c68b7 100644
@@ -659,7 +659,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,

#4 lore raw
Quoted 17 lines · Zhang Rui
Quoted 16 lines · Bhumika Goyal
Quoted 14 lines · Zhang Rui
Quoted 9 lines · Bhumika Goyal

Declare thermal_cooling_device_ops structure as const as it is only
passed
as an argument to the function thermal_cooling_device_register and
this
argument is of type const. So, declare the structure as const.

I checked the source and the code is written in this way as well in some other drivers, why not fix them altogether?

Quoted 8 lines
Quoted 5 lines

Hey,

I have already sent the patches for the drivers requiring this change.
Some of them got applied as well.

I mean the other drivers that use thermal_cooling_device_ops.

Actually, I also meant the same but maybe I wasn't clear enough :)

Quoted 4 lines

Surely I can applied this patch, but still it would be nice if you can check the other places that defines thermal_cooling_device_ops and fix all of them in one time. :)

I checked again and there remains only one file in power/supply where thermal_cooling_device_ops can be made const. I will submit a patch for it but I think I will have to create a separate patch because the maintainers are different.
All other places are either already const or I have submitted patches for them or cannot be made const.

Thanks,
Bhumika

Quoted 32 lines

thanks,
rui

Quoted 30 lines

Thanks,
Bhumika

Quoted 26 lines

thanks,
rui

Quoted 23 lines
---
 drivers/thermal/intel_powerclamp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/intel_powerclamp.c +1 -1
index d718cd1..e4c68b7 100644
@@ -659,7 +659,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,

reviewer
#5 lore raw
Quoted 50 lines · Bhumika Goyal
Quoted 25 lines · Zhang Rui
Quoted 23 lines · Bhumika Goyal
Quoted 20 lines · Zhang Rui
Quoted 13 lines · Bhumika Goyal

Declare thermal_cooling_device_ops structure as const as it is
only
passed
as an argument to the function thermal_cooling_device_register
and
this
argument is of type const. So, declare the structure as const.

I checked the source and the code is written in this way as well in
some other drivers, why not fix them altogether?

Quoted 7 lines
Quoted 5 lines

Hey,

I have already sent the patches for the drivers requiring this change.
Some of them got applied as well.

I mean the other drivers that use thermal_cooling_device_ops.

Actually, I also meant the same but maybe I wasn't clear enough :)

Quoted 7 lines

Surely I can applied this patch, but still it would be nice if you can
check the other places that defines thermal_cooling_device_ops and fix
all of them in one time. :)

I checked again and there remains only one file in power/supply where thermal_cooling_device_ops can be made const. I will submit a patch for it but I think I will have to create a separate patch because the maintainers are different.
All other places are either already const

Quoted 2 lines

or I have submitted patches
for them

am I in the loop of the patches? because I was not aware of those changes.

thanks,
rui

Quoted 43 lines

or cannot be made const.

Thanks,
Bhumika

Quoted 38 lines

thanks,
rui

Quoted 35 lines

Thanks,
Bhumika

Quoted 30 lines

thanks,
rui

Quoted 26 lines

---
 drivers/thermal/intel_powerclamp.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/intel_powerclamp.c +0 -0
index d718cd1..e4c68b7 100644
@@ -659,7 +659,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,