Skip to contentSkip to conversation

thermal/core: Remove pointless variable when registering a cooling device

PATCH Applied Daniel Lezcano 3 participants 3 messages Apr 2 – Apr 4 Thermal

lore
Share & tools
lore

Daniel Lezcano

author maintainer
#0 lore raw

PATCH 1/1 thermal/core: Remove pointless variable when registering a cooling device

From: Daniel Lezcano <[email protected]>

The 'id' variable is set to store the ida_alloc() value which is already stored into cdev->id. It is pointless to use it because cdev->id can be used instead.

---
 drivers/thermal/thermal_core.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/thermal/thermal_core.c +2 -3
index b7d706ed7ed9..02ce58223f9f 100644
@@ -1061,7 +1061,7 @@ __thermal_cooling_device_register(struct device_node *np,
 {
 	struct thermal_cooling_device *cdev;
 	unsigned long current_state;
-	int id, ret;
+	int ret;
 
 	if (!ops || !ops->get_max_state || !ops->get_cur_state ||
 	    !ops->set_cur_state)
@@ -1078,7 +1078,6 @@ __thermal_cooling_device_register(struct device_node *np,
 	if (ret < 0)
 		goto out_kfree_cdev;
 	cdev->id = ret;
-	id = ret;
 
 	cdev->type = kstrdup_const(type ? type : "", GFP_KERNEL);
 	if (!cdev->type) {
@@ -1135,7 +1134,7 @@ __thermal_cooling_device_register(struct device_node *np,
 out_cdev_type:
 	kfree_const(cdev->type);
 out_ida_remove:
-	ida_free(&thermal_cdev_ida, id);
+	ida_free(&thermal_cdev_ida, cdev->id);
 out_kfree_cdev:
 	kfree(cdev);
 	return ERR_PTR(ret);
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 34 lines · Daniel Lezcano

From: Daniel Lezcano <[email protected]>

The 'id' variable is set to store the ida_alloc() value which is already stored into cdev->id. It is pointless to use it because cdev->id can be used instead.

---
  drivers/thermal/thermal_core.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
drivers/thermal/thermal_core.c +1 -2
index b7d706ed7ed9..02ce58223f9f 100644
@@ -1061,7 +1061,7 @@ __thermal_cooling_device_register(struct device_node *np,
  {
  	struct thermal_cooling_device *cdev;
  	unsigned long current_state;
-	int id, ret;
+	int ret;
 
  	if (!ops || !ops->get_max_state || !ops->get_cur_state ||
  	    !ops->set_cur_state)
@@ -1078,7 +1078,6 @@ __thermal_cooling_device_register(struct device_node *np,
  	if (ret < 0)
  		goto out_kfree_cdev;
  	cdev->id = ret;
-	id = ret;
 
  	cdev->type = kstrdup_const(type ? type : "", GFP_KERNEL);
  	if (!cdev->type) {

drivers/thermal/thermal_core.c __thermal_cooling_device_register(struct device_node *np, · line 1140

Quoted 8 lines
drivers/thermal/thermal_core.c +1 -1
@@ -1135,7 +1134,7 @@ __thermal_cooling_device_register(struct device_node *np,
  out_cdev_type:
  	kfree_const(cdev->type);
  out_ida_remove:
-	ida_free(&thermal_cdev_ida, id);
+	ida_free(&thermal_cdev_ida, cdev->id);
  out_kfree_cdev:
  	kfree(cdev);
  	return ERR_PTR(ret);
maintainer Applied
#2 lore raw
Quoted 35 lines · Lukasz Luba
Quoted 31 lines · Daniel Lezcano

From: Daniel Lezcano <[email protected]>

The 'id' variable is set to store the ida_alloc() value which is already stored into cdev->id. It is pointless to use it because cdev->id can be used instead.

---
  drivers/thermal/thermal_core.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
drivers/thermal/thermal_core.c +1 -2
index b7d706ed7ed9..02ce58223f9f 100644
@@ -1061,7 +1061,7 @@ __thermal_cooling_device_register(struct device_node *np,
  {
      struct thermal_cooling_device *cdev;
      unsigned long current_state;
-     int id, ret;
+     int ret;
 
      if (!ops || !ops->get_max_state || !ops->get_cur_state ||
          !ops->set_cur_state)
@@ -1078,7 +1078,6 @@ __thermal_cooling_device_register(struct device_node *np,
      if (ret < 0)
              goto out_kfree_cdev;
      cdev->id = ret;
-     id = ret;
 
Quoted 14 lines

drivers/thermal/thermal_core.c __thermal_cooling_device_register(struct device_node *np, · line 1140

Quoted 11 lines
drivers/thermal/thermal_core.c +1 -1
      cdev->type = kstrdup_const(type ? type : "", GFP_KERNEL);
      if (!cdev->type) {
@@ -1135,7 +1134,7 @@ __thermal_cooling_device_register(struct device_node *np,
  out_cdev_type:
      kfree_const(cdev->type);
  out_ida_remove:
-     ida_free(&thermal_cdev_ida, id);
+     ida_free(&thermal_cdev_ida, cdev->id);
  out_kfree_cdev:
      kfree(cdev);
      return ERR_PTR(ret);

Applied as 7.1 material, thanks!